webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 57c9a264eadef94d7c3a45992548087ff9037618
parent b3c2094cd2501c7f828edcd21ec9666680ef4839
Author: Sheng <webmaster0115@gmail.com>
Date:   Sat, 10 Aug 2019 14:41:15 +0800

Password via url requires to be encoded in base64

Diffstat:
Mwebssh/static/js/main.js | 31+++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js @@ -103,6 +103,15 @@ jQuery(function($){ } + function decode_password(encoded) { + try { + return window.atob(encoded); + } catch (e) { + console.error(e); + } + } + + function parse_url_data(string, form_map, opts_map) { var i, pair, key, val, arr = string.split('&'); @@ -112,6 +121,10 @@ jQuery(function($){ key = pair[0].trim().toLowerCase(); val = pair[1] && pair[1].trim(); + if (key === 'password' && val) { + val = decode_password(val); + } + if (form_map[key] === '') { form_map[key] = val; } else if (opts_map[key] === '') { @@ -762,18 +775,24 @@ jQuery(function($){ restore_items(fields); - initialize_map(fields.concat(['password']), url_form_data); + initialize_map(fields.concat(['password', 'totp']), url_form_data); initialize_map(['bgcolor', 'title', 'encoding', 'command'], url_opts_data); parse_url_data( decode_uri(window.location.search.substring(1)) + '&' + decode_uri(window.location.hash.substring(1)), url_form_data, url_opts_data ); - console.log(url_form_data); - console.log(url_opts_data); - - if (url_form_data.hostname && url_form_data.username) { - connect(url_form_data); + // console.log(url_form_data); + // console.log(url_opts_data); + + if (url_form_data.password === undefined) { + log_status('Password via url must be encoded in base64.'); + } else { + if (url_form_data.hostname && url_form_data.username) { + connect(url_form_data); + } else { + log_status('Values of hostname and username are required.'); + } } });