67e2fc54c2
Rewire onto the shared @simpleworkjs/oidc-client, /directory-schema, /ldap, and
/app-stack packages (deleting the byte-identical local forks). utils/access.js
now fetches reachable hosts through the shared directory client, which
validates the {results} envelope and treats envelope drift as a failed group
rather than silently returning []. models/user_ldap.js is a thin wrapper over
createLdapClient (loose TLS default preserved). build_info moves to utils/ with
the shared {buildVersion,buildHash,buildYear} shape. Align ldapts ^8.1.8 and
redis ^6.1.0. Lockfile regenerated from the registry (no file:/link:).
Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const express = require('express');
|
|
const router = require('express').Router();
|
|
const conf = require('@simpleworkjs/conf');
|
|
const buildInfo = require('../utils/build_info');
|
|
const registry = require('../services/session_registry');
|
|
const { safeInternalPath } = require('@simpleworkjs/oidc-client');
|
|
const { mountStaticModules } = require('@simpleworkjs/app-stack');
|
|
|
|
const values = {
|
|
title: conf.environment !== 'production' ? 'dev' : '',
|
|
titleIcon: conf.environment !== 'production' ? '<i class="fa-brands fa-dev"></i>' : '',
|
|
name: conf.name,
|
|
logo: conf.logo,
|
|
...buildInfo,
|
|
};
|
|
|
|
// Serve front-end vendor libraries straight from node_modules (same convention
|
|
// as the sibling apps), and the app's own JS/CSS/img from public/.
|
|
mountStaticModules(router, {
|
|
root: path.join(__dirname, '..'),
|
|
deps: ['bootstrap', 'mustache', 'jquery', '@fortawesome', 'moment', 'jq-repeat'],
|
|
});
|
|
|
|
// Liveness probe — no auth.
|
|
router.get('/health', (req, res) => {
|
|
res.json({status: 'ok', activeSessions: registry.count(), buildVersion: buildInfo.buildVersion, buildHash: buildInfo.buildHash});
|
|
});
|
|
|
|
router.get('/', (req, res) => res.redirect(302, '/dashboard'));
|
|
|
|
// Page shells. The client framework (app-base.js + app.js) loads data via the
|
|
// authenticated /api/* endpoints and gates the UI on /api/user/me, so these
|
|
// render unauthenticated (like the sibling apps) and the client redirects to
|
|
// /login when there's no valid session.
|
|
router.get('/login', (req, res) => res.render('login', {
|
|
...values,
|
|
redirect: safeInternalPath(req.query.redirect || '/'),
|
|
oidcEnabled: !!(conf.oidc && conf.oidc.enabled),
|
|
}));
|
|
router.get('/dashboard', (req, res) => res.render('dashboard', {...values}));
|
|
router.get('/sessions', (req, res) => res.render('sessions', {...values}));
|
|
router.get('/audit', (req, res) => res.render('audit', {...values}));
|
|
|
|
module.exports = router;
|