3a307c1563
views/top.ejs, views/bottom.ejs and public/lib/js/app-base.js are now byte-identical across sso-manager-node, proxy and jump-host. Everything per-app moved into utils/ui.js, exposed to every render as `ui` via app.locals (nav items + their group gates, footer repo/docs/ToS links, favicon, profile/logout targets, update-banner on/off + label). Client framework changes: - One gating model everywhere: app-base.js reveals .group-required-<cn> for each of the current user user/me groups. sso-manager-node sends LDAP DNs in memberOf, the OIDC clients send CNs in groups; both normalise to CNs, and the clients isAdmin flag becomes a synthetic `admin` group, so proxy nav-admin items are now group-required-admin. - user/me is fetched once per page load and cached (app.auth.loadUser); nav, forceLogin and group-required elements all read that one promise. - isLoggedIn is dual-mode (Promise + node-style callback), so the async and callback call styles both work from one shared top.ejs. - forceLogin no longer uses $.holdReady (removed in jQuery 4): it redirects to /login?redirect=<path>, and still enforces required groups. - logOut only clears the session; the caller decides where to go next. - post/put/delete are dual-mode Promise/callback, which also removes the undefined `callback2` reference that threw on a non-function callback. Dependencies: jquery ^4.0.0 and ejs ^3.1.10 in all three apps. proxy specifics: - .group-required base rule added to styles.css; the admin nav items lost their inline display:none in favour of it. - The brand link points at / instead of #. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
2.1 KiB
JavaScript
46 lines
2.1 KiB
JavaScript
'use strict';
|
|
|
|
// Per-app values for the shared UI shell (views/top.ejs + views/bottom.ejs).
|
|
//
|
|
// Those two partials are byte-identical across sso-manager-node, proxy and
|
|
// jump-host — everything that differs between the apps lives here and is
|
|
// exposed to every render as `ui` via app.locals (see app.js). Keep the key set
|
|
// in sync across the three apps; a missing key is a render-time ReferenceError,
|
|
// not a silent fallback.
|
|
|
|
module.exports = {
|
|
// --- footer -------------------------------------------------------------
|
|
repoUrl: 'https://github.com/theta42/proxy',
|
|
licenseUrl: 'https://github.com/theta42/proxy/blob/master/LICENSE',
|
|
// In-app docs route (routes/docs.js). Apps without one point at the
|
|
// published docs site and set docsExternal.
|
|
docsUrl: '/docs',
|
|
docsExternal: false,
|
|
// Only sso-manager-node serves a Terms of Service page; null hides the link.
|
|
tosUrl: null,
|
|
|
|
// --- header / nav -------------------------------------------------------
|
|
faviconUrl: '/static/favicon.svg',
|
|
// Where the current-user chip links. null renders it as a plain span (for
|
|
// apps with no profile page).
|
|
profileUrl: '/profile',
|
|
// Where "Log Out" lands.
|
|
logoutRedirect: '/',
|
|
// Admin-only "a newer release is available" banner, backed by
|
|
// GET /api/update-check. Apps without that endpoint set false.
|
|
updateCheck: true,
|
|
updateLabel: 'the proxy',
|
|
|
|
// Nav items, in order. `groups` is an OR-list of group CNs that may see the
|
|
// item; an empty list means "always visible". Gating is done client-side by
|
|
// app-base.js, which reveals .group-required-<cn> for each group the user is
|
|
// in (plus the synthetic `admin` group when user/me reports isAdmin).
|
|
nav: [
|
|
{href: '/hosts', icon: 'fa-solid fa-network-wired', label: 'Hosts', groups: []},
|
|
{href: '/dns', icon: 'fa-solid fa-record-vinyl', label: 'DNS', groups: []},
|
|
{href: '/users', icon: 'fa-solid fa-users', label: 'Users', groups: ['admin']},
|
|
{href: '/permissions', icon: 'fa-solid fa-user-shield', label: 'Permissions', groups: ['admin']},
|
|
{href: '/groups', icon: 'fa-solid fa-users-gear', label: 'Groups', groups: ['admin']},
|
|
],
|
|
};
|