Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f357c89ac7 | |||
| b9415dcb17 | |||
| 65ba1b16e3 | |||
| 8c4ec67282 | |||
| 36e7dbf8aa | |||
| c56bfe21e5 | |||
| d533a94718 | |||
| fe18393d4e | |||
| e41e7ff9e1 | |||
| 1100872152 | |||
| 16ab12a61c | |||
| 0f6be51c35 | |||
| 463111dfd6 | |||
| 4874544955 | |||
| 256476268f | |||
| a57d579b0e | |||
| 49bf0fa1d3 | |||
| 1b4764e328 | |||
| db3333e26d | |||
| 1092031a9f | |||
| f386a5f9c3 | |||
| 82318da484 | |||
| 14784266b3 | |||
| 362e77f3dd | |||
| dfafffe154 |
@@ -1,9 +1,60 @@
|
|||||||
|
## v1.18.0
|
||||||
|
- feat: Add SSO-style error page (404/500) for browser navigation instead of a bare text response
|
||||||
|
- feat: navbar — username no longer underlined; only the active link is bold + underlined
|
||||||
|
|
||||||
|
## v1.16.1
|
||||||
|
- fix: remove missing DEPLOYMENT.md from Docker build context
|
||||||
|
|
||||||
|
## v1.16.0
|
||||||
|
- Added OpenBao PKI SSH Certificate Support
|
||||||
|
- Fallback to LDAP Key injection
|
||||||
|
|
||||||
|
# v1.15.0
|
||||||
|
- feat: Rename SSO Manager to Jump in UI
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
All notable changes to this project are documented here. Format loosely
|
All notable changes to this project are documented here. Format loosely
|
||||||
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions
|
||||||
correspond to git tags (`vX.Y.Z`) and `nodejs/package.json`'s `version`.
|
correspond to git tags (`vX.Y.Z`) and `nodejs/package.json`'s `version`.
|
||||||
|
|
||||||
|
## [1.14.1] - 2026-08-01
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Bumped `@simpleworkjs/bao-conf` to 1.0.1** so standalone/no-OpenBao boots
|
||||||
|
don't crash. bao-conf 1.0.0's `init()` threw when `VAULT_TOKEN` was unset,
|
||||||
|
which — combined with `bin/www`'s `.catch(() => process.exit(1))` — made the
|
||||||
|
jump host exit at boot in any deployment without an OpenBao sidecar
|
||||||
|
(standalone Docker, bare metal). 1.0.1 makes `init()` fail-soft on a missing
|
||||||
|
token (warn + continue from `CONF_SECRETS`), matching the documented
|
||||||
|
contract. The theta-env stack is unaffected (it always sets a scoped
|
||||||
|
`VAULT_TOKEN`).
|
||||||
|
|
||||||
|
## [1.14.0] - 2026-08-01
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Secrets now load from OpenBao at boot** via
|
||||||
|
[@simpleworkjs/bao-conf](https://simpleworkjs.github.io/bao-conf/), which
|
||||||
|
deep-merges `secret/jump-host/conf` over the file-loaded config. The jump
|
||||||
|
host authenticates to OpenBao with a scoped `VAULT_TOKEN` (policy
|
||||||
|
`jump-host` — read-only on its own path), never the root token. Because the
|
||||||
|
OIDC `clientSecret` is captured at require time inside `createOidcClient`
|
||||||
|
(during `require('../models')`), `bin/www` now runs `bao-conf.init()`
|
||||||
|
**before** `require('../models')`. Fail-soft: if OpenBao is unreachable,
|
||||||
|
boot continues from `CONF_SECRETS`. The `config/jump-secrets.js` file is now
|
||||||
|
an operator-edit seed artifact (gitignored); OpenBao is authoritative. See
|
||||||
|
theta-env's [Secrets docs](https://theta42.github.io/theta-env/secrets/).
|
||||||
|
- Bumped package version to track the release tag.
|
||||||
|
|
||||||
|
## [1.11.0] - 2026-07-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **`app_super_admin` (cross-app) and `app_jump_admin` groups**: super admins are full admins here same as `app_sso_admin`; jump admins get audit page/data access without other admin rights. The Audit page/API is now actually admin-gated server-side (previously the page shell rendered for any logged-in user, only its data was gated).
|
||||||
|
- **Host list adds Last connection/Last failed connection columns** and highlights rows green (a session is live right now) or yellow (the most recent attempt failed), backed by new per-host last-success/last-fail timestamps in `models/metrics.js`. `services/ssh_server.js` now attributes grammar/TUI connect failures to the resolved host when one was found, not just aggregate counters.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Dashboard's stat boxes and Top hosts/Top users cards moved to the Audit page** (audit is now the admin-facing metrics home; dashboard stays focused on "hosts I can reach"). "All hosts" renamed to "My hosts".
|
||||||
|
|
||||||
## [1.10.2] - 2026-07-30
|
## [1.10.2] - 2026-07-30
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ COPY nodejs/utils ./utils
|
|||||||
COPY nodejs/views ./views
|
COPY nodejs/views ./views
|
||||||
COPY nodejs/public ./public
|
COPY nodejs/public ./public
|
||||||
|
|
||||||
COPY README.md CHANGELOG.md DEPLOYMENT.md /
|
COPY README.md CHANGELOG.md /
|
||||||
COPY --from=gitinfo /commit.txt ./.build_commit
|
COPY --from=gitinfo /commit.txt ./.build_commit
|
||||||
|
|
||||||
COPY docker-entrypoint.sh /usr/local/bin/
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
|||||||
@@ -159,6 +159,22 @@ Config layers via [@simpleworkjs/conf](https://www.npmjs.com/package/@simplework
|
|||||||
`conf/base.js` < `conf/<NODE_ENV>.js` < the `CONF_SECRETS` file < `app_*` env.
|
`conf/base.js` < `conf/<NODE_ENV>.js` < the `CONF_SECRETS` file < `app_*` env.
|
||||||
See `secrets.js.example` for every key.
|
See `secrets.js.example` for every key.
|
||||||
|
|
||||||
|
## Secrets
|
||||||
|
|
||||||
|
At boot, [@simpleworkjs/bao-conf](https://simpleworkjs.github.io/bao-conf/)
|
||||||
|
deep-merges `secret/jump-host/conf` from **OpenBao** over the file-loaded
|
||||||
|
config. The jump host's OIDC `clientSecret` is captured at require time
|
||||||
|
(inside `createOidcClient` during `require('../models')`), so `bin/www` runs
|
||||||
|
`bao-conf.init()` **before** `require('../models')`. Fail-soft: if OpenBao is
|
||||||
|
unreachable, boot continues from `CONF_SECRETS`. The jump host authenticates to
|
||||||
|
OpenBao with the scoped `VAULT_TOKEN` (env, policy `jump-host` — read only
|
||||||
|
`secret/jump-host/conf`), never the root token.
|
||||||
|
|
||||||
|
The `config/jump-secrets.js` file is an operator-edit seed artifact
|
||||||
|
(gitignored); the bootstrap writes the generated API token + OAuth client
|
||||||
|
into OpenBao, which is authoritative. For the full architecture see
|
||||||
|
theta-env's **[Secrets docs](https://theta42.github.io/theta-env/secrets/)**.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
+11
-1
@@ -4,6 +4,8 @@ const express = require('express');
|
|||||||
const compression = require('compression');
|
const compression = require('compression');
|
||||||
|
|
||||||
require('./models'); // wire model-redis + register models
|
require('./models'); // wire model-redis + register models
|
||||||
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
const buildInfo = require('./utils/build_info');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -41,7 +43,15 @@ app.use((err, req, res, next) => {
|
|||||||
if(req.path.startsWith('/api/')){
|
if(req.path.startsWith('/api/')){
|
||||||
return res.status(status).json({name: err.name || 'Error', message: err.message || 'Error'});
|
return res.status(status).json({name: err.name || 'Error', message: err.message || 'Error'});
|
||||||
}
|
}
|
||||||
res.status(status).send(err.message || 'Error');
|
// Browser navigation gets the HTML error page (shared with SSO).
|
||||||
|
res.status(status).render('error', {
|
||||||
|
title: conf.environment !== 'production' ? 'dev' : '',
|
||||||
|
titleIcon: conf.environment !== 'production' ? '<i class="fa-brands fa-dev"></i>' : '',
|
||||||
|
name: conf.name,
|
||||||
|
logo: conf.logo,
|
||||||
|
...buildInfo,
|
||||||
|
error: err,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|||||||
+34
-23
@@ -9,32 +9,43 @@ const http = require('http');
|
|||||||
const conf = require('@simpleworkjs/conf');
|
const conf = require('@simpleworkjs/conf');
|
||||||
const { Server } = require('socket.io');
|
const { Server } = require('socket.io');
|
||||||
|
|
||||||
require('../models');
|
// @simpleworkjs/conf loads ./config/jump-secrets.js synchronously, then
|
||||||
|
// @simpleworkjs/bao-conf deep-merges secret/jump-host/conf from OpenBao over
|
||||||
|
// it. The OIDC clientSecret is captured at require time inside models (via
|
||||||
|
// createOidcClient), so the fetch MUST resolve before require('../models').
|
||||||
|
// Fail-soft: if OpenBao is unreachable, init() leaves conf as the file-loaded
|
||||||
|
// fallback and boot continues from ./config/jump-secrets.js.
|
||||||
|
require('@simpleworkjs/bao-conf').init({ path: 'jump-host', conf }).then(() => {
|
||||||
|
require('../models');
|
||||||
|
|
||||||
const app = require('../app');
|
const app = require('../app');
|
||||||
const middleware = require('../middleware/auth');
|
const middleware = require('../middleware/auth');
|
||||||
const sshServer = require('../services/ssh_server');
|
const sshServer = require('../services/ssh_server');
|
||||||
|
|
||||||
const webPort = (conf.web && conf.web.port) || 3002;
|
const webPort = (conf.web && conf.web.port) || 3002;
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
|
|
||||||
// Socket.IO — the client framework (app-base.js) opens an authenticated socket.
|
// Socket.IO — the client framework (app-base.js) opens an authenticated socket.
|
||||||
// We don't push anything yet, but serving /socket.io keeps the shared front-end
|
// We don't push anything yet, but serving /socket.io keeps the shared front-end
|
||||||
// working exactly as it does in the sibling apps.
|
// working exactly as it does in the sibling apps.
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
io.use(middleware.authIO);
|
io.use(middleware.authIO);
|
||||||
app.io = io;
|
app.io = io;
|
||||||
|
|
||||||
server.listen(webPort, () => {
|
server.listen(webPort, () => {
|
||||||
console.log(`[web] jump-host UI/API on :${server.address().port}`);
|
console.log(`[web] jump-host UI/API on :${server.address().port}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
sshServer.start();
|
sshServer.start();
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
console.log('[jump-host] shutting down');
|
console.log('[jump-host] shutting down');
|
||||||
server.close();
|
server.close();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
process.on('SIGTERM', shutdown);
|
process.on('SIGTERM', shutdown);
|
||||||
process.on('SIGINT', shutdown);
|
process.on('SIGINT', shutdown);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('boot failed:', err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
+7
-2
@@ -6,7 +6,7 @@
|
|||||||
// values (LDAP creds, SSO API token) belong in the secrets file.
|
// values (LDAP creds, SSO API token) belong in the secrets file.
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'Jump Host',
|
name: 'Jump',
|
||||||
logo: '/static/img/theta42.svg',
|
logo: '/static/img/theta42.svg',
|
||||||
|
|
||||||
// LDAP directory the users live in (same directory the SSO manages).
|
// LDAP directory the users live in (same directory the SSO manages).
|
||||||
@@ -80,7 +80,12 @@ module.exports = {
|
|||||||
|
|
||||||
auth: {
|
auth: {
|
||||||
// OIDC group memberships that grant web UI/API admin access.
|
// OIDC group memberships that grant web UI/API admin access.
|
||||||
adminGroups: ['app_sso_admin'],
|
// app_super_admin is the cross-app super admin group (sso, proxy, jump-host).
|
||||||
|
adminGroups: ['app_sso_admin', 'app_super_admin'],
|
||||||
|
// OIDC group memberships that grant jump admin access (the audit page
|
||||||
|
// and its data), without granting other admin-only rights. Full admins
|
||||||
|
// (adminGroups/adminUsers) always have jump admin access too.
|
||||||
|
jumpAdminGroups: ['app_jump_admin'],
|
||||||
// Local anti-lockout admin: the first name here is bootstrapped as a
|
// Local anti-lockout admin: the first name here is bootstrapped as a
|
||||||
// redis-backed user on first boot (password from localAdminPass, or a
|
// redis-backed user on first boot (password from localAdminPass, or a
|
||||||
// random one printed to the log once). Lets you in even with OIDC down.
|
// random one printed to the log once). Lets you in even with OIDC down.
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ async function requireAdmin(req, res, next){
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jump admin = access to the audit page/data. A narrower grant than full
|
||||||
|
// jump-host admin: full admins (isAdmin) always qualify, plus anyone in
|
||||||
|
// conf.auth.jumpAdminGroups (e.g. a dedicated app_jump_admin LDAP group) can
|
||||||
|
// be granted audit access without also getting other admin-only rights.
|
||||||
|
function isJumpAdmin(req){
|
||||||
|
if(isAdmin(req)) return true;
|
||||||
|
const jumpAdminGroups = (conf.auth && conf.auth.jumpAdminGroups) || [];
|
||||||
|
return (req.groups || []).some(g => jumpAdminGroups.includes(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requireJumpAdmin(req, res, next){
|
||||||
|
if(isJumpAdmin(req)) return next();
|
||||||
|
const error = new Error('Forbidden');
|
||||||
|
error.name = 'Forbidden';
|
||||||
|
error.status = 403;
|
||||||
|
error.message = 'Jump admin access required.';
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
|
||||||
// Socket.IO handshake auth (app-base.js connects with the session token).
|
// Socket.IO handshake auth (app-base.js connects with the session token).
|
||||||
async function authIO(socket, next){
|
async function authIO(socket, next){
|
||||||
try{
|
try{
|
||||||
@@ -69,4 +88,4 @@ async function authIO(socket, next){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { auth, requireAdmin, authIO, isAdmin };
|
module.exports = { auth, requireAdmin, authIO, isAdmin, isJumpAdmin, requireJumpAdmin };
|
||||||
|
|||||||
@@ -13,10 +13,34 @@ async function bump({ uid, hostSlug, success }) {
|
|||||||
const ops = [redis.incr(`${P()}total`), redis.incr(`${P()}day_${day}`)];
|
const ops = [redis.incr(`${P()}total`), redis.incr(`${P()}day_${day}`)];
|
||||||
if (!success) ops.push(redis.incr(`${P()}fail`));
|
if (!success) ops.push(redis.incr(`${P()}fail`));
|
||||||
if (uid) ops.push(redis.incr(`${P()}user_${uid}`));
|
if (uid) ops.push(redis.incr(`${P()}user_${uid}`));
|
||||||
if (hostSlug) ops.push(redis.incr(`${P()}host_${hostSlug}`));
|
if (hostSlug) {
|
||||||
|
ops.push(redis.incr(`${P()}host_${hostSlug}`));
|
||||||
|
// Last-attempt timestamp per host, split by outcome -- drives the
|
||||||
|
// dashboard's "Last connection"/"Last failed connection" columns and
|
||||||
|
// row highlighting (see lastForHosts below).
|
||||||
|
ops.push(redis.set(`${P()}host_last_${success ? 'success' : 'fail'}_${hostSlug}`, Date.now()));
|
||||||
|
}
|
||||||
await Promise.all(ops);
|
await Promise.all(ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Per-host last-success/last-fail timestamps for a given list of slugs (e.g.
|
||||||
|
// the hosts a session can reach), for the dashboard's host list.
|
||||||
|
async function lastForHosts(slugs) {
|
||||||
|
const redis = await getRedis();
|
||||||
|
const result = {};
|
||||||
|
await Promise.all((slugs || []).map(async (slug) => {
|
||||||
|
const [lastSuccess, lastFail] = await Promise.all([
|
||||||
|
redis.get(`${P()}host_last_success_${slug}`),
|
||||||
|
redis.get(`${P()}host_last_fail_${slug}`),
|
||||||
|
]);
|
||||||
|
result[slug] = {
|
||||||
|
lastConnected: lastSuccess ? Number(lastSuccess) : null,
|
||||||
|
lastFailed: lastFail ? Number(lastFail) : null,
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async function summary() {
|
async function summary() {
|
||||||
const redis = await getRedis();
|
const redis = await getRedis();
|
||||||
const [total, fail] = await Promise.all([
|
const [total, fail] = await Promise.all([
|
||||||
@@ -37,4 +61,4 @@ async function summary() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { bump, summary };
|
module.exports = { bump, summary, lastForHosts };
|
||||||
|
|||||||
Generated
+15
-2
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "t42-jump-host",
|
"name": "t42-jump-host",
|
||||||
"version": "1.9.0",
|
"version": "1.18.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "t42-jump-host",
|
"name": "t42-jump-host",
|
||||||
"version": "1.9.0",
|
"version": "1.18.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^7.3.0",
|
"@fortawesome/fontawesome-free": "^7.3.0",
|
||||||
"@simpleworkjs/app-stack": "^1.0.0",
|
"@simpleworkjs/app-stack": "^1.0.0",
|
||||||
|
"@simpleworkjs/bao-conf": "^1.0.0",
|
||||||
"@simpleworkjs/conf": "^1.2.0",
|
"@simpleworkjs/conf": "^1.2.0",
|
||||||
"@simpleworkjs/directory-schema": "^1.0.0",
|
"@simpleworkjs/directory-schema": "^1.0.0",
|
||||||
"@simpleworkjs/frontend": "^0.2.6",
|
"@simpleworkjs/frontend": "^0.2.6",
|
||||||
@@ -156,6 +157,18 @@
|
|||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@simpleworkjs/bao-conf": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@simpleworkjs/bao-conf/-/bao-conf-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-mcay5NQ/w9ShpIAolMP/3f9TfXSLE+d5jrA4dTPOUHDjTkdsP7pe4hMmQUmwnniR59U1bGoRIVdXjvDbX3I5nw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"extend": "^3.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@simpleworkjs/conf": {
|
"node_modules/@simpleworkjs/conf": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@simpleworkjs/conf/-/conf-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@simpleworkjs/conf/-/conf-1.2.0.tgz",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "t42-jump-host",
|
"name": "t42-jump-host",
|
||||||
"version": "1.10.2",
|
"version": "1.18.0",
|
||||||
"description": "SSH jump host for the theta42 stack — LDAP-authenticated, directory-driven host bridging with audit and metrics",
|
"description": "SSH jump host for the theta42 stack — LDAP-authenticated, directory-driven host bridging with audit and metrics",
|
||||||
"author": [
|
"author": [
|
||||||
{
|
{
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^7.3.0",
|
"@fortawesome/fontawesome-free": "^7.3.0",
|
||||||
"@simpleworkjs/app-stack": "^1.0.0",
|
"@simpleworkjs/app-stack": "^1.0.0",
|
||||||
|
"@simpleworkjs/bao-conf": "^1.0.0",
|
||||||
"@simpleworkjs/conf": "^1.2.0",
|
"@simpleworkjs/conf": "^1.2.0",
|
||||||
"@simpleworkjs/directory-schema": "^1.0.0",
|
"@simpleworkjs/directory-schema": "^1.0.0",
|
||||||
"@simpleworkjs/frontend": "^0.2.6",
|
"@simpleworkjs/frontend": "^0.2.6",
|
||||||
|
|||||||
@@ -3,6 +3,12 @@ nav.navbar{
|
|||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Only the active top-nav link is bold + underlined; the username is plain. */
|
||||||
|
.top-nav a.active{
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ router.use('/user', middleware.auth, require('./user'));
|
|||||||
// admin gate (see routes/api_token.js for why a token can't reach admin routes).
|
// admin gate (see routes/api_token.js for why a token can't reach admin routes).
|
||||||
router.use('/api-token', middleware.auth, require('./api_token'));
|
router.use('/api-token', middleware.auth, require('./api_token'));
|
||||||
|
|
||||||
// Jump-host data — admin only (audit log, active sessions, metrics).
|
// Jump-host data — jump admin only (audit log, active sessions, metrics).
|
||||||
router.use('/', middleware.auth, middleware.requireAdmin, require('./jump'));
|
router.use('/', middleware.auth, middleware.requireJumpAdmin, require('./jump'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
+18
-2
@@ -4,14 +4,17 @@
|
|||||||
// browser who it is and whether it's an admin (drives login state + nav).
|
// browser who it is and whether it's an admin (drives login state + nav).
|
||||||
|
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
const { isAdmin } = require('../middleware/auth');
|
const { isAdmin, isJumpAdmin } = require('../middleware/auth');
|
||||||
const access = require('../utils/access');
|
const access = require('../utils/access');
|
||||||
|
const metrics = require('../models/metrics');
|
||||||
|
const registry = require('../services/session_registry');
|
||||||
|
|
||||||
router.get('/me', (req, res) => {
|
router.get('/me', (req, res) => {
|
||||||
res.json({
|
res.json({
|
||||||
username: req.user && req.user.username,
|
username: req.user && req.user.username,
|
||||||
groups: req.groups || [],
|
groups: req.groups || [],
|
||||||
isAdmin: isAdmin(req),
|
isAdmin: isAdmin(req),
|
||||||
|
isJumpAdmin: isJumpAdmin(req),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,7 +26,20 @@ router.get('/hosts', async (req, res, next) => {
|
|||||||
const hosts = isAdmin(req)
|
const hosts = isAdmin(req)
|
||||||
? await access.allHosts()
|
? await access.allHosts()
|
||||||
: await access.accessibleHosts({ uid: req.user && req.user.username, groups: req.groups || [] });
|
: await access.accessibleHosts({ uid: req.user && req.user.username, groups: req.groups || [] });
|
||||||
res.json({ results: hosts });
|
|
||||||
|
// Enrich with connection state for the dashboard's host list: whether a
|
||||||
|
// session is live right now (active bridges, session_registry), plus the
|
||||||
|
// last successful/failed connection times (models/metrics).
|
||||||
|
const connectedSlugs = new Set(registry.list().map((s) => s.slug));
|
||||||
|
const last = await metrics.lastForHosts(hosts.map((h) => h.slug));
|
||||||
|
const enriched = hosts.map((h) => ({
|
||||||
|
...h,
|
||||||
|
connected: connectedSlugs.has(h.slug),
|
||||||
|
lastConnected: (last[h.slug] && last[h.slug].lastConnected) || null,
|
||||||
|
lastFailed: (last[h.slug] && last[h.slug].lastFailed) || null,
|
||||||
|
}));
|
||||||
|
|
||||||
|
res.json({ results: enriched });
|
||||||
} catch (err) { next(err); }
|
} catch (err) { next(err); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function counter(onBytes) {
|
|||||||
// Connect the upstream ssh2.Client, retrying once after a short pause if the
|
// Connect the upstream ssh2.Client, retrying once after a short pause if the
|
||||||
// first attempt fails auth (SSSD/AuthorizedKeysCommand cache lag right after a
|
// first attempt fails auth (SSSD/AuthorizedKeysCommand cache lag right after a
|
||||||
// first-time key injection).
|
// first-time key injection).
|
||||||
function connectUpstream({ host, port, username, privateKey, onHostKey, uid, justInjected }) {
|
function connectUpstream({ host, port, username, privateKey, cert, onHostKey, uid, justInjected, expectedHostKeyFp }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let attempted = false;
|
let attempted = false;
|
||||||
const dial = (allowRetry) => {
|
const dial = (allowRetry) => {
|
||||||
@@ -42,12 +42,16 @@ function connectUpstream({ host, port, username, privateKey, onHostKey, uid, jus
|
|||||||
})
|
})
|
||||||
.connect({
|
.connect({
|
||||||
host, port, username, privateKey,
|
host, port, username, privateKey,
|
||||||
|
certificates: cert ? [cert] : undefined,
|
||||||
readyTimeout: (conf.ssh && conf.ssh.connectTimeoutMs) || 10000,
|
readyTimeout: (conf.ssh && conf.ssh.connectTimeoutMs) || 10000,
|
||||||
keepaliveInterval: 15000,
|
keepaliveInterval: 15000,
|
||||||
hostVerifier: (key) => {
|
hostVerifier: (key) => {
|
||||||
const fp = 'SHA256:' + crypto.createHash('sha256').update(key).digest('base64').replace(/=+$/, '');
|
const fp = 'SHA256:' + crypto.createHash('sha256').update(key).digest('base64').replace(/=+$/, '');
|
||||||
if (onHostKey) onHostKey(fp);
|
if (onHostKey) onHostKey(fp);
|
||||||
return true; // v1: trust-on-use, fingerprint audited. Pinning = follow-up.
|
if (expectedHostKeyFp && expectedHostKeyFp !== fp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true; // v1: trust-on-use if not pinned, fingerprint audited.
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -129,17 +129,30 @@ async function resolveAndConnect(state, record, { onHostKey } = {}) {
|
|||||||
await record.patch({ targetSlug: host ? host.slug : 'raw-ip', targetAddr: endpoint.address, targetPort: endpoint.port });
|
await record.patch({ targetSlug: host ? host.slug : 'raw-ip', targetAddr: endpoint.address, targetPort: endpoint.port });
|
||||||
|
|
||||||
let justInjected = false;
|
let justInjected = false;
|
||||||
try { justInjected = await ensureKeyInjected(state.user, JUMP_KEYS.publicLine); }
|
let cert;
|
||||||
catch (err) { throw fail('key-inject-failed', err.message); }
|
const usePki = conf.ssh && conf.ssh.pki && conf.ssh.pki.enabled;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (usePki) {
|
||||||
|
const { getSignedCert } = require('../utils/vault_cert');
|
||||||
|
cert = await getSignedCert(JUMP_KEYS.publicLine, state.uid);
|
||||||
|
} else {
|
||||||
|
justInjected = await ensureKeyInjected(state.user, JUMP_KEYS.publicLine);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
const failType = usePki ? 'pki-cert-failed' : 'key-inject-failed';
|
||||||
|
throw fail(failType, err.message, host ? host.slug : undefined);
|
||||||
|
}
|
||||||
|
|
||||||
let upstream;
|
let upstream;
|
||||||
try {
|
try {
|
||||||
upstream = await connectUpstream({
|
upstream = await connectUpstream({
|
||||||
host: endpoint.address, port: endpoint.port,
|
host: endpoint.address, port: endpoint.port,
|
||||||
username: state.uid, privateKey: JUMP_KEYS.clientKey,
|
username: state.uid, privateKey: JUMP_KEYS.clientKey, cert,
|
||||||
uid: state.uid, justInjected, onHostKey,
|
uid: state.uid, justInjected, onHostKey,
|
||||||
|
expectedHostKeyFp: host && host.metadata && host.metadata.sshHostKeyFp,
|
||||||
});
|
});
|
||||||
} catch (err) { throw fail('upstream-unreachable', err.message); }
|
} catch (err) { throw fail('upstream-unreachable', err.message, host ? host.slug : undefined); }
|
||||||
|
|
||||||
return { upstream, host, endpoint };
|
return { upstream, host, endpoint };
|
||||||
}
|
}
|
||||||
@@ -147,8 +160,10 @@ async function resolveAndConnect(state, record, { onHostKey } = {}) {
|
|||||||
// detail carries the real underlying error message (e.g. ECONNREFUSED,
|
// detail carries the real underlying error message (e.g. ECONNREFUSED,
|
||||||
// ETIMEDOUT, an ssh2 auth-failure string) so audit records aren't reduced to
|
// ETIMEDOUT, an ssh2 auth-failure string) so audit records aren't reduced to
|
||||||
// just the generic reason code -- without it, a network-layer failure and an
|
// just the generic reason code -- without it, a network-layer failure and an
|
||||||
// SSH auth failure both looked identical in the audit log.
|
// SSH auth failure both looked identical in the audit log. hostSlug (when the
|
||||||
function fail(reason, detail) { const e = new Error(reason); e.reason = reason; e.detail = detail; return e; }
|
// target was already resolved to a known host) lets callers attribute the
|
||||||
|
// failure to that host for per-host "last failed connection" tracking.
|
||||||
|
function fail(reason, detail, hostSlug) { const e = new Error(reason); e.reason = reason; e.detail = detail; e.hostSlug = hostSlug; return e; }
|
||||||
|
|
||||||
async function runGrammar(session, client, state) {
|
async function runGrammar(session, client, state) {
|
||||||
// Register session listeners IMMEDIATELY — before any async work.
|
// Register session listeners IMMEDIATELY — before any async work.
|
||||||
@@ -179,7 +194,7 @@ async function runGrammar(session, client, state) {
|
|||||||
const reason = err.reason || 'error';
|
const reason = err.reason || 'error';
|
||||||
rejectUp(new Error(reasonMessage(reason)));
|
rejectUp(new Error(reasonMessage(reason)));
|
||||||
await record.finish({ success: false, failReason: reason, failDetail: err.detail });
|
await record.finish({ success: false, failReason: reason, failDetail: err.detail });
|
||||||
await metrics.bump({ uid: state.uid, success: false });
|
await metrics.bump({ uid: state.uid, hostSlug: err.hostSlug, success: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,9 +218,9 @@ async function runTuiSession(session, client, state) {
|
|||||||
|
|
||||||
const record = await audit.create({ uid: state.uid, authMethod: state.authMethod, clientIp: state.clientIp, mode: 'tui' });
|
const record = await audit.create({ uid: state.uid, authMethod: state.authMethod, clientIp: state.clientIp, mode: 'tui' });
|
||||||
|
|
||||||
const finishFail = async (reason, detail) => {
|
const finishFail = async (reason, detail, hostSlug) => {
|
||||||
await record.finish({ success: false, failReason: reason, failDetail: detail });
|
await record.finish({ success: false, failReason: reason, failDetail: detail });
|
||||||
await metrics.bump({ uid: state.uid, success: false });
|
await metrics.bump({ uid: state.uid, hostSlug, success: false });
|
||||||
try { client.end(); } catch (_) {}
|
try { client.end(); } catch (_) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,19 +241,32 @@ async function runTuiSession(session, client, state) {
|
|||||||
await record.patch({ targetSlug: tui.host.slug, targetAddr: endpoint.address, targetPort: endpoint.port });
|
await record.patch({ targetSlug: tui.host.slug, targetAddr: endpoint.address, targetPort: endpoint.port });
|
||||||
|
|
||||||
let justInjected = false;
|
let justInjected = false;
|
||||||
try { justInjected = await ensureKeyInjected(state.user, JUMP_KEYS.publicLine); }
|
let cert;
|
||||||
catch (err) { return finishFail('key-inject-failed', err.message); }
|
const usePki = conf.ssh && conf.ssh.pki && conf.ssh.pki.enabled;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (usePki) {
|
||||||
|
const { getSignedCert } = require('../utils/vault_cert');
|
||||||
|
cert = await getSignedCert(JUMP_KEYS.publicLine, state.uid);
|
||||||
|
} else {
|
||||||
|
justInjected = await ensureKeyInjected(state.user, JUMP_KEYS.publicLine);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
const failType = usePki ? 'pki-cert-failed' : 'key-inject-failed';
|
||||||
|
return finishFail(failType, err.message, tui.host.slug);
|
||||||
|
}
|
||||||
|
|
||||||
let upstream;
|
let upstream;
|
||||||
try {
|
try {
|
||||||
upstream = await connectUpstream({
|
upstream = await connectUpstream({
|
||||||
host: endpoint.address, port: endpoint.port,
|
host: endpoint.address, port: endpoint.port,
|
||||||
username: state.uid, privateKey: JUMP_KEYS.clientKey,
|
username: state.uid, privateKey: JUMP_KEYS.clientKey, cert,
|
||||||
uid: state.uid, justInjected, onHostKey: (fp) => record.patch({ hostKeyFp: fp }),
|
uid: state.uid, justInjected, onHostKey: (fp) => record.patch({ hostKeyFp: fp }),
|
||||||
|
expectedHostKeyFp: tui.host && tui.host.metadata && tui.host.metadata.sshHostKeyFp,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
try { tui.channel.write(`\r\n Could not reach ${endpoint.address}.\r\n`); tui.channel.close(); } catch (_) {}
|
try { tui.channel.write(`\r\n Could not reach ${endpoint.address}.\r\n`); tui.channel.close(); } catch (_) {}
|
||||||
return finishFail('upstream-unreachable', err.message);
|
return finishFail('upstream-unreachable', err.message, tui.host.slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.add(record.id, { uid: state.uid, target: endpoint.address, slug: tui.host.slug });
|
registry.add(record.id, { uid: state.uid, target: endpoint.address, slug: tui.host.slug });
|
||||||
|
|||||||
@@ -9,10 +9,29 @@ const ESC = '\x1b';
|
|||||||
const CLEAR = `${ESC}[2J${ESC}[H`;
|
const CLEAR = `${ESC}[2J${ESC}[H`;
|
||||||
const HIDE_CUR = `${ESC}[?25l`;
|
const HIDE_CUR = `${ESC}[?25l`;
|
||||||
const SHOW_CUR = `${ESC}[?25h`;
|
const SHOW_CUR = `${ESC}[?25h`;
|
||||||
const INV = `${ESC}[7m`;
|
|
||||||
|
// Basic styles
|
||||||
const RST = `${ESC}[0m`;
|
const RST = `${ESC}[0m`;
|
||||||
const DIM = `${ESC}[2m`;
|
|
||||||
const BOLD = `${ESC}[1m`;
|
const BOLD = `${ESC}[1m`;
|
||||||
|
const DIM = `${ESC}[2m`;
|
||||||
|
|
||||||
|
// Colors (30-37: standard, 90-97: bright)
|
||||||
|
const RED = `${ESC}[31m`;
|
||||||
|
const BRIGHT_RED = `${ESC}[91m`;
|
||||||
|
const CYAN = `${ESC}[36m`;
|
||||||
|
const BRIGHT_CYAN = `${ESC}[96m`;
|
||||||
|
const GREEN = `${ESC}[32m`;
|
||||||
|
const BRIGHT_GREEN = `${ESC}[92m`;
|
||||||
|
const YELLOW = `${ESC}[33m`;
|
||||||
|
const BRIGHT_YELLOW = `${ESC}[93m`;
|
||||||
|
const MAGENTA = `${ESC}[35m`;
|
||||||
|
const BRIGHT_MAGENTA = `${ESC}[95m`;
|
||||||
|
const BLUE = `${ESC}[34m`;
|
||||||
|
const BRIGHT_BLUE = `${ESC}[94m`;
|
||||||
|
|
||||||
|
// Inverted selection with color
|
||||||
|
const INV_GREEN = `${ESC}[42m${ESC}[30m`; // Green bg, black text
|
||||||
|
const INV = `${ESC}[7m`;
|
||||||
|
|
||||||
function pickHost(channel, uid, hosts) {
|
function pickHost(channel, uid, hosts) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@@ -35,18 +54,43 @@ function pickHost(channel, uid, hosts) {
|
|||||||
const list = visible();
|
const list = visible();
|
||||||
if (selected >= list.length) selected = Math.max(0, list.length - 1);
|
if (selected >= list.length) selected = Math.max(0, list.length - 1);
|
||||||
let out = CLEAR + HIDE_CUR;
|
let out = CLEAR + HIDE_CUR;
|
||||||
out += `${BOLD} Theta42 Jump — hosts for ${uid}${RST}\r\n`;
|
|
||||||
out += `${DIM} ↑/↓ move · Enter connect · type to filter · q quit${RST}\r\n\r\n`;
|
// Header with gradient-style color
|
||||||
|
out += `\r\n ${BOLD}${BRIGHT_CYAN}╔════════════════════════════════════════════════════════╗${RST}\r\n`;
|
||||||
|
out += ` ${BOLD}${BRIGHT_CYAN}║${RST} ${BOLD}${BRIGHT_MAGENTA}Theta42 Jump${RST} ${DIM}·${RST} ${BRIGHT_GREEN}hosts for ${uid}${RST} ${BOLD}${BRIGHT_CYAN}║${RST}\r\n`;
|
||||||
|
out += ` ${BOLD}${BRIGHT_CYAN}╚════════════════════════════════════════════════════════╝${RST}\r\n`;
|
||||||
|
out += `\r\n`;
|
||||||
|
out += ` ${DIM}↑/↓ move · Enter connect · type to filter · q quit${RST}\r\n`;
|
||||||
|
out += `\r\n`;
|
||||||
|
|
||||||
if (!list.length) {
|
if (!list.length) {
|
||||||
out += ` ${DIM}(no match for "${filter}")${RST}\r\n`;
|
out += ` ${YELLOW}⚠${RST} ${DIM}(no match for "${filter}")${RST}\r\n`;
|
||||||
} else {
|
} else {
|
||||||
list.forEach((h, i) => {
|
list.forEach((h, i) => {
|
||||||
const ip = (h.metadata && h.metadata.ip) || (h.metadata && h.metadata.address) || '';
|
const ip = (h.metadata && h.metadata.ip) || (h.metadata && h.metadata.address) || '';
|
||||||
const row = ` ${h.name} ${DIM}(${h.slug})${RST}${ip ? ` ${ip}` : ''}`;
|
const isProd = h.metadata && h.metadata.isProduction;
|
||||||
out += (i === selected ? `${INV}> ${h.name} (${h.slug})${ip ? ` ${ip}` : ''}${RST}` : row) + '\r\n';
|
const envBadge = isProd ? `${BOLD}${RED}PROD${RST} ` : `${DIM}DEV${RST} `;
|
||||||
|
|
||||||
|
if (i === selected) {
|
||||||
|
// Selected row with green inverse background
|
||||||
|
const selRow = `${INV_GREEN} ${h.name} ${DIM}(${h.slug})${RST}${ip ? ` ${CYAN}${ip}${RST}` : ''} ${envBadge} ${BOLD}${BRIGHT_GREEN}◄ SELECTED ►${RST}${INV_GREEN}${RST}`;
|
||||||
|
out += selRow + '\r\n';
|
||||||
|
} else {
|
||||||
|
// Normal row with subtle coloring
|
||||||
|
const nameColor = i % 2 === 0 ? BRIGHT_CYAN : CYAN;
|
||||||
|
out += ` ${nameColor}${h.name}${RST} ${DIM}(${h.slug})${RST}${ip ? ` ${BLUE}${ip}${RST}` : ''} ${envBadge}\r\n`;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (filter) out += `\r\n ${DIM}filter:${RST} ${filter}`;
|
|
||||||
|
if (filter) {
|
||||||
|
out += `\r\n ${DIM}filter: ${BRIGHT_YELLOW}${filter}${RST}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Footer
|
||||||
|
out += `\r\n\r\n ${DIM}────────────────────────────────────────────────────────${RST}\r\n`;
|
||||||
|
out += ` ${DIM}Press${RST} ${BOLD}1-9${RST} ${DIM}to quick-select · ${BOLD}q${RST} ${DIM}to quit${RST}\r\n`;
|
||||||
|
|
||||||
channel.write(out);
|
channel.write(out);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,39 +8,33 @@ function stubLdap(groups) {
|
|||||||
return { getGroups: async () => groups };
|
return { getGroups: async () => groups };
|
||||||
}
|
}
|
||||||
|
|
||||||
function stubFetch(byGroup) {
|
function stubFetch(byUid) {
|
||||||
return async (url) => {
|
return async (url) => {
|
||||||
const cn = decodeURIComponent(url.split('group=')[1]);
|
const uid = url.split('/access/')[1];
|
||||||
return { ok: true, json: async () => ({ results: byGroup[cn] || [] }) };
|
return { ok: true, json: async () => ({ results: byUid[uid] || [] }) };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
test('unions hosts across groups, dedupes, drops non-hosts', async () => {
|
test('drops non-hosts from access projection', async () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
const user = { uid: 'alice', dn: 'uid=alice,ou=people,dc=x' };
|
const user = { uid: 'alice', dn: 'uid=alice,ou=people,dc=x' };
|
||||||
const fetchImpl = stubFetch({
|
const fetchImpl = stubFetch({
|
||||||
host_web01_access: [
|
alice: [
|
||||||
{ id: '1', kind: 'host', slug: 'host_web01' },
|
{ id: '1', kind: 'host', slug: 'host_web01' },
|
||||||
|
{ id: '2', kind: 'host', slug: 'host_db' },
|
||||||
{ id: '9', kind: 'service', slug: 'app_gitea' }, // dropped: not a host
|
{ id: '9', kind: 'service', slug: 'app_gitea' }, // dropped: not a host
|
||||||
],
|
],
|
||||||
host_db_access: [
|
|
||||||
{ id: '1', kind: 'host', slug: 'host_web01' }, // dupe by id
|
|
||||||
{ id: '2', kind: 'host', slug: 'host_db' },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
const hosts = await accessibleHosts(user, { fetchImpl, ldap: stubLdap(['host_web01_access', 'host_db_access']) });
|
const hosts = await accessibleHosts(user, { fetchImpl });
|
||||||
assert.deepStrictEqual(hosts.map((h) => h.id).sort(), ['1', '2']);
|
assert.deepStrictEqual(hosts.map((h) => h.id).sort(), ['1', '2']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a failing group query does not sink the rest', async () => {
|
test('a failing access query returns empty list without throwing', async () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
const user = { uid: 'bob', dn: 'uid=bob,ou=people,dc=x' };
|
const user = { uid: 'bob', dn: 'uid=bob,ou=people,dc=x' };
|
||||||
const fetchImpl = async (url) => {
|
const fetchImpl = async () => ({ ok: false, status: 500 });
|
||||||
if (url.includes('bad')) return { ok: false, status: 500 };
|
const hosts = await accessibleHosts(user, { fetchImpl });
|
||||||
return { ok: true, json: async () => ({ results: [{ id: '3', kind: 'host', slug: 'host_ok' }] }) };
|
assert.deepStrictEqual(hosts, []);
|
||||||
};
|
|
||||||
const hosts = await accessibleHosts(user, { fetchImpl, ldap: stubLdap(['bad_access', 'good_access']) });
|
|
||||||
assert.deepStrictEqual(hosts.map((h) => h.id), ['3']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('caches per uid', async () => {
|
test('caches per uid', async () => {
|
||||||
@@ -48,23 +42,19 @@ test('caches per uid', async () => {
|
|||||||
let calls = 0;
|
let calls = 0;
|
||||||
const user = { uid: 'cara', dn: 'd' };
|
const user = { uid: 'cara', dn: 'd' };
|
||||||
const fetchImpl = async () => { calls++; return { ok: true, json: async () => ({ results: [] }) }; };
|
const fetchImpl = async () => { calls++; return { ok: true, json: async () => ({ results: [] }) }; };
|
||||||
const ldap = { getGroups: async () => ['g1'] };
|
await accessibleHosts(user, { fetchImpl });
|
||||||
await accessibleHosts(user, { fetchImpl, ldap });
|
await accessibleHosts(user, { fetchImpl });
|
||||||
await accessibleHosts(user, { fetchImpl, ldap });
|
|
||||||
assert.strictEqual(calls, 1);
|
assert.strictEqual(calls, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('accepts pre-resolved groups (web UI/OIDC session) without calling ldap.getGroups', async () => {
|
test('does not depend on user.groups or ldap.getGroups', async () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
let ldapCalled = false;
|
const user = { uid: 'erin' }; // no dn, no groups
|
||||||
const user = { uid: 'erin', groups: ['host_web01_access'] };
|
|
||||||
const fetchImpl = stubFetch({
|
const fetchImpl = stubFetch({
|
||||||
host_web01_access: [{ id: '5', kind: 'host', slug: 'host_web01' }],
|
erin: [{ id: '5', kind: 'host', slug: 'host_web01' }],
|
||||||
});
|
});
|
||||||
const ldap = { getGroups: async () => { ldapCalled = true; return []; } };
|
const hosts = await accessibleHosts(user, { fetchImpl });
|
||||||
const hosts = await accessibleHosts(user, { fetchImpl, ldap });
|
|
||||||
assert.deepStrictEqual(hosts.map((h) => h.id), ['5']);
|
assert.deepStrictEqual(hosts.map((h) => h.id), ['5']);
|
||||||
assert.strictEqual(ldapCalled, false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('allHosts fetches the whole host inventory with no group filter', async () => {
|
test('allHosts fetches the whole host inventory with no group filter', async () => {
|
||||||
@@ -80,16 +70,14 @@ test('allHosts fetches the whole host inventory with no group filter', async ()
|
|||||||
assert.deepStrictEqual(hosts.map((h) => h.id).sort(), ['1', '2']);
|
assert.deepStrictEqual(hosts.map((h) => h.id).sort(), ['1', '2']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a bare-array response (envelope drift) is treated as a failed group, not silently []', async () => {
|
test('a bare-array response (envelope drift) returns empty list', async () => {
|
||||||
clearCache();
|
clearCache();
|
||||||
const user = { uid: 'dave', dn: 'd' };
|
const user = { uid: 'dave', dn: 'd' };
|
||||||
// drift shape: a bare array instead of { results: [...] }. The shared client
|
// drift shape: a bare array instead of { results: [...] }. The shared client
|
||||||
// throws DirectoryEnvelopeViolation; access.js must catch + continue, so a
|
// throws DirectoryEnvelopeViolation; access.js must catch + continue.
|
||||||
// good group alongside still yields its hosts.
|
const fetchImpl = async () => {
|
||||||
const fetchImpl = async (url) => {
|
return { ok: true, json: async () => [{ id: '7', kind: 'host' }] };
|
||||||
if (url.includes('drift')) return { ok: true, json: async () => [{ id: '7', kind: 'host' }] };
|
|
||||||
return { ok: true, json: async () => ({ results: [{ id: '8', kind: 'host' }] }) };
|
|
||||||
};
|
};
|
||||||
const hosts = await accessibleHosts(user, { fetchImpl, ldap: stubLdap(['drift_access', 'good_access']) });
|
const hosts = await accessibleHosts(user, { fetchImpl });
|
||||||
assert.deepStrictEqual(hosts.map((h) => h.id), ['8']);
|
assert.deepStrictEqual(hosts, []);
|
||||||
});
|
});
|
||||||
|
|||||||
+23
-32
@@ -17,14 +17,9 @@ if (conf.standalone && conf.standalone.enabled) {
|
|||||||
|
|
||||||
// Which directory hosts may a user reach, and how do we dial them?
|
// Which directory hosts may a user reach, and how do we dial them?
|
||||||
//
|
//
|
||||||
// v1 resolution (see directory_spec.md §9.2 in sso-manager-node): the SSO's
|
// We use the SSO's machine-aware /api/discovery/access/:uid endpoint,
|
||||||
// /api/discovery/me only answers for the API token's own user, and /graph
|
// which evaluates the user's groups server-side and returns their complete
|
||||||
// omits ResourceGroup links — so we combine the user's LDAP groups (queried
|
// access projection in one call.
|
||||||
// directly) with per-group resource lookups:
|
|
||||||
//
|
|
||||||
// 1. LDAP: groups the user's DN is a member of
|
|
||||||
// 2. SSO: GET /api/discovery/resources?group=<cn> per group (ApiToken)
|
|
||||||
// 3. union, keep kind === 'host'
|
|
||||||
//
|
//
|
||||||
// Results are cached per-uid for a short TTL — the TUI picker and the
|
// Results are cached per-uid for a short TTL — the TUI picker and the
|
||||||
// username-grammar path share the cache. Dependency-injected fetch/ldap for
|
// username-grammar path share the cache. Dependency-injected fetch/ldap for
|
||||||
@@ -51,37 +46,33 @@ if (conf.standalone && conf.standalone.enabled) {
|
|||||||
|
|
||||||
// Every host in the inventory, unfiltered — for admins (the web UI's own
|
// Every host in the inventory, unfiltered — for admins (the web UI's own
|
||||||
// account is already gated by requireAdmin before this is ever called).
|
// account is already gated by requireAdmin before this is ever called).
|
||||||
async function allHosts({ fetchImpl = fetch } = {}) {
|
function isManagedHost(r) {
|
||||||
const resources = await directoryClient({ fetchImpl }).getResourcesByGroup(undefined, { kind: 'host' });
|
if (!r || r.kind !== 'host') return false;
|
||||||
return resources.filter(r => r.kind === 'host');
|
// If managed attribute is present, require it to be true/truthy
|
||||||
|
if (r.metadata && r.metadata.managed !== undefined) {
|
||||||
|
return r.metadata.managed === true || r.metadata.managed === 'true';
|
||||||
|
}
|
||||||
|
// Default to true for manually created hosts that lack explicit managed metadata
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function accessibleHosts(user, { fetchImpl = fetch, ldap = userLdap } = {}) {
|
async function allHosts({ fetchImpl = fetch } = {}) {
|
||||||
|
const resources = await directoryClient({ fetchImpl }).getResourcesByGroup(undefined, { kind: 'host' });
|
||||||
|
return resources.filter(isManagedHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function accessibleHosts(user, { fetchImpl = fetch } = {}) {
|
||||||
const hit = cache.get(user.uid);
|
const hit = cache.get(user.uid);
|
||||||
if (hit && Date.now() - hit.at < CACHE_TTL_MS) return hit.hosts;
|
if (hit && Date.now() - hit.at < CACHE_TTL_MS) return hit.hosts;
|
||||||
|
|
||||||
// The SSH path passes an LDAP user ({dn, uid, ...}) with no .groups, so we
|
let resources = [];
|
||||||
// look them up; the web UI already has the session's OIDC groups claim
|
try {
|
||||||
// and passes it directly, skipping a redundant LDAP round-trip.
|
resources = await directoryClient({ fetchImpl }).getAccess(user.uid);
|
||||||
const groups = user.groups || await ldap.getGroups(user.dn);
|
} catch (error) {
|
||||||
|
console.error(`[access] ${error.message}`);
|
||||||
const seen = new Map();
|
|
||||||
for (const cn of groups) {
|
|
||||||
let resources;
|
|
||||||
try {
|
|
||||||
resources = await fetchResourcesByGroup(cn, { fetchImpl });
|
|
||||||
} catch (error) {
|
|
||||||
// One bad group must not hide the rest; the SSO being down
|
|
||||||
// surfaces as an empty list + log line, not a crash.
|
|
||||||
console.error(`[access] ${error.message}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const r of resources) {
|
|
||||||
if (r.kind === 'host' && !seen.has(r.id)) seen.set(r.id, r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hosts = [...seen.values()];
|
const hosts = resources.filter(isManagedHost);
|
||||||
cache.set(user.uid, { at: Date.now(), hosts });
|
cache.set(user.uid, { at: Date.now(), hosts });
|
||||||
return hosts;
|
return hosts;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -37,6 +37,6 @@ module.exports = {
|
|||||||
nav: [
|
nav: [
|
||||||
{href: '/dashboard', icon: 'fa-solid fa-gauge-high', label: 'Dashboard', groups: []},
|
{href: '/dashboard', icon: 'fa-solid fa-gauge-high', label: 'Dashboard', groups: []},
|
||||||
{href: '/sessions', icon: 'fa-solid fa-plug-circle-bolt', label: 'Sessions', groups: []},
|
{href: '/sessions', icon: 'fa-solid fa-plug-circle-bolt', label: 'Sessions', groups: []},
|
||||||
{href: '/audit', icon: 'fa-solid fa-clipboard-list', label: 'Audit', groups: ['admin']},
|
{href: '/audit', icon: 'fa-solid fa-clipboard-list', label: 'Audit', groups: ['admin', 'app_jump_admin']},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const conf = require('@simpleworkjs/conf');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a signed SSH certificate from the SSO Manager's OpenBao/Vault proxy.
|
||||||
|
*
|
||||||
|
* @param {string} publicKey - The jump host's public key (e.g. 'ssh-rsa AAAAB3...')
|
||||||
|
* @param {string} targetUid - The username the cert should be valid for
|
||||||
|
* @returns {Promise<string>} - The signed SSH certificate
|
||||||
|
*/
|
||||||
|
async function getSignedCert(publicKey, targetUid) {
|
||||||
|
const sso = conf.sso || {};
|
||||||
|
const pkiConfig = conf.ssh?.pki || {};
|
||||||
|
|
||||||
|
const vaultRole = pkiConfig.role || 'jump-host-role';
|
||||||
|
const endpoint = `${sso.url}/api/vault/ssh/sign/${vaultRole}`;
|
||||||
|
|
||||||
|
const response = await fetch(endpoint, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${sso.apiToken}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
public_key: publicKey,
|
||||||
|
valid_principals: targetUid
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errText = await response.text().catch(() => '');
|
||||||
|
throw new Error(`Failed to sign SSH cert (status ${response.status}): ${errText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (!data.data || !data.data.signed_key) {
|
||||||
|
throw new Error('Vault response missing signed_key');
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.data.signed_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getSignedCert };
|
||||||
+64
-2
@@ -1,7 +1,47 @@
|
|||||||
<%- include('top') %>
|
<%- include('top') %>
|
||||||
<script type="text/javascript">app.auth.forceLogin();</script>
|
<script type="text/javascript">app.auth.forceLogin(['admin', 'app_jump_admin']);</script>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
|
<div class="row g-3 mb-4">
|
||||||
|
<div class="col-6 col-md-3">
|
||||||
|
<div class="card shadow-sm text-center"><div class="card-body">
|
||||||
|
<div class="display-6" id="stat-active">–</div>
|
||||||
|
<div class="text-muted small text-uppercase">Active sessions</div>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-md-3">
|
||||||
|
<div class="card shadow-sm text-center"><div class="card-body">
|
||||||
|
<div class="display-6" id="stat-total">–</div>
|
||||||
|
<div class="text-muted small text-uppercase">Total connections</div>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-md-3">
|
||||||
|
<div class="card shadow-sm text-center"><div class="card-body">
|
||||||
|
<div class="display-6 text-danger" id="stat-fail">–</div>
|
||||||
|
<div class="text-muted small text-uppercase">Failed</div>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-md-3">
|
||||||
|
<div class="card shadow-sm text-center"><div class="card-body">
|
||||||
|
<div class="display-6" id="stat-users">–</div>
|
||||||
|
<div class="text-muted small text-uppercase">Users seen</div>
|
||||||
|
</div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row g-3 mb-4">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card shadow-sm"><div class="card-header"><i class="fa-solid fa-server me-1"></i> Top hosts</div>
|
||||||
|
<table class="table table-sm mb-0"><tbody id="top-hosts"></tbody></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card shadow-sm"><div class="card-header"><i class="fa-solid fa-user me-1"></i> Top users</div>
|
||||||
|
<table class="table table-sm mb-0"><tbody id="top-users"></tbody></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header"><i class="fa-solid fa-clipboard-list me-1"></i> Audit log</div>
|
<div class="card-header"><i class="fa-solid fa-clipboard-list me-1"></i> Audit log</div>
|
||||||
<div class="card-body pb-0">
|
<div class="card-body pb-0">
|
||||||
@@ -33,6 +73,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
function rows(sel, list){
|
||||||
|
var $b = $(sel).empty();
|
||||||
|
if(!list || !list.length){ $b.append('<tr><td class="text-muted">No data.</td></tr>'); return; }
|
||||||
|
list.forEach(function(x){
|
||||||
|
$b.append('<tr><td>' + app.jump.esc(x.name) + '</td><td class="text-end">' + x.count + '</td></tr>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function loadMetrics(){
|
||||||
|
app.jump.metrics(function(error, data){
|
||||||
|
if(error || !data) return;
|
||||||
|
$('#stat-active').text(data.active);
|
||||||
|
$('#stat-total').text(data.total);
|
||||||
|
$('#stat-fail').text(data.fail);
|
||||||
|
$('#stat-users').text((data.topUsers || []).length);
|
||||||
|
rows('#top-hosts', data.topHosts);
|
||||||
|
rows('#top-users', data.topUsers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var page = 0;
|
var page = 0;
|
||||||
function filters(){ return {page: page, uid: $('#f-uid').val(), target: $('#f-target').val(), status: $('#f-status').val()}; }
|
function filters(){ return {page: page, uid: $('#f-uid').val(), target: $('#f-target').val(), status: $('#f-status').val()}; }
|
||||||
function applyFilters(){ page = 0; load(); }
|
function applyFilters(){ page = 0; load(); }
|
||||||
@@ -59,6 +118,9 @@
|
|||||||
$('#next').prop('disabled', (page + 1) * size >= total);
|
$('#next').prop('disabled', (page + 1) * size >= total);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$(document).ready(load);
|
$(document).ready(function(){
|
||||||
|
loadMetrics();
|
||||||
|
load();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<%- include('bottom') %>
|
<%- include('bottom') %>
|
||||||
|
|||||||
+15
-59
@@ -2,33 +2,6 @@
|
|||||||
<script type="text/javascript">app.auth.forceLogin();</script>
|
<script type="text/javascript">app.auth.forceLogin();</script>
|
||||||
|
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="row g-3 mb-4">
|
|
||||||
<div class="col-6 col-md-3">
|
|
||||||
<div class="card shadow-sm text-center"><div class="card-body">
|
|
||||||
<div class="display-6" id="stat-active">–</div>
|
|
||||||
<div class="text-muted small text-uppercase">Active sessions</div>
|
|
||||||
</div></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-md-3">
|
|
||||||
<div class="card shadow-sm text-center"><div class="card-body">
|
|
||||||
<div class="display-6" id="stat-total">–</div>
|
|
||||||
<div class="text-muted small text-uppercase">Total connections</div>
|
|
||||||
</div></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-md-3">
|
|
||||||
<div class="card shadow-sm text-center"><div class="card-body">
|
|
||||||
<div class="display-6 text-danger" id="stat-fail">–</div>
|
|
||||||
<div class="text-muted small text-uppercase">Failed</div>
|
|
||||||
</div></div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-md-3">
|
|
||||||
<div class="card shadow-sm text-center"><div class="card-body">
|
|
||||||
<div class="display-6" id="stat-users">–</div>
|
|
||||||
<div class="text-muted small text-uppercase">Users seen</div>
|
|
||||||
</div></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row g-3 mb-4">
|
<div class="row g-3 mb-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
@@ -54,20 +27,12 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header"><i class="fa-solid fa-network-wired me-1"></i> <span id="my-hosts-title">Hosts you can reach</span></div>
|
<div class="card-header"><i class="fa-solid fa-network-wired me-1"></i> <span id="my-hosts-title">Hosts you can reach</span></div>
|
||||||
<table class="table table-sm mb-0"><tbody id="my-hosts"></tbody></table>
|
<div class="table-responsive">
|
||||||
</div>
|
<table class="table table-sm mb-0">
|
||||||
</div>
|
<thead><tr><th>Host</th><th>Slug</th><th class="text-end">Address</th><th>Last connection</th><th>Last failed connection</th><th></th></tr></thead>
|
||||||
</div>
|
<tbody id="my-hosts"></tbody>
|
||||||
|
</table>
|
||||||
<div class="row g-3 mb-4">
|
</div>
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="card shadow-sm"><div class="card-header"><i class="fa-solid fa-server me-1"></i> Top hosts</div>
|
|
||||||
<table class="table table-sm mb-0"><tbody id="top-hosts"></tbody></table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="card shadow-sm"><div class="card-header"><i class="fa-solid fa-user me-1"></i> Top users</div>
|
|
||||||
<table class="table table-sm mb-0"><tbody id="top-users"></tbody></table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -121,13 +86,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function rows(sel, list){
|
|
||||||
var $b = $(sel).empty();
|
|
||||||
if(!list || !list.length){ $b.append('<tr><td class="text-muted">No data.</td></tr>'); return; }
|
|
||||||
list.forEach(function(x){
|
|
||||||
$b.append('<tr><td>' + app.jump.esc(x.name) + '</td><td class="text-end">' + x.count + '</td></tr>');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// The web UI and the SSH front door share a hostname, just not a port.
|
// The web UI and the SSH front door share a hostname, just not a port.
|
||||||
var SSH_PORT = <%- JSON.stringify(sshPort) %>;
|
var SSH_PORT = <%- JSON.stringify(sshPort) %>;
|
||||||
function sshCommand(target){
|
function sshCommand(target){
|
||||||
@@ -153,9 +111,16 @@
|
|||||||
hosts.forEach(function(h){
|
hosts.forEach(function(h){
|
||||||
var addr = (h.metadata && (h.metadata.ip || h.metadata.address)) || '';
|
var addr = (h.metadata && (h.metadata.ip || h.metadata.address)) || '';
|
||||||
var rowId = 'host-cmd-' + h.slug.replace(/[^a-zA-Z0-9_-]/g, '');
|
var rowId = 'host-cmd-' + h.slug.replace(/[^a-zA-Z0-9_-]/g, '');
|
||||||
$b.append('<tr><td>' + app.jump.esc(h.displayName || h.name || h.slug) + '</td>'
|
// Green: a session to this host is live right now. Yellow: the most
|
||||||
|
// recent attempt to this host failed (and none is currently live).
|
||||||
|
var rowClass = h.connected ? 'table-success'
|
||||||
|
: (h.lastFailed && (!h.lastConnected || h.lastFailed > h.lastConnected)) ? 'table-warning'
|
||||||
|
: '';
|
||||||
|
$b.append('<tr class="' + rowClass + '"><td>' + app.jump.esc(h.displayName || h.name || h.slug) + '</td>'
|
||||||
+ '<td class="text-muted small">' + app.jump.esc(h.slug) + '</td>'
|
+ '<td class="text-muted small">' + app.jump.esc(h.slug) + '</td>'
|
||||||
+ '<td class="text-end text-muted small">' + app.jump.esc(addr) + '</td>'
|
+ '<td class="text-end text-muted small">' + app.jump.esc(addr) + '</td>'
|
||||||
|
+ '<td class="small">' + (h.lastConnected ? app.jump.fmtTime(h.lastConnected) : '—') + '</td>'
|
||||||
|
+ '<td class="small">' + (h.lastFailed ? app.jump.fmtTime(h.lastFailed) : '—') + '</td>'
|
||||||
+ '<td class="text-end">'
|
+ '<td class="text-end">'
|
||||||
+ '<input type="hidden" id="' + rowId + '" value="' + app.jump.esc(sshCommand(h.slug)) + '">'
|
+ '<input type="hidden" id="' + rowId + '" value="' + app.jump.esc(sshCommand(h.slug)) + '">'
|
||||||
+ '<button class="btn btn-sm btn-outline-secondary" onclick="copyFieldValue(\'#' + rowId + '\')" title="Copy quick-jump command"><i class="fa-solid fa-copy"></i></button>'
|
+ '<button class="btn btn-sm btn-outline-secondary" onclick="copyFieldValue(\'#' + rowId + '\')" title="Copy quick-jump command"><i class="fa-solid fa-copy"></i></button>'
|
||||||
@@ -304,17 +269,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(async function(){
|
$(document).ready(async function(){
|
||||||
app.jump.metrics(function(error, data){
|
|
||||||
if(error || !data) return;
|
|
||||||
$('#stat-active').text(data.active);
|
|
||||||
$('#stat-total').text(data.total);
|
|
||||||
$('#stat-fail').text(data.fail);
|
|
||||||
$('#stat-users').text((data.topUsers || []).length);
|
|
||||||
rows('#top-hosts', data.topHosts);
|
|
||||||
rows('#top-users', data.topUsers);
|
|
||||||
});
|
|
||||||
await app.auth.loadUser();
|
await app.auth.loadUser();
|
||||||
if(app.auth.isAdmin()) $('#my-hosts-title').text('All hosts');
|
if(app.auth.isAdmin()) $('#my-hosts-title').text('My hosts');
|
||||||
$('#quick-jump-cmd').val(sshCommand());
|
$('#quick-jump-cmd').val(sshCommand());
|
||||||
app.jump.hosts(function(error, data){
|
app.jump.hosts(function(error, data){
|
||||||
if(error) return hostRows('#my-hosts', []);
|
if(error) return hostRows('#my-hosts', []);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<%- include('top') %>
|
||||||
|
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-6 text-center">
|
||||||
|
<div class="mb-4">
|
||||||
|
<i class="fa-solid fa-triangle-exclamation text-warning" style="font-size: 4rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h1 class="display-4 fw-bold text-dark"><%= error.status || 500 %></h1>
|
||||||
|
<h3 class="mb-3 text-secondary"><%= error.message || 'Something went wrong' %></h3>
|
||||||
|
<p class="text-muted mb-4">
|
||||||
|
<% if (error.status === 404) { %>
|
||||||
|
The page you are looking for doesn't exist or has been moved.
|
||||||
|
<% } else { %>
|
||||||
|
An unexpected error occurred. Please try again later.
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
<a href="/" class="btn btn-primary shadow-sm px-4 py-2">
|
||||||
|
<i class="fa-solid fa-house me-2"></i>Return to Home
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%- include('bottom') %>
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
<a href="/api/auth/oidc/start" class="btn btn-outline-primary">
|
<a href="/api/auth/oidc/start" class="btn btn-outline-primary">
|
||||||
<i class="fa-solid fa-id-badge"></i> Log in with SSO
|
<i class="fa-solid fa-id-badge"></i> Log in with Jump
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="form-inline mt-2 mt-md-0">
|
<div class="form-inline mt-2 mt-md-0">
|
||||||
<% if(ui.profileUrl){ %>
|
<% if(ui.profileUrl){ %>
|
||||||
<a id="cl-username" class="navbar-text text-light me-3" href="<%- ui.profileUrl %>" style="display: none;">
|
<a id="cl-username" class="navbar-text text-light me-3 text-decoration-none" href="<%- ui.profileUrl %>" style="display: none;">
|
||||||
<i class="fa-solid fa-user me-1"></i><span id="cl-username-text"></span>
|
<i class="fa-solid fa-user me-1"></i><span id="cl-username-text"></span>
|
||||||
</a>
|
</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
|||||||
Reference in New Issue
Block a user