fix: read-config-ng references
This commit is contained in:
parent
ea12cc8b7e
commit
9537f4da67
3 changed files with 81 additions and 33 deletions
|
@ -1,5 +1,13 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [0.2.13] 2024-07-11
|
||||||
|
|
||||||
|
BIG-IP Specific version
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- fixed missing reference to `read-config-ng` switchover which could prevent `config.json` from being read
|
||||||
|
|
||||||
## [0.2.12] 2024-07-10
|
## [0.2.12] 2024-07-10
|
||||||
|
|
||||||
BIG-IP Specific version
|
BIG-IP Specific version
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "webssh2",
|
"name": "webssh2",
|
||||||
"version": "0.2.12",
|
"version": "0.2.13",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
".gitignore"
|
".gitignore"
|
||||||
],
|
],
|
||||||
|
|
|
@ -68,16 +68,8 @@ let config = {
|
||||||
'aes256-gcm@openssh.com',
|
'aes256-gcm@openssh.com',
|
||||||
'aes256-cbc'
|
'aes256-cbc'
|
||||||
],
|
],
|
||||||
hmac: [
|
hmac: ['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'],
|
||||||
'hmac-sha2-256',
|
compress: ['none', 'zlib@openssh.com', 'zlib']
|
||||||
'hmac-sha2-512',
|
|
||||||
'hmac-sha1'
|
|
||||||
],
|
|
||||||
compress: [
|
|
||||||
'none',
|
|
||||||
'zlib@openssh.com',
|
|
||||||
'zlib'
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
serverlog: {
|
serverlog: {
|
||||||
client: false,
|
client: false,
|
||||||
|
@ -92,13 +84,19 @@ let config = {
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(configPath)) {
|
if (fs.existsSync(configPath)) {
|
||||||
console.log('ephemeral_auth service reading config from: ' + configPath)
|
console.log('ephemeral_auth service reading config from: ' + configPath)
|
||||||
config = require('read-config')(configPath)
|
config = require('read-config-ng')(configPath)
|
||||||
} else {
|
} else {
|
||||||
console.error('\n\nERROR: Missing config.json for webssh. Current config: ' + JSON.stringify(config))
|
console.error(
|
||||||
|
'\n\nERROR: Missing config.json for webssh. Current config: ' +
|
||||||
|
JSON.stringify(config)
|
||||||
|
)
|
||||||
console.error('\n See config.json.sample for details\n\n')
|
console.error('\n See config.json.sample for details\n\n')
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('\n\nERROR: Missing config.json for webssh. Current config: ' + JSON.stringify(config))
|
console.error(
|
||||||
|
'\n\nERROR: Missing config.json for webssh. Current config: ' +
|
||||||
|
JSON.stringify(config)
|
||||||
|
)
|
||||||
console.error('\n See config.json.sample for details\n\n')
|
console.error('\n See config.json.sample for details\n\n')
|
||||||
console.error('ERROR:\n\n ' + err)
|
console.error('ERROR:\n\n ' + err)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +113,11 @@ var compression = require('compression')
|
||||||
var server = require('http').Server(app)
|
var server = require('http').Server(app)
|
||||||
var myutil = require('./util')
|
var myutil = require('./util')
|
||||||
var validator = require('validator')
|
var validator = require('validator')
|
||||||
var io = require('socket.io')(server, { serveClient: false, path: '/ssh/socket.io', origins: config.http.origins })
|
var io = require('socket.io')(server, {
|
||||||
|
serveClient: false,
|
||||||
|
path: '/ssh/socket.io',
|
||||||
|
origins: config.http.origins
|
||||||
|
})
|
||||||
var socket = require('./socket')
|
var socket = require('./socket')
|
||||||
var expressOptions = require('./expressOptions')
|
var expressOptions = require('./expressOptions')
|
||||||
var favicon = require('serve-favicon')
|
var favicon = require('serve-favicon')
|
||||||
|
@ -136,7 +138,13 @@ app.use(favicon(path.join(publicPath,'favicon.ico')))
|
||||||
|
|
||||||
app.get('/ssh/reauth', function (req, res, next) {
|
app.get('/ssh/reauth', function (req, res, next) {
|
||||||
var r = req.headers.referer || '/'
|
var r = req.headers.referer || '/'
|
||||||
res.status(401).send('<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=' + r + '"></head><body bgcolor="#000"></body></html>')
|
res
|
||||||
|
.status(401)
|
||||||
|
.send(
|
||||||
|
'<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=' +
|
||||||
|
r +
|
||||||
|
'"></head><body bgcolor="#000"></body></html>'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line complexity
|
// eslint-disable-next-line complexity
|
||||||
|
@ -144,12 +152,16 @@ app.get('/ssh/host/:host?', function (req, res, next) {
|
||||||
res.sendFile(path.join(path.join(publicPath, 'client.htm')))
|
res.sendFile(path.join(path.join(publicPath, 'client.htm')))
|
||||||
// capture, assign, and validated variables
|
// capture, assign, and validated variables
|
||||||
req.session.ssh = {
|
req.session.ssh = {
|
||||||
host: (validator.isIP(req.params.host + '') && req.params.host) ||
|
host:
|
||||||
|
(validator.isIP(req.params.host + '') && req.params.host) ||
|
||||||
(validator.isFQDN(req.params.host) && req.params.host) ||
|
(validator.isFQDN(req.params.host) && req.params.host) ||
|
||||||
(/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.params.host) &&
|
(/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.params.host) &&
|
||||||
req.params.host) || config.ssh.host,
|
req.params.host) ||
|
||||||
port: (validator.isInt(req.query.port + '', { min: 1, max: 65535 }) &&
|
config.ssh.host,
|
||||||
req.query.port) || config.ssh.port,
|
port:
|
||||||
|
(validator.isInt(req.query.port + '', { min: 1, max: 65535 }) &&
|
||||||
|
req.query.port) ||
|
||||||
|
config.ssh.port,
|
||||||
header: {
|
header: {
|
||||||
name: req.query.header || config.header.text,
|
name: req.query.header || config.header.text,
|
||||||
background: req.query.headerBackground || config.header.background
|
background: req.query.headerBackground || config.header.background
|
||||||
|
@ -157,26 +169,53 @@ app.get('/ssh/host/:host?', function (req, res, next) {
|
||||||
algorithms: config.algorithms,
|
algorithms: config.algorithms,
|
||||||
keepaliveInterval: config.ssh.keepaliveInterval,
|
keepaliveInterval: config.ssh.keepaliveInterval,
|
||||||
keepaliveCountMax: config.ssh.keepaliveCountMax,
|
keepaliveCountMax: config.ssh.keepaliveCountMax,
|
||||||
term: (/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm) &&
|
term:
|
||||||
req.query.sshterm) || config.ssh.term,
|
(/^(([a-z]|[A-Z]|[0-9]|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm) &&
|
||||||
|
req.query.sshterm) ||
|
||||||
|
config.ssh.term,
|
||||||
terminal: {
|
terminal: {
|
||||||
cursorBlink: (validator.isBoolean(req.query.cursorBlink + '') ? myutil.parseBool(req.query.cursorBlink) : config.terminal.cursorBlink),
|
cursorBlink: validator.isBoolean(req.query.cursorBlink + '')
|
||||||
scrollback: (validator.isInt(req.query.scrollback + '', { min: 1, max: 200000 }) && req.query.scrollback) ? req.query.scrollback : config.terminal.scrollback,
|
? myutil.parseBool(req.query.cursorBlink)
|
||||||
tabStopWidth: (validator.isInt(req.query.tabStopWidth + '', { min: 1, max: 100 }) && req.query.tabStopWidth) ? req.query.tabStopWidth : config.terminal.tabStopWidth,
|
: config.terminal.cursorBlink,
|
||||||
bellStyle: ((req.query.bellStyle) && (['sound', 'none'].indexOf(req.query.bellStyle) > -1)) ? req.query.bellStyle : config.terminal.bellStyle
|
scrollback:
|
||||||
|
validator.isInt(req.query.scrollback + '', { min: 1, max: 200000 }) &&
|
||||||
|
req.query.scrollback
|
||||||
|
? req.query.scrollback
|
||||||
|
: config.terminal.scrollback,
|
||||||
|
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: config.options.challengeButton || (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,
|
allowreauth: config.options.allowreauth || false,
|
||||||
mrhsession: ((validator.isAlphanumeric(req.headers.mrhsession + '') && req.headers.mrhsession) ? req.headers.mrhsession : 'none'),
|
mrhsession:
|
||||||
|
validator.isAlphanumeric(req.headers.mrhsession + '') &&
|
||||||
|
req.headers.mrhsession
|
||||||
|
? req.headers.mrhsession
|
||||||
|
: 'none',
|
||||||
serverlog: {
|
serverlog: {
|
||||||
client: config.serverlog.client || false,
|
client: config.serverlog.client || false,
|
||||||
server: config.serverlog.server || false
|
server: config.serverlog.server || false
|
||||||
},
|
},
|
||||||
readyTimeout: (validator.isInt(req.query.readyTimeout + '', { min: 1, max: 300000 }) &&
|
readyTimeout:
|
||||||
req.query.readyTimeout) || config.ssh.readyTimeout
|
(validator.isInt(req.query.readyTimeout + '', { min: 1, max: 300000 }) &&
|
||||||
|
req.query.readyTimeout) ||
|
||||||
|
config.ssh.readyTimeout
|
||||||
}
|
}
|
||||||
if (req.session.ssh.header.name) validator.escape(req.session.ssh.header.name)
|
if (req.session.ssh.header.name) validator.escape(req.session.ssh.header.name)
|
||||||
if (req.session.ssh.header.background) validator.escape(req.session.ssh.header.background)
|
if (req.session.ssh.header.background)
|
||||||
|
validator.escape(req.session.ssh.header.background)
|
||||||
})
|
})
|
||||||
|
|
||||||
// express error handling
|
// express error handling
|
||||||
|
@ -192,7 +231,8 @@ app.use(function (err, req, res, next) {
|
||||||
// socket.io
|
// socket.io
|
||||||
// expose express session with socket.request.session
|
// expose express session with socket.request.session
|
||||||
io.use(function (socket, next) {
|
io.use(function (socket, next) {
|
||||||
(socket.request.res) ? session(socket.request, socket.request.res, next)
|
socket.request.res
|
||||||
|
? session(socket.request, socket.request.res, next)
|
||||||
: next(next)
|
: next(next)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue