From 039d3630c5340312d2b066ee89d016c5bae52d56 Mon Sep 17 00:00:00 2001 From: Valentin Valchev Date: Mon, 23 Jul 2018 13:02:50 +0300 Subject: [PATCH 1/3] The provided patch, will add a /logout URL, which will re-request the authentication and then redirect you back to the referrer (e.g like http://localhost:2222/ssh/host/myhost.com). It also adds a menu entry "Switch User" that opens /logout and forces re-authentication. --- server/app.js | 13 +++++++++++++ server/socket.js | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index dae3eb79c..72ab4fe3c 100644 --- a/server/app.js +++ b/server/app.js @@ -35,6 +35,19 @@ app.disable('x-powered-by') // static files app.use(express.static(publicPath, expressOptions)) +app.get('/logout', function (req, res, next) { + var r = req.headers.referer || '/'; + res.status(401).send( + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Go Back' + + ' ' + + ''); +}) + app.get('/ssh/host/:host?', function (req, res, next) { res.sendFile(path.join(path.join(publicPath, 'client.htm'))) // capture, assign, and validated variables diff --git a/server/socket.js b/server/socket.js index fceedcbfe..08489f538 100644 --- a/server/socket.js +++ b/server/socket.js @@ -7,7 +7,9 @@ var SSH = require('ssh2').Client // var fs = require('fs') // var hostkeys = JSON.parse(fs.readFileSync('./hostkeyhashes.json', 'utf8')) var termCols, termRows -var menuData = ' Start Log Download Log' +var menuData = ' Start Log' + + ' Download Log' + + ' Switch User'; // public module.exports = function socket (socket) { From 31be90405036b9e8c17410c40a1f480450e61842 Mon Sep 17 00:00:00 2001 From: Bill Church Date: Mon, 30 Jul 2018 08:17:39 -0400 Subject: [PATCH 2/3] Update app.js changed URL to `reauth` from `logout` as it's not quite performing a `logout` function. --- server/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 72ab4fe3c..140c398fa 100644 --- a/server/app.js +++ b/server/app.js @@ -35,7 +35,7 @@ app.disable('x-powered-by') // static files app.use(express.static(publicPath, expressOptions)) -app.get('/logout', function (req, res, next) { +app.get('/reauth', function (req, res, next) { var r = req.headers.referer || '/'; res.status(401).send( '' + From 3963106030e790ac7055bcd544957a63d110435e Mon Sep 17 00:00:00 2001 From: Bill Church Date: Mon, 30 Jul 2018 08:18:26 -0400 Subject: [PATCH 3/3] Update socket.js changing from `logout` to `reauth` --- server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/socket.js b/server/socket.js index 08489f538..4ea8ac53f 100644 --- a/server/socket.js +++ b/server/socket.js @@ -9,7 +9,7 @@ var SSH = require('ssh2').Client var termCols, termRows var menuData = ' Start Log' + ' Download Log' + - ' Switch User'; + ' Switch User'; // public module.exports = function socket (socket) {