diff --git a/include/ui.js b/include/ui.js index cb5717cbd..b15023ec7 100644 --- a/include/ui.js +++ b/include/ui.js @@ -96,6 +96,7 @@ var UI; UI.initSetting('view_only', false); UI.initSetting('path', 'websockify'); UI.initSetting('repeaterID', ''); + UI.initSetting('token', ''); var autoconnect = WebUtil.getQueryVar('autoconnect', false); if (autoconnect === 'true' || autoconnect == '1') { @@ -519,6 +520,7 @@ var UI; UI.connSettingsOpen = false; UI.saveSetting('host'); UI.saveSetting('port'); + UI.saveSetting('token'); //UI.saveSetting('password'); } else { $D('noVNC_controls').style.display = "block"; @@ -810,7 +812,17 @@ var UI; var host = $D('noVNC_host').value; var port = $D('noVNC_port').value; var password = $D('noVNC_password').value; + var token = $D('noVNC_token').value; var path = $D('noVNC_path').value; + + //if token is in path then ignore the new token variable + if (token && !(path.indexOf("token") > -1)){ + if (path.indexOf("?") > -1) + path += "&token=" + token; //there is a query string already + else + path += "?token=" + token; + } + if ((!host) || (!port)) { throw new Error("Must set host and port"); } diff --git a/vnc.html b/vnc.html index 1a293d090..ea23a1ccc 100644 --- a/vnc.html +++ b/vnc.html @@ -197,6 +197,7 @@
+ diff --git a/vnc_auto.html b/vnc_auto.html index 86cfde75e..18659d565 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -200,16 +200,25 @@ } } + password = WebUtil.getQueryVar('password', ''); + path = WebUtil.getQueryVar('path', 'websockify'); + // If a token variable is passed in, set the parameter in a cookie. // This is used by nova-novncproxy. token = WebUtil.getQueryVar('token', null); if (token) { + + //if token is already present in the path we should use it + if (!(path.indexOf("token") > -1)){ + if (path.indexOf("?") > -1) + path += "&token=" + token; //there is a query string already + else + path += "?token=" + token; + } + WebUtil.createCookie('token', token, 1) } - password = WebUtil.getQueryVar('password', ''); - path = WebUtil.getQueryVar('path', 'websockify'); - if ((!host) || (!port)) { updateState(null, 'fatal', null, 'Must specify host and port in URL'); return;