From: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
get the password from cookie and pass them in url to spice and VNC page.
For spice we need to get the password from this url and pass it to
websocket connection.
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
ui/pages/spice.html.tmpl | 3 ++-
ui/pages/websockify/console.html | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ui/pages/spice.html.tmpl b/ui/pages/spice.html.tmpl
index 213d216..c2bdffe 100644
--- a/ui/pages/spice.html.tmpl
+++ b/ui/pages/spice.html.tmpl
@@ -64,6 +64,7 @@
host = getParameter("listen");
port = getParameter("port");
token = getParameter("token");
+ password = getParameter("password")
document.getElementById("host").value = host;
document.getElementById("port").value = port;
if ((!host) || (!port)) {
@@ -82,7 +83,7 @@
screen_id : "spice-screen",
dump_id : "debug-div",
message_id : "message-div",
- password : "",
+ password : password,
onerror : spice_error
});
} catch (e) {
diff --git a/ui/pages/websockify/console.html b/ui/pages/websockify/console.html
index a536e38..7706074 100644
--- a/ui/pages/websockify/console.html
+++ b/ui/pages/websockify/console.html
@@ -16,6 +16,11 @@
var url = "https://" + location.hostname + ":" + kimchi_port
+ "/";
url += path + query
+ var cookieRe = new RegExp(';?\\\s*(ticketVM)=(\s*[^;]*);?',
'g');
+ var match = cookieRe.exec(document.cookie);
+ var ticket = match ? decodeURIComponent(match[2]) : undefined;
+ url += ticket ? "&password=" + ticket : '';
+
window.location.replace(url)
}
</script>
--
1.9.0