feat: rebuild web UI on the shared theta42 app stack; OIDC + local admin auth

The web management UI was a bespoke minimal theme with LDAP-bind login.
Rebuild it to match the SSO Manager and Proxy — same stack, same look/feel,
same auth model. The SSH bridge, audit, metrics, and access logic are
unchanged; this is purely the web layer.

Frontend (mirrors proxy/sso):
- Express + EJS with the shared top.ejs/bottom.ejs shell, Bootstrap 5,
  jQuery, jq-repeat, FontAwesome, Socket.IO, and the shared app-base.js /
  val.js client framework (copied verbatim). Vendor libs served from
  node_modules via /static-modules; app assets via /static.
- Dashboard / Sessions / Audit pages render in the common look/feel,
  loading data through the authenticated /api/* endpoints.

Auth (mirrors proxy):
- OIDC against the SSO (utils/oidc.js + routes/auth.js + models/oidc_state)
  plus a local anti-lockout admin (models/user_redis.js, bootstrapped from
  auth.adminUsers[0] / auth.localAdminPass). AuthToken sessions carry the
  group snapshot; middleware gates the data API on adminGroups or the local
  admin. New config: oidc{} + auth.adminUsers/localAdminPass.
- /api/user/me drives the client login state; "Log in with SSO" hidden when
  oidc.enabled is false.

Verified end to end: local admin login -> token -> /api/user/me isAdmin,
metrics/sessions/audit 200 with token / 401 without / 401 bad password;
static + page shells serve; 26 tests green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 20:57:34 -04:00
parent eb8e5b409e
commit aa3b3ed515
38 changed files with 2550 additions and 374 deletions
+8 -29
View File
@@ -1,36 +1,15 @@
'use strict';
// Auditing + metrics API (admin-gated by middleware/auth in app.js).
const router = require('express').Router();
const middleware = require('../middleware/auth');
const express = require('express');
const audit = require('../models/audit_event');
const metrics = require('../models/metrics');
const registry = require('../services/session_registry');
// Authentication (local login + OIDC handshake). Unauthenticated by design.
router.use('/auth', require('./auth'));
const router = express.Router();
// Who am I — needs a valid session but no admin gate (drives the login state).
router.use('/user', middleware.auth, require('./user'));
router.get('/sessions', (req, res) => {
res.json({ results: registry.list(), active: registry.count() });
});
router.get('/audit', async (req, res, next) => {
try {
const page = Math.max(0, parseInt(req.query.page, 10) || 0);
const data = await audit.list({
page,
pageSize: Math.min(200, parseInt(req.query.pageSize, 10) || 50),
uid: req.query.uid || undefined,
target: req.query.target || undefined,
status: req.query.status || undefined,
});
res.json(data);
} catch (err) { next(err); }
});
router.get('/metrics', async (req, res, next) => {
try {
res.json({ ...(await metrics.summary()), active: registry.count() });
} catch (err) { next(err); }
});
// Jump-host data — admin only (audit log, active sessions, metrics).
router.use('/', middleware.auth, middleware.requireAdmin, require('./jump'));
module.exports = router;