diff --git a/index.js b/index.js index 13b1b43..2173768 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,12 @@ -// index.js +'use strict' +/* jshint esversion: 6, asi: true, node: true */ /* + * index.js + * * WebSSH2 - Web to SSH2 gateway * Bill Church - https://github.com/billchurch/WebSSH2 - May 2017 * */ -'use strict' var config = require('./server/app').config var server = require('./server/app').server diff --git a/server/app.js b/server/app.js index c91a0dd..bd4ffe1 100644 --- a/server/app.js +++ b/server/app.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // app.js var path = require('path') diff --git a/server/socket.js b/server/socket.js index d788b05..577607c 100644 --- a/server/socket.js +++ b/server/socket.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // socket.js // private diff --git a/server/util.js b/server/util.js index 2bf52c6..634926f 100644 --- a/server/util.js +++ b/server/util.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // util.js // private diff --git a/workspace/extensions/webssh2/server/app.js b/workspace/extensions/webssh2/server/app.js index dae3eb7..bd4ffe1 100644 --- a/workspace/extensions/webssh2/server/app.js +++ b/workspace/extensions/webssh2/server/app.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // app.js var path = require('path') @@ -35,6 +37,11 @@ app.disable('x-powered-by') // static files app.use(express.static(publicPath, expressOptions)) +app.get('/reauth', function (req, res, next) { + var r = req.headers.referer || '/' + res.status(401).send('') +}) + app.get('/ssh/host/:host?', function (req, res, next) { res.sendFile(path.join(path.join(publicPath, 'client.htm'))) // capture, assign, and validated variables @@ -60,7 +67,8 @@ app.get('/ssh/host/:host?', function (req, res, next) { tabStopWidth: (validator.isInt(req.query.tabStopWidth + '', {min: 1, max: 100}) && req.query.tabStopWidth) ? req.query.tabStopWidth : config.terminal.tabStopWidth, bellStyle: ((req.query.bellStyle) && (['sound', 'none'].indexOf(req.query.bellStyle) > -1)) ? req.query.bellStyle : config.terminal.bellStyle }, - allowreplay: (validator.isBoolean(req.headers.allowreplay + '') ? myutil.parseBool(req.headers.allowreplay) : false), + allowreplay: config.options.challengeButton || (validator.isBoolean(req.headers.allowreplay + '') ? myutil.parseBool(req.headers.allowreplay) : false), + allowreauth: config.options.allowreauth || false, mrhsession: ((validator.isAlphanumeric(req.headers.mrhsession + '') && req.headers.mrhsession) ? req.headers.mrhsession : 'none'), serverlog: { client: config.serverlog.client || false, diff --git a/workspace/extensions/webssh2/server/socket.js b/workspace/extensions/webssh2/server/socket.js index a43cebd..577607c 100644 --- a/workspace/extensions/webssh2/server/socket.js +++ b/workspace/extensions/webssh2/server/socket.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // socket.js // private @@ -7,7 +9,8 @@ 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' // public module.exports = function socket (socket) { @@ -24,7 +27,7 @@ module.exports = function socket (socket) { termRows = rows }) conn.on('banner', function connOnBanner (data) { - // need to convert to cr/lf for proper formatting + // need to convert to cr/lf for proper formatting data = data.replace(/\r?\n/g, '\r\n') socket.emit('data', data.toString('utf-8')) }) @@ -40,6 +43,7 @@ module.exports = function socket (socket) { socket.emit('status', 'SSH CONNECTION ESTABLISHED') socket.emit('statusBackground', 'green') socket.emit('allowreplay', socket.request.session.ssh.allowreplay) + socket.emit('allowreauth', socket.request.session.ssh.allowreauth) conn.shell({ term: socket.request.session.ssh.term, cols: termCols, diff --git a/workspace/extensions/webssh2/server/util.js b/workspace/extensions/webssh2/server/util.js index 546a0b5..634926f 100644 --- a/workspace/extensions/webssh2/server/util.js +++ b/workspace/extensions/webssh2/server/util.js @@ -1,3 +1,5 @@ +'use strict' +/* jshint esversion: 6, asi: true, node: true */ // util.js // private @@ -12,7 +14,7 @@ exports.basicAuth = function basicAuth (req, res, next) { req.session.userpassword = myAuth.pass debug('myAuth.name: ' + myAuth.name.yellow.bold.underline + ' and password ' + ((myAuth.pass) ? 'exists'.yellow.bold.underline - : 'is blank'.underline.red.bold)) + : 'is blank'.underline.red.bold)) next() } else { res.statusCode = 401