Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep kiosk sessions off settings surfaces and silence the truncated-status security banner (#1650)

rcourtman000986f12580
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 27d6499a07..066e8d849e 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -6816,3 +6816,14 @@ from the active tenant monitor. Provider replacement refreshes both the default
service and already-created tenant services after monitor reload, so no AI
service retains an orphaned cache or writes a tenant's URL through another
organization's guest, Docker, or host metadata store.
+
+The same shell chrome boundary now also has to respect browser session
+authority. When the authenticated shell in `frontend-modern/src/App.tsx` and
+`frontend-modern/src/AppLayout.tsx` is driven by a scope-limited API token
+(a kiosk token carrying `monitoring:read` only), the Patrol utility tab route
+`/patrol` stays inside the shell's blocked-route redirect whether or not kiosk
+mode is currently on, and the Escape key must not be usable to leave kiosk into
+that chrome. Assistant and Patrol shell state stays owned by
+`frontend-modern/src/stores/aiChat.ts` and the canonical Patrol path as before;
+this containment is a shell-level authority rule and must not be forked into a
+second AI-side scope check.
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 12e279220c..7a208697c1 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -1368,6 +1368,15 @@ hands-on Patrol modes, issue investigation, verified fixes, and longer history`.
deployed environment. The returned portal identifier is a separate
approved configuration/deployment input, and a passing GET-only production
re-audit remains the postcondition.
+29. Keep the authenticated shell's kiosk containment keyed to session
+ authority. Token scope settings access is decided once by
+ `sessionHasSettingsAccess` in `frontend-modern/src/AppLayout.tsx` and
+ consumed by the utility tab list, the blocked-route redirect, the Escape
+ key handler, and the `frontend-modern/src/App.tsx` global banner block.
+ Escape exits kiosk only for a session that can reach settings; a
+ scope-limited session gets the temporary header reveal instead. The
+ blocked-route redirect and the banner block must stay active for a
+ scope-limited session even when kiosk is off.
## Current State
@@ -3206,3 +3215,21 @@ nullable until the formatting edge, but it must normalize the message through
the shared monitored-system presentation helper instead of branching on
demo/billing state inside settings panels or inventing a second mock-only
license explanation path.
+That same authenticated shell split also owns kiosk containment for
+scope-limited browser sessions. A kiosk API token carries `monitoring:read`
+only, so the shell must treat "this session cannot read settings" as an
+authority fact rather than a kiosk decoration.
+`frontend-modern/src/AppLayout.tsx` exports the single
+`sessionHasSettingsAccess` predicate over token scopes, and both the utility
+tab list and `frontend-modern/src/App.tsx` must consume that one predicate
+instead of re-deriving scope membership inline. Escape may toggle kiosk only
+for a session that can reach settings; for a scope-limited session Escape must
+resolve to the existing temporary header reveal, because `setKioskMode(false)`
+is sticky for the remainder of the browser session and would otherwise strand a
+wall display on chrome it has no authority to use. The blocked-route redirect
+away from `/settings`, `/patrol`, and alert-configuration tabs must hold
+whenever the session lacks settings access, not only while kiosk is on, and the
+global banner block in `frontend-modern/src/App.tsx` (security, demo,
+commercial migration, update, what's-new, GitHub star) must be gated on the
+same predicate because those banners deep-link into settings destinations a
+scope-limited session cannot open.
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index 08a7117628..a1737d4f70 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -573,6 +573,15 @@ tokens, and path-normalization variants.
`internal/api/rbac_handlers_test.go`, and the rejection cases in
`pkg/auth/sqlite_manager_test.go`.
+14. Security posture presentation must never be computed from a payload the
+ caller was not authorized to read. `/api/security/status` truncates its
+ response by authority and declares which tier it returned through
+ `detailLevel`. `frontend-modern/src/utils/securityScorePresentation.ts`
+ treats an `authenticated` payload as carrying no posture at all and a
+ `public` payload as authoritative for `hasAuthentication` only; only a
+ `privileged` payload supports the full assessment. Absent posture fields
+ must not be read as disabled controls.
+
## Current State
### System settings mutation surface no longer accepts dead schedule inputs
@@ -1731,3 +1740,31 @@ or scheme of its choosing — it can only reach the same `Host` header handling
the request already depends on. The derived value is returned in an
admin-authenticated settings response and is never persisted, never used as a
redirect target, and never used to make an authorization decision.
+
+### The global security banner no longer scores a truncated status payload
+
+`/api/security/status` in `internal/api/router_routes_auth_security.go` returns
+three payload tiers and names the tier it served in `detailLevel`. Only the
+`privileged` tier (settings:read) carries `exportProtected`,
+`apiTokenConfigured`, `hasHTTPS`, and `publicAccess`. The browser banner used
+to compute its score from whatever arrived, so a kiosk API token holding
+`monitoring:read` alone received an `authenticated` payload with those fields
+absent, read them as disabled controls, and rendered a false "security score
+1/5" banner whose "Enable Security" link pointed at a settings page the token
+cannot open (#1650).
+
+`shouldShowGlobalSecurityWarning` in
+`frontend-modern/src/utils/securityScorePresentation.ts` now takes the served
+`detailLevel` and refuses to assert anything the payload does not support. An
+`authenticated` payload raises no warning. A `public` payload is authoritative
+for `hasAuthentication` only, so an instance with no authentication configured
+is still warned about — the case the banner exists for — while a public payload
+that does have authentication contributes no invented posture debt. A
+`privileged` payload keeps the full assessment unchanged, and a caller passing
+the posture directly without a `detailLevel` is still treated as privileged.
+`frontend-modern/src/components/SecurityWarning.tsx` carries the field through
+from the response. This is presentation authority only; every settings endpoint
+already enforces scopes server-side and no backend behaviour changed.
+Regression coverage: the `Issue1650` cases in
+`frontend-modern/src/utils/__tests__/securityScorePresentation.test.ts` and
+`frontend-modern/src/components/__tests__/SecurityWarning.test.tsx`.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 77e4f3dc65..1ace793dd9 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -4772,3 +4772,14 @@ detected public URL is unchanged. Tenant workspace preservation, recovery flows
that copy `system.json` forward, and backup or restore attribution are
unaffected, and the extension-point expectations on `internal/api/` and
`internal/api/router.go` are otherwise unchanged.
+
+The shared `frontend-modern/src/App.tsx` shell boundary this subsystem consumes
+gained one authority gate on its global banner block. The banners rendered
+above the authenticated shell (security, demo, commercial migration, update,
+what's-new, GitHub star, and the global update progress watcher) now render
+only for a session that can reach settings, using the single
+`sessionHasSettingsAccess` predicate exported from
+`frontend-modern/src/AppLayout.tsx`. Public-route ownership, the post-login
+handoff, demo organization suppression, and platform-page route carriage in
+`frontend-modern/src/App.tsx` are unchanged; nothing about backup, restore, or
+recovery routing keys off banner visibility.
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index 68ce8f032e..7e5d0dc2bc 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -56,7 +56,7 @@ import {
buildVmwarePath,
} from './routing/resourceLinks';
import { APP_SHELL_ROUTE_PRELOAD_PATHS, preloadRouteModule } from '@/routing/routePreload';
-import { AppLayout } from '@/AppLayout';
+import { AppLayout, sessionHasSettingsAccess } from '@/AppLayout';
import RuntimeHomePage from '@/pages/RuntimeHome';
import { useAppRuntimeState } from '@/useAppRuntimeState';
import {
@@ -293,12 +293,9 @@ function App() {
);
const platformNavigationResolved = () => platformNavigationAdmission().resolved;
const platformNavigationVisibility = () => platformNavigationAdmission().visibility;
- const hasSettingsAccess = createMemo(() => {
- const scopes = runtime.securityStatus()?.tokenScopes;
- return (
- !scopes || scopes.length === 0 || scopes.includes('*') || scopes.includes('settings:read')
- );
- });
+ const hasSettingsAccess = createMemo(() =>
+ sessionHasSettingsAccess(runtime.securityStatus()?.tokenScopes),
+ );
let appShellRoutePreloadCleanup: (() => void) | undefined;
let appShellRoutesPreloadScheduled = false;
let workspaceRedirectPending = false;
@@ -491,7 +488,12 @@ function App() {
>
<WebSocketContext.Provider value={runtime.enhancedStore()!}>
<DarkModeContext.Provider value={runtime.darkMode}>
- <Show when={!kioskMode()}>
+ {/* Global banners deep-link into settings (security
+ hardening, telemetry preferences, license management),
+ so they are for sessions that can actually reach those
+ surfaces. Kiosk hides them; a scope-limited token has
+ no business seeing them even outside kiosk (#1650). */}
+ <Show when={!kioskMode() && hasSettingsAccess()}>
<SecurityWarning />
<DemoBanner />
<CommercialMigrationBanner />
diff --git a/frontend-modern/src/AppLayout.tsx b/frontend-modern/src/AppLayout.tsx
index 2cce278dd8..9f93a86199 100644
--- a/frontend-modern/src/AppLayout.tsx
+++ b/frontend-modern/src/AppLayout.tsx
@@ -24,7 +24,7 @@ import {
import { dialogStackHasBlockingDialog } from '@/components/shared/useDialogState';
import { OrgSwitcher } from '@/components/OrgSwitcher';
import { PulsePatrolLogo } from '@/components/Brand/PulsePatrolLogo';
-import { MONITORING_READ_SCOPE } from '@/constants/apiScopes';
+import { MONITORING_READ_SCOPE, SETTINGS_READ_SCOPE } from '@/constants/apiScopes';
import type { Organization } from '@/api/orgs';
import type { VersionInfo } from '@/api/updates';
import type { Alert, State } from '@/types/api';
@@ -112,6 +112,20 @@ function resolvePrimaryNavigationRoute(tab: PrimaryTab, routeMemory: PrimaryRout
export function resetPrimaryNavigationRouteMemory() {
primaryRouteMemory = {};
}
+
+/**
+ * Whether this session is allowed to reach settings surfaces.
+ *
+ * Session/cookie auth carries no token scopes, so an absent or empty scope list
+ * means "unrestricted". A scoped API token needs the wildcard or settings:read.
+ * Kiosk tokens are minted with monitoring:read only, so they fail this check and
+ * must never be handed a settings tab, a settings route, or a banner that links
+ * into settings (#1650).
+ */
+export function sessionHasSettingsAccess(scopes: string[] | undefined): boolean {
+ if (!scopes || scopes.length === 0) return true;
+ return scopes.includes('*') || scopes.includes(SETTINGS_READ_SCOPE);
+}
const NAV_TAB_ICON_CLASS = 'w-4 h-4 shrink-0';
const AI_CHAT_LAUNCHER_BUTTON_CLASS =
'fixed right-4 bottom-[calc(5rem+env(safe-area-inset-bottom,0px))] z-40 flex h-11 w-11 items-center justify-center rounded-full border border-border bg-surface text-blue-600 shadow-lg transition-colors duration-200 hover:bg-surface-hover hover:text-blue-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-blue-400 dark:hover:text-blue-300 lg:right-0 lg:top-1/2 lg:bottom-auto lg:h-auto lg:w-auto lg:min-h-9 lg:min-w-10 lg:-translate-y-1/2 lg:rounded-l-lg lg:rounded-r-none lg:border-r-0 lg:px-2.5 lg:py-2.5 lg:shadow-none';
@@ -294,6 +308,11 @@ export function AppLayout(props: AppLayoutProps) {
setKioskMode(!kioskMode());
};
+ // Scope-limited sessions (kiosk API tokens) have no way back into the full
+ // shell, so kiosk is not theirs to leave. Sessions that can reach settings
+ // chose kiosk themselves and keep the escape hatch.
+ const hasSettingsAccess = createMemo(() => sessionHasSettingsAccess(props.tokenScopes()));
+
const platformNavigationVisibility = createMemo(
() =>
props.platformVisibility?.() ??
@@ -335,16 +354,27 @@ export function AppLayout(props: AppLayoutProps) {
if (!kioskMode()) return;
const onKeyDown = (event: KeyboardEvent) => {
- if (event.key === 'Escape') {
- toggleKioskMode();
+ if (event.key !== 'Escape') return;
+ if (!hasSettingsAccess()) {
+ // A kiosk-token session cannot exit kiosk: setKioskMode(false) is sticky
+ // for the rest of the session and would strand the display on chrome it
+ // has no authority to use. Give it the same temporary header peek the
+ // hover and touch affordances give instead.
+ showHeader();
+ scheduleHideHeader(3000);
+ return;
}
+ toggleKioskMode();
};
window.addEventListener('keydown', onKeyDown);
onCleanup(() => window.removeEventListener('keydown', onKeyDown));
});
createEffect(() => {
- if (!kioskMode()) return;
+ // Kiosk hides the navigation, but the redirect is not a kiosk decoration:
+ // a session whose token cannot read settings must stay off these routes
+ // whether or not kiosk is currently on (#1650).
+ if (!kioskMode() && hasSettingsAccess()) return;
const normalizedPath = location.pathname.replace(/\/+$/, '') || '/';
const blockedPrefixes = ['/settings', '/patrol'];
const isBlocked = blockedPrefixes.some(
@@ -504,10 +534,6 @@ export function AppLayout(props: AppLayoutProps) {
);
const activeAlertCount = breakdown.warning + breakdown.critical;
- const scopes = props.tokenScopes();
- const hasSettingsAccess =
- !scopes || scopes.length === 0 || scopes.includes('*') || scopes.includes('settings:read');
-
const tabs: UtilityTab[] = [
{
id: 'alerts',
@@ -543,7 +569,7 @@ export function AppLayout(props: AppLayoutProps) {
},
];
- if (hasSettingsAccess) {
+ if (hasSettingsAccess()) {
tabs.push({
id: 'settings',
label: 'Settings',
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index 705a9e0bd2..50f561102a 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -102,7 +102,9 @@ describe('App platform navigation admission', () => {
describe('App architecture', () => {
it('keeps App as the entry shell that delegates runtime and chrome ownership', () => {
- expect(appSource).toContain("import { AppLayout } from '@/AppLayout';");
+ expect(appSource).toContain(
+ "import { AppLayout, sessionHasSettingsAccess } from '@/AppLayout';",
+ );
expect(appSource).toContain("import { aiChatStore } from './stores/aiChat';");
expect(appSource).toContain(
"import { DarkModeContext, WebSocketContext, useWebSocket } from '@/contexts/appRuntime';",
@@ -293,6 +295,31 @@ describe('App architecture', () => {
expect(appSource).not.toContain('monitoredSystemLimitWarningBanner');
});
+ it('Issue1650 keeps kiosk-scoped sessions off settings chrome in the shell', () => {
+ // ESC used to call toggleKioskMode() unconditionally, and setKioskMode(false)
+ // is sticky for the rest of the session, so a kiosk display could be walked
+ // out of kiosk and into settings-linked chrome it has no authority to use.
+ expect(appLayoutSource).toContain('export function sessionHasSettingsAccess(');
+ expect(appLayoutSource).toContain(
+ 'const hasSettingsAccess = createMemo(() => sessionHasSettingsAccess(props.tokenScopes()));',
+ );
+ expect(appLayoutSource).toContain("if (event.key !== 'Escape') return;");
+ expect(appLayoutSource).toContain('if (!hasSettingsAccess()) {');
+ expect(appLayoutSource).toContain('scheduleHideHeader(3000);');
+ expect(appLayoutSource).not.toContain(
+ "if (event.key === 'Escape') {\n toggleKioskMode();",
+ );
+ // The blocked-route guard is an authority rule, not kiosk decoration.
+ expect(appLayoutSource).toContain('if (!kioskMode() && hasSettingsAccess()) return;');
+ expect(appLayoutSource).toContain("const blockedPrefixes = ['/settings', '/patrol'];");
+ // Banners in the shell deep-link into settings, so they follow the same rule.
+ expect(appSource).toContain('<Show when={!kioskMode() && hasSettingsAccess()}>');
+ expect(appSource).toContain(
+ 'const hasSettingsAccess = createMemo(() =>\n sessionHasSettingsAccess(runtime.securityStatus()?.tokenScopes),\n );',
+ );
+ expect(appSource).not.toContain("scopes.includes('settings:read')");
+ });
+
it('keeps the update progress watcher aligned with the backend updater stages', () => {
// The in-progress stage list must mirror internal/updates/manager.go
// updateStatus emissions, including the rollback path's restoring stage,
diff --git a/frontend-modern/src/__tests__/AppLayout.test.tsx b/frontend-modern/src/__tests__/AppLayout.test.tsx
index e876fb6477..c2fe1923d9 100644
--- a/frontend-modern/src/__tests__/AppLayout.test.tsx
+++ b/frontend-modern/src/__tests__/AppLayout.test.tsx
@@ -3,7 +3,12 @@ import { Route, Router, useNavigate } from '@solidjs/router';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { State } from '@/types/api';
import type { Resource } from '@/types/resource';
-import { AppLayout, resetPrimaryNavigationRouteMemory } from '@/AppLayout';
+import {
+ AppLayout,
+ resetPrimaryNavigationRouteMemory,
+ sessionHasSettingsAccess,
+} from '@/AppLayout';
+import { isKioskMode, setKioskMode } from '@/utils/url';
import type { PlatformNavigationVisibility } from '@/features/platformNavigation/platformNavigationModel';
import { aiChatStore } from '@/stores/aiChat';
@@ -26,6 +31,87 @@ vi.mock('@/routing/routePreload', () => ({
preloadRouteModule: vi.fn(() => Promise.resolve()),
}));
+const makeResource = (overrides: Partial<Resource>): Resource =>
+ ({
+ id: overrides.id ?? 'resource-1',
+ name: overrides.name ?? overrides.id ?? 'resource-1',
+ displayName: overrides.displayName ?? overrides.name ?? overrides.id ?? 'resource-1',
+ type: overrides.type ?? 'agent',
+ platformId: overrides.platformId ?? 'platform-1',
+ platformType: overrides.platformType ?? 'agent',
+ sourceType: overrides.sourceType ?? 'api',
+ status: overrides.status ?? 'online',
+ lastSeen: overrides.lastSeen ?? 1_700_000_000_000,
+ ...overrides,
+ }) as Resource;
+
+const renderLayout = (
+ resources: Resource[] = [],
+ initialPath = '/settings/infrastructure',
+ platformVisibility?: PlatformNavigationVisibility,
+ tokenScopes: string[] = ['settings:read'],
+) => {
+ window.history.replaceState({}, '', initialPath);
+ const RouteStateProbe = () => {
+ const navigate = useNavigate();
+ return (
+ <button
+ type="button"
+ onClick={() => navigate('/proxmox/overview?status=running', { replace: true })}
+ >
+ Set Proxmox running filter
+ </button>
+ );
+ };
+ const LayoutRoute = () => (
+ <AppLayout
+ connectionStatus={() => ({
+ kind: 'connected',
+ label: 'Connected',
+ detail: 'Backend and live data stream are connected.',
+ tone: 'healthy',
+ })}
+ lastUpdateText={() => ''}
+ versionInfo={() =>
+ ({
+ version: '6.0.0-rc.2',
+ channel: 'rc',
+ isDevelopment: false,
+ isDocker: false,
+ }) as never
+ }
+ hasAuth={() => true}
+ needsAuth={() => false}
+ proxyAuthInfo={() => null}
+ handleLogout={() => {}}
+ state={() =>
+ ({
+ activeAlerts: [{ id: 'alert-1', level: 'warning', acknowledged: false }],
+ resources,
+ }) as unknown as State
+ }
+ platformVisibility={platformVisibility ? () => platformVisibility : undefined}
+ tokenScopes={() => tokenScopes}
+ organizations={() => []}
+ activeOrgID={() => 'default'}
+ orgsLoading={() => false}
+ showOrgSwitcher={() => false}
+ onSwitchOrg={() => {}}
+ >
+ <div>Infrastructure body</div>
+ <RouteStateProbe />
+ </AppLayout>
+ );
+ return render(() => (
+ <Router>
+ <Route path="/settings/infrastructure" component={LayoutRoute} />
+ <Route path="/proxmox/overview" component={LayoutRoute} />
+ <Route path="/docker/overview" component={LayoutRoute} />
+ <Route path="/alerts" component={LayoutRoute} />
+ </Router>
+ ));
+};
+
describe('AppLayout navigation icons', () => {
beforeEach(() => {
window.history.replaceState({}, '', '/settings/infrastructure');
@@ -41,85 +127,6 @@ describe('AppLayout navigation icons', () => {
cleanup();
});
- const makeResource = (overrides: Partial<Resource>): Resource =>
- ({
- id: overrides.id ?? 'resource-1',
- name: overrides.name ?? overrides.id ?? 'resource-1',
- displayName: overrides.displayName ?? overrides.name ?? overrides.id ?? 'resource-1',
- type: overrides.type ?? 'agent',
- platformId: overrides.platformId ?? 'platform-1',
- platformType: overrides.platformType ?? 'agent',
- sourceType: overrides.sourceType ?? 'api',
- status: overrides.status ?? 'online',
- lastSeen: overrides.lastSeen ?? 1_700_000_000_000,
- ...overrides,
- }) as Resource;
-
- const renderLayout = (
- resources: Resource[] = [],
- initialPath = '/settings/infrastructure',
- platformVisibility?: PlatformNavigationVisibility,
- ) => {
- window.history.replaceState({}, '', initialPath);
- const RouteStateProbe = () => {
- const navigate = useNavigate();
- return (
- <button
- type="button"
- onClick={() => navigate('/proxmox/overview?status=running', { replace: true })}
- >
- Set Proxmox running filter
- </button>
- );
- };
- const LayoutRoute = () => (
- <AppLayout
- connectionStatus={() => ({
- kind: 'connected',
- label: 'Connected',
- detail: 'Backend and live data stream are connected.',
- tone: 'healthy',
- })}
- lastUpdateText={() => ''}
- versionInfo={() =>
- ({
- version: '6.0.0-rc.2',
- channel: 'rc',
- isDevelopment: false,
- isDocker: false,
- }) as never
- }
- hasAuth={() => true}
- needsAuth={() => false}
- proxyAuthInfo={() => null}
- handleLogout={() => {}}
- state={() =>
- ({
- activeAlerts: [{ id: 'alert-1', level: 'warning', acknowledged: false }],
- resources,
- }) as unknown as State
- }
- platformVisibility={platformVisibility ? () => platformVisibility : undefined}
- tokenScopes={() => ['settings:read']}
- organizations={() => []}
- activeOrgID={() => 'default'}
- orgsLoading={() => false}
- showOrgSwitcher={() => false}
- onSwitchOrg={() => {}}
- >
- <div>Infrastructure body</div>
- <RouteStateProbe />
- </AppLayout>
- );
- return render(() => (
- <Router>
- <Route path="/settings/infrastructure" component={LayoutRoute} />
- <Route path="/proxmox/overview" component={LayoutRoute} />
- <Route path="/docker/overview" component={LayoutRoute} />
- </Router>
- ));
- };
-
const getInfrastructureTab = (name: string) => {
const desktopNav = screen.getByRole('tablist', { name: 'Primary navigation' });
const infrastructureGroup = desktopNav.querySelector('[aria-label="Infrastructure"]');
@@ -370,3 +377,102 @@ describe('AppLayout navigation icons', () => {
});
});
});
+
+describe('AppLayout Issue1650 kiosk scope containment', () => {
+ const KIOSK_TOKEN_SCOPES = ['monitoring:read'];
+ const DOCKER_ONLY_VISIBILITY: PlatformNavigationVisibility = {
+ proxmox: false,
+ docker: true,
+ kubernetes: false,
+ truenas: false,
+ vmware: false,
+ standalone: false,
+ };
+
+ const header = (container: HTMLElement) => container.querySelector('.header') as HTMLElement;
+ const headerIsRevealed = (container: HTMLElement) =>
+ header(container).style.transform === 'translateY(0)';
+
+ beforeEach(() => {
+ window.history.replaceState({}, '', '/settings/infrastructure');
+ resetPrimaryNavigationRouteMemory();
+ patrolAttentionMockState.activeCount = 0;
+ aiChatStore.close();
+ aiChatStore.setEnabled(false);
+ });
+
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ setKioskMode(false);
+ window.sessionStorage.clear();
+ });
+
+ it('treats a monitoring-only token as having no settings access', () => {
+ expect(sessionHasSettingsAccess(KIOSK_TOKEN_SCOPES)).toBe(false);
+ expect(sessionHasSettingsAccess(['monitoring:read', 'settings:read'])).toBe(true);
+ expect(sessionHasSettingsAccess(['*'])).toBe(true);
+ expect(sessionHasSettingsAccess([])).toBe(true);
+ expect(sessionHasSettingsAccess(undefined)).toBe(true);
+ });
+
+ it('keeps kiosk on and peeks the header when a kiosk token presses Escape', () => {
+ vi.useFakeTimers();
+ setKioskMode(true);
+ const { container } = renderLayout(
+ [],
+ '/docker/overview',
+ DOCKER_ONLY_VISIBILITY,
+ KIOSK_TOKEN_SCOPES,
+ );
+
+ // Kiosk shows the header briefly on entry, then hides it.
+ vi.advanceTimersByTime(2000);
+ expect(headerIsRevealed(container)).toBe(false);
+
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
+
+ expect(isKioskMode()).toBe(true);
+ expect(screen.queryByRole('tablist', { name: 'Primary navigation' })).toBeNull();
+ expect(headerIsRevealed(container)).toBe(true);
+
+ // The peek is temporary, exactly like the hover and touch affordances.
+ vi.advanceTimersByTime(3500);
+ expect(headerIsRevealed(container)).toBe(false);
+ expect(isKioskMode()).toBe(true);
+ });
+
+ it('still exits kiosk on Escape for a session that can reach settings', () => {
+ setKioskMode(true);
+ renderLayout([], '/docker/overview', DOCKER_ONLY_VISIBILITY, ['settings:read']);
+
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
+
+ expect(isKioskMode()).toBe(false);
+ expect(screen.getByRole('tablist', { name: 'Primary navigation' })).toBeTruthy();
+ });
+
+ it('redirects a scope-limited session away from settings even when kiosk is off', async () => {
+ setKioskMode(false);
+ renderLayout([], '/settings/infrastructure', DOCKER_ONLY_VISIBILITY, KIOSK_TOKEN_SCOPES);
+
+ expect(isKioskMode()).toBe(false);
+ await waitFor(() => {
+ expect(window.location.pathname).toBe('/docker/overview');
+ });
+ const systemGroup = screen
+ .getByRole('tablist', { name: 'Primary navigation' })
+ .querySelector('[aria-label="System"]');
+ expect(within(systemGroup as HTMLElement).queryByRole('tab', { name: 'Settings' })).toBeNull();
+ });
+
+ it('leaves settings reachable with kiosk off for a session that has settings access', async () => {
+ setKioskMode(false);
+ renderLayout([], '/settings/infrastructure', DOCKER_ONLY_VISIBILITY, ['settings:read']);
+
+ await waitFor(() => {
+ expect(screen.getByRole('tablist', { name: 'Primary navigation' })).toBeTruthy();
+ });
+ expect(window.location.pathname).toBe('/settings/infrastructure');
+ });
+});
diff --git a/frontend-modern/src/components/SecurityWarning.tsx b/frontend-modern/src/components/SecurityWarning.tsx
index e898719ae4..a64d12737b 100644
--- a/frontend-modern/src/components/SecurityWarning.tsx
+++ b/frontend-modern/src/components/SecurityWarning.tsx
@@ -11,11 +11,13 @@ import {
getSecurityScoreTextClass,
getSecurityWarningPresentation,
shouldShowGlobalSecurityWarning,
+ type SecurityStatusDetailLevel,
} from '@/utils/securityScorePresentation';
import type { SecurityStatus } from '@/types/config';
interface SecurityState {
+ detailLevel?: SecurityStatusDetailLevel;
hasAuthentication: boolean;
hasHTTPS: boolean;
hasAPIToken: boolean;
@@ -62,6 +64,9 @@ export const SecurityWarning: Component = () => {
if (data.hasAuthentication) score++;
setStatus({
+ // Carried through so the banner can tell a real posture from a payload
+ // the server truncated for this caller's authority (#1650).
+ detailLevel: data.detailLevel,
hasAuthentication: data.hasAuthentication || false,
hasHTTPS: runningOverHttps,
hasAPIToken: data.apiTokenConfigured || false,
@@ -100,6 +105,7 @@ export const SecurityWarning: Component = () => {
if (!currentStatus) return false;
return shouldShowGlobalSecurityWarning({
+ detailLevel: currentStatus.detailLevel,
hasAuthentication: currentStatus.hasAuthentication,
exportProtected: currentStatus.exportProtected,
hasHTTPS: currentStatus.hasHTTPS,
diff --git a/frontend-modern/src/components/__tests__/SecurityWarning.test.tsx b/frontend-modern/src/components/__tests__/SecurityWarning.test.tsx
index c2539a7d37..569e4fecf7 100644
--- a/frontend-modern/src/components/__tests__/SecurityWarning.test.tsx
+++ b/frontend-modern/src/components/__tests__/SecurityWarning.test.tsx
@@ -87,4 +87,54 @@ describe('SecurityWarning', () => {
'/docs/SECURITY.md',
);
});
+
+ it('Issue1650 renders nothing for a status payload truncated below privileged', async () => {
+ const pendingStatus = deferred<any>();
+ apiFetchJSONMock.mockReturnValue(pendingStatus.promise);
+
+ const { SecurityWarning } = await import('../SecurityWarning');
+ render(() => <SecurityWarning />);
+
+ // What a kiosk token (monitoring:read only) actually receives: identity
+ // fields, and none of the posture fields the score is computed from.
+ pendingStatus.resolve({
+ detailLevel: 'authenticated',
+ hasAuthentication: true,
+ requiresAuth: true,
+ tokenScopes: ['monitoring:read'],
+ });
+
+ await waitFor(() => {
+ expect(apiFetchJSONMock).toHaveBeenCalled();
+ });
+
+ expect(screen.queryByRole('status')).not.toBeInTheDocument();
+ expect(screen.queryByText(/Security score:/i)).not.toBeInTheDocument();
+ expect(screen.queryByRole('link', { name: /Enable Security/i })).not.toBeInTheDocument();
+ });
+
+ it('Issue1650 still warns a privileged payload that genuinely lacks export protection', async () => {
+ const pendingStatus = deferred<any>();
+ apiFetchJSONMock.mockReturnValue(pendingStatus.promise);
+
+ const { SecurityWarning } = await import('../SecurityWarning');
+ render(() => <SecurityWarning />);
+
+ pendingStatus.resolve({
+ detailLevel: 'privileged',
+ apiTokenConfigured: false,
+ credentialsEncrypted: true,
+ exportProtected: false,
+ hasAuditLogging: false,
+ hasAuthentication: true,
+ hasHTTPS: true,
+ publicAccess: false,
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText(/Security score:/i)).toBeInTheDocument();
+ });
+
+ expect(screen.getByRole('link', { name: /Enable Security/i })).toBeInTheDocument();
+ });
});
diff --git a/frontend-modern/src/utils/__tests__/securityScorePresentation.test.ts b/frontend-modern/src/utils/__tests__/securityScorePresentation.test.ts
index 042bb701d0..048a2e9e6c 100644
--- a/frontend-modern/src/utils/__tests__/securityScorePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/securityScorePresentation.test.ts
@@ -297,3 +297,71 @@ describe('securityScorePresentation', () => {
).toBe('Private network access');
});
});
+
+describe('Issue1650 truncated security status must not raise the global warning', () => {
+ // /api/security/status truncates its payload by authority. A kiosk API token
+ // (monitoring:read only) gets detailLevel 'authenticated' with no posture
+ // fields at all, which used to read as "exports unprotected" and produced a
+ // false 1/5 security banner linking into settings the token cannot open.
+ const truncatedKioskPayload = {
+ detailLevel: 'authenticated' as const,
+ hasAuthentication: true,
+ exportProtected: false,
+ hasHTTPS: false,
+ publicAccess: false,
+ };
+
+ it('stays silent for an authenticated-but-unprivileged payload', () => {
+ expect(shouldShowGlobalSecurityWarning(truncatedKioskPayload)).toBe(false);
+ });
+
+ it('stays silent for an authenticated payload that looks publicly exposed', () => {
+ expect(
+ shouldShowGlobalSecurityWarning({
+ ...truncatedKioskPayload,
+ publicAccess: true,
+ }),
+ ).toBe(false);
+ });
+
+ it('still warns an unauthenticated instance from its public payload', () => {
+ expect(
+ shouldShowGlobalSecurityWarning({
+ detailLevel: 'public',
+ hasAuthentication: false,
+ exportProtected: false,
+ }),
+ ).toBe(true);
+ });
+
+ it('does not invent posture debt from a public payload that has authentication', () => {
+ expect(
+ shouldShowGlobalSecurityWarning({
+ detailLevel: 'public',
+ hasAuthentication: true,
+ exportProtected: false,
+ }),
+ ).toBe(false);
+ });
+
+ it('keeps the full assessment for a privileged payload', () => {
+ expect(
+ shouldShowGlobalSecurityWarning({
+ detailLevel: 'privileged',
+ hasAuthentication: true,
+ exportProtected: false,
+ hasHTTPS: true,
+ publicAccess: false,
+ }),
+ ).toBe(true);
+ expect(
+ shouldShowGlobalSecurityWarning({
+ detailLevel: 'privileged',
+ hasAuthentication: true,
+ exportProtected: true,
+ hasHTTPS: true,
+ publicAccess: false,
+ }),
+ ).toBe(false);
+ });
+});
diff --git a/frontend-modern/src/utils/securityScorePresentation.ts b/frontend-modern/src/utils/securityScorePresentation.ts
index 0549e41392..f9ff8611ca 100644
--- a/frontend-modern/src/utils/securityScorePresentation.ts
+++ b/frontend-modern/src/utils/securityScorePresentation.ts
@@ -26,7 +26,18 @@ export interface SecurityWarningPresentation {
messageClass: string;
}
+/**
+ * How much of the security posture `/api/security/status` was willing to tell
+ * this caller. The endpoint truncates by authority: `public` carries login
+ * discovery and authentication state only, `authenticated` adds session
+ * identity but still no posture fields, and only `privileged` (settings:read)
+ * carries exportProtected, apiTokenConfigured, hasHTTPS, publicAccess and the
+ * rest.
+ */
+export type SecurityStatusDetailLevel = 'public' | 'authenticated' | 'privileged';
+
export interface SecurityRuntimeWarningVisibilityOptions {
+ detailLevel?: SecurityStatusDetailLevel;
hasAuthentication: boolean;
exportProtected: boolean;
hasHTTPS?: boolean;
@@ -192,13 +203,37 @@ export function getSecurityWarningPresentation(options: {
};
}
+/**
+ * The global banner may only be raised from fields the payload actually
+ * carries. A truncated response omits the posture fields entirely, and reading
+ * an absent field as `false` is how a kiosk token (monitoring:read only) was
+ * shown a bogus "security score 1/5" banner linking into settings it cannot
+ * open (#1650).
+ *
+ * - `authenticated`: no posture fields at all, so nothing can be asserted.
+ * - `public`: only `hasAuthentication` is authoritative, which is exactly the
+ * case that matters — an instance with no authentication configured must
+ * still be warned about.
+ * - `privileged` (or a caller supplying the full posture directly): full
+ * assessment.
+ */
export function shouldShowGlobalSecurityWarning(
options: SecurityRuntimeWarningVisibilityOptions,
): boolean {
+ const detailLevel = options.detailLevel ?? 'privileged';
+
+ if (detailLevel === 'authenticated') {
+ return false;
+ }
+
if (!options.hasAuthentication) {
return true;
}
+ if (detailLevel === 'public') {
+ return false;
+ }
+
if (!options.exportProtected) {
return true;
}