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.

fix(settings): gate all admin-only panels

rcourtman7a0f41050882
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index a99b3ad05f..21593103ba 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -5997,6 +5997,15 @@ than the new field — the two are siblings precisely so neither page's gate can
be moved by a change aimed at the other. The api-contracts entry holds the
authoritative description and its proof.
+The same security-status payload now includes the additive
+`availabilityRead`, `pulseIntelligenceRead`, `diagnosticsRead`,
+`systemLogsRead`, and `reportingRead` fields. This is recorded because
+`internal/api/` is an Extension Point here; none of the fields changes an agent
+route, enrollment contract, report payload, capability manifest, or lifecycle
+decision. Agent-facing code must not infer any of these browser Settings grants
+from agent credentials. The api-contracts contract owns their predicates and
+proof.
+
### API-layer refusal logging moved to debug
`internal/api/` is a canonical reference in this contract's Extension Points, so
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f1b55530a5..d7497b1e11 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -9098,3 +9098,32 @@ receiving 200 from the runtime route while still receiving 403 from the admin
route. `TestHandleGetRuntimeDisplay_PublishesOnlyPresentationFields` pins the
serialized whitelist, and the frontend bootstrap tests pin that
`useAppRuntimeState` never calls `getSystemSettings()`.
+
+### Security status names every admin-only Settings panel capability
+
+The authenticated `GET /api/security/status` payload also carries five
+additive, fail-closed capabilities for Settings panels that read privileged
+routes on mount:
+
+- `availabilityRead` mirrors `RequireAdmin` + `settings:read` on
+ `/api/availability-targets`;
+- `diagnosticsRead` mirrors the same pair on `/api/diagnostics`;
+- `systemLogsRead` mirrors the pair on `/api/logs/level`, `/api/logs/stream`,
+ and `/api/logs/download`;
+- `pulseIntelligenceRead` combines the handler's settings-admin/scope check
+ with `RequirePermission(read, settings)` from `/api/settings/ai`;
+- `reportingRead` combines `ensureAdminSession`, `settings:read`, and
+ `RequirePermission(read, nodes)` from `/api/admin/reports/catalog`.
+
+Those last two must not collapse to `canReadSettings`: a custom authorizer can
+deny the route even when the caller has the settings scope. Reporting's
+`advanced_reporting` entitlement stays separate; the catalog is intentionally
+available without it so an authorized administrator can see the inline upgrade
+state, while a non-admin cannot reach the reporting surface at all.
+
+`TestContract_SecurityStatusAdminOnlySettingsCapabilitiesTrackMountRoutes`
+pins the settings-scope grant and refusal against each unconditional mount
+route. `TestContract_SecurityStatusPermissionedSettingsCapabilitiesIncludeRouteAuthorization`
+pins the extra authorizer predicates, and
+`TestSettingsCapabilitiesMatchRouteEnforcementWithoutRBAC` proves that a
+non-admin browser session receives both false capabilities and matching 403s.
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index ada4f93ff3..ce9861161f 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -5848,12 +5848,30 @@ which pins the withheld, granted, and unresolved cases plus the
Because `DEFAULT_SETTINGS_TAB` *is* `infrastructure-systems`, the blocked-route
fallback in `useSettingsAccess.ts` can no longer resolve to the constant — that
-sent a refused session straight back to the tab that had just refused it. It now
-falls back to `flatTabs()[0]`, the first tab the session can actually reach, and
-only uses `DEFAULT_SETTINGS_TAB` when no tab resolves at all.
+sent a refused session straight back to the tab that had just refused it. The
+fallback uses an explicit preference order: the default when reachable, then
+the user-scoped `system-general` tab, and only then the first remaining route.
+Catalog order is not a safety policy; after the admin-only routes are removed it
+can otherwise land a viewer on Plans, an upgrade surface they cannot administer.
+
+The capability rule also covers every remaining panel whose mount read is
+admin-only: Availability checks, all three Pulse Intelligence tabs, Diagnostics
+& Health, Data & Reports, and System Logs declare their own named capability.
+Data & Reports keeps its independent `advanced_reporting` feature gate because
+feature discovery and administrative reachability answer different questions.
+
+Navigation remains stable while `/api/security/status` is loading, but
+`canMountSettingsPanel` refuses to instantiate a capability-gated panel until
+the exact named capability is `true`. A failed or incomplete status response is
+a resolved denial: the route is removed and the fallback selects General. This
+prevents first-paint panel fetches from racing the capability request while
+keeping a successful status usable during later refreshes.
Pinned by the `infrastructure-systems` block assertion in
`settingsArchitecture.test.ts` and by
`__tests__/infrastructureNavCapabilityGate.test.ts`, which also pins that
neither gate fires before the security status resolves — hiding on an
unresolved status would flash the default tab away from an admin on every load.
+`__tests__/adminOnlySettingsNavGates.test.ts` and
+`__tests__/useSettingsAccess.test.tsx` pin the complete named-capability,
+fail-closed mount, failed-status, deduplicated-load, and General-fallback rules.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index d3374563f2..34220f3466 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -5074,6 +5074,15 @@ surface that finds the capability withheld must present an access state and
must not record the skipped fetch as coverage loss or mutate recovery
freshness from it.
+The payload also gained `availabilityRead`, `pulseIntelligenceRead`,
+`diagnosticsRead`, `systemLogsRead`, and `reportingRead`. They are request-time
+authorization projections only: no capability is persisted and none changes a
+storage, backup, recovery, retention, or report artifact. In particular,
+`reportingRead` gates whether the Data & Reports panel may mount; it does not
+grant `advanced_reporting`, create a schedule, or imply that any generated
+artifact exists. The api-contracts entry owns the authoritative predicate and
+route proof.
+
### API-layer refusal logging moved to debug
`internal/api/` is a canonical reference in this contract's Extension Points.
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index 839e0bc37d..750b629ba7 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,23 +1,31 @@
{
"version": 1,
- "base_sha": "fbee92614a1a837d811e533eaf47d722db4ff71f",
- "verified_at": "2026-08-08T00:05:39Z",
+ "base_sha": "ff03168e5eec670822fcd0a5315cf84f6ac74bd1",
+ "verified_at": "2026-08-08T00:17:09Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/api/settings.ts",
- "frontend-modern/src/stores/systemSettings.ts",
- "frontend-modern/src/useAppRuntimeState.ts",
- "frontend-modern/src/utils/layout.ts"
+ "frontend-modern/src/components/Settings/Settings.tsx",
+ "frontend-modern/src/components/Settings/settingsNavCatalog.ts",
+ "frontend-modern/src/components/Settings/settingsNavVisibility.ts",
+ "frontend-modern/src/components/Settings/useSettingsAccess.ts",
+ "frontend-modern/src/types/config.ts"
],
"content_sha256": {
- "frontend-modern/src/api/settings.ts": "74ba64f4854a293a79d8339271ff442846121fdd9046ff873ff0abf2e72a1f79",
- "frontend-modern/src/stores/systemSettings.ts": "fdb3e8bbe05854f528d873a2181916bd1014f8f48e131353f39de1f2a105ec71",
- "frontend-modern/src/useAppRuntimeState.ts": "4cb1c3b50f1ad611299cf294363d3b36f8e88de99a581bb3478f4737a4fbf489",
- "frontend-modern/src/utils/layout.ts": "d82536f0e7d2ea135d0d92a882942db15eded5f78fdea34818b04bd9dfa81fbc"
+ "frontend-modern/src/components/Settings/Settings.tsx": "3053ee87a22ed5eecff3f9edac20260c23b5f6a48c80ce2ff592ff74b8687da2",
+ "frontend-modern/src/components/Settings/settingsNavCatalog.ts": "4bed8aa881bc59af56119e079ed97dc23ac9d983e227f3f0d4877e3ae3d20d04",
+ "frontend-modern/src/components/Settings/settingsNavVisibility.ts": "eefa115abc68f9b9f636eb105bbd1b71c529ec9f731bb4eb6de785c26eae2c83",
+ "frontend-modern/src/components/Settings/useSettingsAccess.ts": "895b74346f56e10f0a21fc2e808cf098a9b956da262b3b73ba067b46c30b8339",
+ "frontend-modern/src/types/config.ts": "9dc0faa8e9b41eab526245aae72e447535709108c0b109c76545ab73500a2588"
},
"routes": [
- "/",
- "/api/runtime/display"
+ "/settings",
+ "/settings/monitoring/availability",
+ "/settings/pulse-intelligence/provider",
+ "/settings/pulse-intelligence/patrol",
+ "/settings/pulse-intelligence/assistant",
+ "/settings/support/diagnostics",
+ "/settings/support/reporting",
+ "/settings/support/logs"
],
"viewports": [
{
@@ -25,19 +33,23 @@
"height": 800
},
{
- "width": 375,
+ "width": 390,
"height": 812
}
],
"states": [
- "Fresh isolated backend returned the configured authenticated runtime projection with fullWidthMode=true, disableDockerUpdateActions=true, and reduceProUpsellNoise=true.",
- "Authenticated desktop bootstrap rendered the current embedded build at 1280x800 with the full shell, 1280px document width, and no console errors.",
- "Authenticated narrow bootstrap rendered the current embedded build at 375x812 with the mobile shell and document scroll width equal to the 375px viewport."
+ "Real proxy-auth viewer at 1280x800: /settings settled on /settings/system-general, the General panel rendered, and the Settings navigation contained only Plans & Billing, General, and Security Overview; Availability checks, Provider & Models, Patrol, Assistant, Diagnostics & Health, Data & Reports, and System Logs were absent.",
+ "Same viewer from each named admin-only deep link: all seven routes settled on /settings/system-general. An instrumented proxy recorded an empty request list for /api/availability-targets, /api/settings/ai*, /api/diagnostics*, /api/admin/reports*, and /api/logs*, proving the panels did not mount during first paint or fallback.",
+ "Real proxy-auth administrator at 1280x800: all seven navigation entries remained visible; opening each rendered its expected heading at its canonical route. security/status returned all five named capabilities true, and the representative read routes returned 200.",
+ "Viewer at 390x812: /settings again settled on General; the opened mobile Settings drawer contained only Plans & Billing, General, and Security Overview, and document scroll width equalled the 390px viewport.",
+ "Administrator at 390x812: /settings/support/logs rendered the System Logs panel, and document scroll width equalled the 390px viewport."
],
"interactions": [
- "Built the production frontend and launched the current backend on an isolated local port and temporary data directory so concurrent audit-repair runtimes were untouched.",
- "Configured the four-field runtime display response through the admin-only update route, then read GET /api/runtime/display and confirmed the explicit projection values.",
- "Signed in to the isolated current build, reloaded after the server display settings were active, and inspected authenticated shell state at desktop and narrow viewports.",
- "Read the desktop console errors and confirmed none were emitted."
+ "Built the current production frontend embed and current backend binary, then ran them on isolated localhost ports behind disposable viewer and administrator proxy-auth identities.",
+ "Loaded /settings as the viewer, inspected the desktop navigation and General panel, then loaded every named admin-only deep link and checked its settled URL.",
+ "Captured protected API-family requests in the viewer proxy while exercising /settings and all seven direct deep links; the captured list remained empty.",
+ "Loaded /settings as the administrator and clicked Availability checks, Provider & Models, Patrol, Assistant, Diagnostics & Health, Data & Reports, and System Logs, checking each canonical URL and rendered page heading.",
+ "Loaded the viewer at 390x812, opened the mobile Settings drawer, inspected its entries and horizontal overflow, then loaded System Logs as the administrator at the same viewport and checked its rendered heading and overflow.",
+ "Read the administrator security-status capability projection and representative protected read routes as a backend A/B control; all five capabilities were true and all five routes returned 200."
]
}
diff --git a/frontend-modern/src/components/Settings/Settings.tsx b/frontend-modern/src/components/Settings/Settings.tsx
index 67450dd25d..d738c9da9e 100644
--- a/frontend-modern/src/components/Settings/Settings.tsx
+++ b/frontend-modern/src/components/Settings/Settings.tsx
@@ -26,6 +26,7 @@ import { useSystemSettingsState } from './useSystemSettingsState';
import { useSettingsNavigation } from './useSettingsNavigation';
import { getSettingsLoadingState } from '@/utils/settingsShellPresentation';
import { isRouteableSettingsLocation } from './settingsNavigationModel';
+import { canMountSettingsPanel } from './settingsNavVisibility';
import NotFound from '@/pages/NotFound';
import { getRuntimeLimit, loadRuntimeCapabilities } from '@/stores/license';
@@ -155,6 +156,12 @@ const SettingsWorkspace: Component<SettingsProps> = (props) => {
});
const activeSettingsPanelEntry = createMemo(() => {
const currentTab = activeTab();
+ // Panels fetch on mount. A capability-gated panel therefore mounts only
+ // after the server has explicitly granted its named capability; unresolved,
+ // failed, missing, and denied states all stay closed.
+ if (!canMountSettingsPanel(currentTab, securityStatus()?.settingsCapabilities)) {
+ return null;
+ }
if (!flatTabs().some((tab) => tab.id === currentTab)) {
return null;
}
diff --git a/frontend-modern/src/components/Settings/__tests__/adminOnlySettingsNavGates.test.ts b/frontend-modern/src/components/Settings/__tests__/adminOnlySettingsNavGates.test.ts
new file mode 100644
index 0000000000..051adcbd12
--- /dev/null
+++ b/frontend-modern/src/components/Settings/__tests__/adminOnlySettingsNavGates.test.ts
@@ -0,0 +1,101 @@
+import { describe, expect, it } from 'vitest';
+import { SETTINGS_NAV_GROUPS, getSettingsNavItem } from '../settingsNavCatalog';
+import type { SettingsTab } from '../settingsNavigationModel';
+import {
+ canMountSettingsPanel,
+ shouldBlockSettingsRouteItem,
+ shouldHideSettingsNavItem,
+ type SettingsNavVisibilityContext,
+} from '../settingsNavVisibility';
+
+const ADMIN_ONLY_TABS: ReadonlyArray<{
+ tab: SettingsTab;
+ capability: keyof NonNullable<SettingsNavVisibilityContext['settingsCapabilities']>;
+}> = [
+ { tab: 'monitoring-availability', capability: 'availabilityRead' },
+ { tab: 'system-ai', capability: 'pulseIntelligenceRead' },
+ { tab: 'system-ai-patrol', capability: 'pulseIntelligenceRead' },
+ { tab: 'system-ai-assistant', capability: 'pulseIntelligenceRead' },
+ { tab: 'support-diagnostics', capability: 'diagnosticsRead' },
+ { tab: 'support-reporting', capability: 'reportingRead' },
+ { tab: 'support-logs', capability: 'systemLogsRead' },
+];
+
+const createContext = (
+ overrides: Partial<SettingsNavVisibilityContext> = {},
+): SettingsNavVisibilityContext => ({
+ hasFeature: () => true,
+ runtimeCapabilitiesLoaded: () => true,
+ hostedModeEnabled: false,
+ ...overrides,
+});
+
+describe('admin-only settings nav gates', () => {
+ it.each(ADMIN_ONLY_TABS)('$tab declares $capability', ({ tab, capability }) => {
+ expect(getSettingsNavItem(tab)?.requiredCapability).toBe(capability);
+ });
+
+ it.each(ADMIN_ONLY_TABS)(
+ '$tab is hidden, route-blocked, and unmountable when $capability is withheld',
+ ({ tab, capability }) => {
+ const settingsCapabilities = { [capability]: false };
+ const context = createContext({
+ settingsCapabilitiesResolved: true,
+ settingsCapabilities,
+ });
+
+ expect(shouldHideSettingsNavItem(tab, context)).toBe(true);
+ expect(shouldBlockSettingsRouteItem(tab, context)).toBe(true);
+ expect(canMountSettingsPanel(tab, settingsCapabilities)).toBe(false);
+ },
+ );
+
+ it.each(ADMIN_ONLY_TABS)(
+ '$tab remains reachable and mountable when $capability is granted',
+ ({ tab, capability }) => {
+ const settingsCapabilities = { [capability]: true };
+ const context = createContext({
+ settingsCapabilitiesResolved: true,
+ settingsCapabilities,
+ });
+
+ expect(shouldHideSettingsNavItem(tab, context)).toBe(false);
+ expect(shouldBlockSettingsRouteItem(tab, context)).toBe(false);
+ expect(canMountSettingsPanel(tab, settingsCapabilities)).toBe(true);
+ },
+ );
+
+ it.each(ADMIN_ONLY_TABS)(
+ '$tab cannot mount before capabilities resolve even though the nav avoids flashing',
+ ({ tab }) => {
+ const context = createContext({
+ settingsCapabilitiesResolved: false,
+ settingsCapabilities: null,
+ });
+
+ expect(shouldHideSettingsNavItem(tab, context)).toBe(false);
+ expect(shouldBlockSettingsRouteItem(tab, context)).toBe(false);
+ expect(canMountSettingsPanel(tab, null)).toBe(false);
+ },
+ );
+
+ it('keeps the user-scoped General panel mountable without a capability payload', () => {
+ expect(getSettingsNavItem('system-general')?.requiredCapability).toBeUndefined();
+ expect(canMountSettingsPanel('system-general', null)).toBe(true);
+ });
+
+ it('leaves General reachable after every admin-only capability is withheld', () => {
+ const withheld = createContext({
+ settingsCapabilitiesResolved: true,
+ settingsCapabilities: {},
+ hasFeature: () => false,
+ });
+ const reachable = SETTINGS_NAV_GROUPS.flatMap((group) => group.items)
+ .filter((item) => !shouldBlockSettingsRouteItem(item.id, withheld))
+ .map((item) => item.id);
+
+ expect(reachable).toContain('system-general');
+ expect(reachable).not.toContain('monitoring-availability');
+ expect(reachable).not.toContain('support-diagnostics');
+ });
+});
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 014a43dd5f..33b111d552 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -351,10 +351,36 @@ describe('settings architecture guardrails', () => {
// DEFAULT_SETTINGS_TAB points at the tab we just made blockable, so the
// fallback must resolve a reachable tab rather than the hardcoded default,
// or a non-admin lands back on the blocked route.
- expect(settingsAccessSource).toContain('const fallbackTab = flatTabs()[0]?.id');
+ expect(settingsAccessSource).toContain('SETTINGS_FALLBACK_TAB_ORDER.find(');
expect(settingsAccessSource).toContain('setActiveTab(fallbackTab)');
});
+ it('keeps capability-gated panels fail-closed before their routes resolve', () => {
+ expect(settingsSource).toContain(
+ 'canMountSettingsPanel(currentTab, securityStatus()?.settingsCapabilities)',
+ );
+ expect(settingsAccessSource).toContain('securityStatus() !== null || !securityStatusLoading()');
+ expect(settingsAccessSource).toContain("DEFAULT_SETTINGS_TAB,\n 'system-general'");
+ });
+
+ it('gates every remaining admin-only Settings panel on its named capability', () => {
+ const adminOnlyTabs: Array<[string, string]> = [
+ ['monitoring-availability', 'availabilityRead'],
+ ['system-ai', 'pulseIntelligenceRead'],
+ ['system-ai-patrol', 'pulseIntelligenceRead'],
+ ['system-ai-assistant', 'pulseIntelligenceRead'],
+ ['support-diagnostics', 'diagnosticsRead'],
+ ['support-reporting', 'reportingRead'],
+ ['support-logs', 'systemLogsRead'],
+ ];
+
+ for (const [tab, capability] of adminOnlyTabs) {
+ expect(settingsNavCatalogSource).toMatch(
+ new RegExp(`id: '${tab}',[\\s\\S]*?requiredCapability: '${capability}',`),
+ );
+ }
+ });
+
it('gates the admin-only System tabs on the served systemSettingsRead capability', () => {
// Same rationale as Infrastructure rather than the paid-feature one: a free
// install can act on a paid tab by upgrading, but a non-admin cannot grant
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx b/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx
index 965e70071f..dbd9b3628b 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/settingsNavigation.integration.test.tsx
@@ -179,6 +179,7 @@ describe('settingsNavigation integration scaffold', () => {
settingsCapabilities: {
auditLog: true,
auditWebhooksRead: true,
+ reportingRead: true,
relayRead: true,
roles: true,
users: true,
diff --git a/frontend-modern/src/components/Settings/__tests__/useSettingsAccess.test.tsx b/frontend-modern/src/components/Settings/__tests__/useSettingsAccess.test.tsx
index fec47d7b2c..33df1c0a1e 100644
--- a/frontend-modern/src/components/Settings/__tests__/useSettingsAccess.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useSettingsAccess.test.tsx
@@ -13,6 +13,7 @@ const presentationPolicyIsReadOnlyMock = vi.fn();
const sessionPresentationPolicyResolvedMock = vi.fn();
const shouldHideSettingsNavItemMock = vi.fn();
const shouldBlockSettingsRouteItemMock = vi.fn();
+const apiFetchMock = vi.fn();
vi.mock('@/stores/license', () => ({
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
@@ -35,6 +36,28 @@ vi.mock('@/stores/sessionPresentationPolicy', () => ({
}));
vi.mock('../settingsNavVisibility', () => ({
+ canMountSettingsPanel: (tab: string) =>
+ ![
+ 'infrastructure-systems',
+ 'monitoring-availability',
+ 'system-ai',
+ 'system-ai-patrol',
+ 'system-ai-assistant',
+ 'support-diagnostics',
+ 'support-reporting',
+ 'support-logs',
+ 'system-network',
+ 'system-updates',
+ 'system-recovery',
+ 'api',
+ 'security-auth',
+ 'security-sso',
+ 'security-roles',
+ 'security-users',
+ 'security-audit',
+ 'security-webhooks',
+ 'system-relay',
+ ].includes(tab),
shouldBlockSettingsRouteItem: (...args: unknown[]) => shouldBlockSettingsRouteItemMock(...args),
shouldHideSettingsNavItem: (...args: unknown[]) => shouldHideSettingsNavItemMock(...args),
}));
@@ -46,6 +69,10 @@ vi.mock('@/utils/logger', () => ({
},
}));
+vi.mock('@/utils/apiClient', () => ({
+ apiFetch: (...args: unknown[]) => apiFetchMock(...args),
+}));
+
function renderHarness(setActiveTabSpy: (tab: string) => void, initialTab = 'organization-access') {
return render(() => {
const [activeTab, setActiveTab] = createSignal(initialTab as never);
@@ -73,6 +100,7 @@ describe('useSettingsAccess', () => {
sessionPresentationPolicyResolvedMock.mockReset();
shouldHideSettingsNavItemMock.mockReset();
shouldBlockSettingsRouteItemMock.mockReset();
+ apiFetchMock.mockReset();
hasFeatureMock.mockImplementation((feature: string) => feature === 'multi_tenant');
runtimeCapabilitiesLoadedMock.mockReturnValue(true);
@@ -86,6 +114,10 @@ describe('useSettingsAccess', () => {
(tab: string) => tab === 'organization-access',
);
shouldBlockSettingsRouteItemMock.mockReturnValue(false);
+ apiFetchMock.mockResolvedValue({
+ ok: true,
+ json: async () => ({ settingsCapabilities: {} }),
+ });
});
afterEach(() => {
@@ -102,7 +134,7 @@ describe('useSettingsAccess', () => {
});
});
- it('falls back to the default tab when the current route is no longer allowed', async () => {
+ it('falls back to General while the default capability is unresolved', async () => {
const setActiveTabSpy = vi.fn();
hasFeatureMock.mockReturnValue(false);
shouldBlockSettingsRouteItemMock.mockImplementation(
@@ -112,10 +144,89 @@ describe('useSettingsAccess', () => {
renderHarness(setActiveTabSpy);
await waitFor(() => {
- expect(setActiveTabSpy).toHaveBeenCalledWith('infrastructure-systems');
+ expect(setActiveTabSpy).toHaveBeenCalledWith('system-general');
});
});
+ it('prefers General over catalog order when admin-only routes are blocked', async () => {
+ const setActiveTabSpy = vi.fn();
+ hasFeatureMock.mockReturnValue(false);
+ const blockedForNonAdmin = new Set([
+ 'organization-access',
+ 'infrastructure-systems',
+ 'monitoring-availability',
+ 'system-ai',
+ 'system-ai-patrol',
+ 'system-ai-assistant',
+ 'support-diagnostics',
+ 'support-reporting',
+ 'support-logs',
+ 'system-network',
+ 'system-updates',
+ 'system-recovery',
+ 'api',
+ 'security-auth',
+ 'security-sso',
+ 'security-roles',
+ 'security-users',
+ 'security-audit',
+ 'security-webhooks',
+ 'system-relay',
+ ]);
+ shouldBlockSettingsRouteItemMock.mockImplementation((tab: string) =>
+ blockedForNonAdmin.has(tab),
+ );
+
+ renderHarness(setActiveTabSpy);
+
+ await waitFor(() => {
+ expect(setActiveTabSpy).toHaveBeenCalledWith('system-general');
+ });
+ expect(setActiveTabSpy).not.toHaveBeenCalledWith('system-billing');
+ });
+
+ it('treats a failed security-status request as a resolved denial', async () => {
+ const setActiveTabSpy = vi.fn();
+ apiFetchMock.mockResolvedValue({ ok: false, status: 503 });
+ shouldBlockSettingsRouteItemMock.mockImplementation(
+ (tab: string, context: { settingsCapabilitiesResolved?: boolean }) =>
+ tab === 'infrastructure-systems' && context.settingsCapabilitiesResolved === true,
+ );
+
+ renderHarness(setActiveTabSpy, 'infrastructure-systems');
+
+ await waitFor(() => {
+ expect(setActiveTabSpy).toHaveBeenCalledWith('system-general');
+ });
+ });
+
+ it('deduplicates concurrent security-status loads', async () => {
+ let resolveFetch!: (value: { ok: boolean; json: () => Promise<unknown> }) => void;
+ apiFetchMock.mockReturnValue(
+ new Promise((resolve) => {
+ resolveFetch = resolve;
+ }),
+ );
+ let access!: ReturnType<typeof useSettingsAccess>;
+ render(() => {
+ const [activeTab, setActiveTab] = createSignal('system-general' as never);
+ access = useSettingsAccess({
+ activeTab,
+ setActiveTab: setActiveTab as never,
+ searchQuery: () => '',
+ });
+ return null;
+ });
+
+ await waitFor(() => expect(apiFetchMock).toHaveBeenCalledTimes(1));
+ const first = access.loadSecurityStatus();
+ const second = access.loadSecurityStatus();
+ expect(apiFetchMock).toHaveBeenCalledTimes(1);
+
+ resolveFetch({ ok: true, json: async () => ({ settingsCapabilities: {} }) });
+ await Promise.all([first, second]);
+ });
+
it('keeps direct feature-gated routes active when the panel owns the locked state', async () => {
const setActiveTabSpy = vi.fn();
hasFeatureMock.mockReturnValue(false);
diff --git a/frontend-modern/src/components/Settings/settingsNavCatalog.ts b/frontend-modern/src/components/Settings/settingsNavCatalog.ts
index 0ba367de35..4727e51a4b 100644
--- a/frontend-modern/src/components/Settings/settingsNavCatalog.ts
+++ b/frontend-modern/src/components/Settings/settingsNavCatalog.ts
@@ -56,6 +56,7 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
label: 'Availability checks',
icon: Activity,
iconProps: { strokeWidth: 2 },
+ requiredCapability: 'availabilityRead',
},
],
},
@@ -68,12 +69,14 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
label: 'Provider & Models',
icon: Sparkles,
iconProps: { strokeWidth: 2 },
+ requiredCapability: 'pulseIntelligenceRead',
},
{
id: 'system-ai-patrol',
label: 'Patrol',
icon: Activity,
iconProps: { strokeWidth: 2 },
+ requiredCapability: 'pulseIntelligenceRead',
},
{
id: 'system-billing',
@@ -96,6 +99,7 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
],
icon: Terminal,
iconProps: { strokeWidth: 2 },
+ requiredCapability: 'pulseIntelligenceRead',
},
],
},
@@ -211,6 +215,7 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
icon: Activity,
iconProps: { strokeWidth: 2 },
hideWhenDemoMode: true,
+ requiredCapability: 'diagnosticsRead',
},
{
id: 'support-reporting',
@@ -222,6 +227,7 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
// revision): the panel renders its own upgrade gate, and hiding the
// item made the capability undiscoverable — same rationale as Relay.
hideWhenDemoMode: true,
+ requiredCapability: 'reportingRead',
},
{
id: 'support-logs',
@@ -229,6 +235,7 @@ export const SETTINGS_NAV_GROUPS: SettingsNavGroup[] = [
icon: Terminal,
iconProps: { strokeWidth: 2 },
hideWhenDemoMode: true,
+ requiredCapability: 'systemLogsRead',
},
],
},
diff --git a/frontend-modern/src/components/Settings/settingsNavVisibility.ts b/frontend-modern/src/components/Settings/settingsNavVisibility.ts
index 0ed8e66984..ef36bd6f59 100644
--- a/frontend-modern/src/components/Settings/settingsNavVisibility.ts
+++ b/frontend-modern/src/components/Settings/settingsNavVisibility.ts
@@ -17,6 +17,14 @@ export interface SettingsNavVisibilityContext {
isRuntimeCapabilityBlocked?: (feature: string, reason?: string) => boolean;
}
+export function canMountSettingsPanel(
+ tab: SettingsTab,
+ settingsCapabilities: Partial<SecurityStatusSettingsCapabilities> | null | undefined,
+): boolean {
+ const requiredCapability = getSettingsNavItem(tab)?.requiredCapability;
+ return !requiredCapability || settingsCapabilities?.[requiredCapability] === true;
+}
+
function hasRequiredFeatures(tab: SettingsTab, hasFeature: (feature: string) => boolean): boolean {
const requiredFeatures = getSettingsNavItem(tab)?.features ?? [];
return requiredFeatures.every((feature) => hasFeature(feature));
diff --git a/frontend-modern/src/components/Settings/useSettingsAccess.ts b/frontend-modern/src/components/Settings/useSettingsAccess.ts
index 798d841f95..91fdac961b 100644
--- a/frontend-modern/src/components/Settings/useSettingsAccess.ts
+++ b/frontend-modern/src/components/Settings/useSettingsAccess.ts
@@ -1,4 +1,4 @@
-import { Accessor, createEffect, createMemo, createSignal } from 'solid-js';
+import { Accessor, createEffect, createMemo, createSignal, onMount } from 'solid-js';
import {
presentationPolicyHidesCommercialSurfaces,
presentationPolicyHidesOrganizationSurfaces,
@@ -19,7 +19,16 @@ import { DEFAULT_SETTINGS_TAB, type SettingsTab } from './settingsNavigationMode
import { tabFeatureRequirements } from './settingsFeatureGates';
import { getSettingsHeaderMeta } from './settingsHeaderMeta';
import { getSettingsNavGroups, getSettingsNavItem } from './settingsNavCatalog';
-import { shouldBlockSettingsRouteItem, shouldHideSettingsNavItem } from './settingsNavVisibility';
+import {
+ canMountSettingsPanel,
+ shouldBlockSettingsRouteItem,
+ shouldHideSettingsNavItem,
+} from './settingsNavVisibility';
+
+const SETTINGS_FALLBACK_TAB_ORDER: readonly SettingsTab[] = [
+ DEFAULT_SETTINGS_TAB,
+ 'system-general',
+];
interface UseSettingsAccessParams {
activeTab: Accessor<SettingsTab>;
@@ -78,7 +87,10 @@ export function useSettingsAccess({
const routeAccessContext = createMemo(() => {
const hostedModeEnabled = isHostedModeEnabled();
const settingsCapabilities = securityStatus()?.settingsCapabilities ?? null;
- const settingsCapabilitiesResolved = securityStatus() !== null;
+ // A failed status request is a resolved denial, not permission to expose
+ // capability-gated routes. Keep an existing successful status usable while
+ // it refreshes, but fail closed once the first request settles without one.
+ const settingsCapabilitiesResolved = securityStatus() !== null || !securityStatusLoading();
return {
hasFeature,
@@ -184,14 +196,23 @@ export function useSettingsAccess({
}
// The default tab is itself gated now (Infrastructure needs
// settings:read), so falling back to it unconditionally would strand a
- // non-admin session on a blocked tab. Prefer the first tab this session
- // can actually reach.
- const fallbackTab = flatTabs()[0]?.id ?? DEFAULT_SETTINGS_TAB;
+ // non-admin session on a blocked tab. Use an explicit safe preference:
+ // catalog order can move and currently puts the Plans surface before the
+ // user-scoped General tab once the admin-only entries are removed.
+ const reachable = flatTabs().filter((item) =>
+ canMountSettingsPanel(item.id, securityStatus()?.settingsCapabilities),
+ );
+ const fallbackTab =
+ SETTINGS_FALLBACK_TAB_ORDER.find((tab) => reachable.some((item) => item.id === tab)) ??
+ reachable[0]?.id ??
+ DEFAULT_SETTINGS_TAB;
setActiveTab(fallbackTab);
}
});
- async function loadSecurityStatus() {
+ let securityStatusRequest: Promise<void> | null = null;
+
+ async function fetchSecurityStatus() {
setSecurityStatusLoading(true);
try {
const { apiFetch } = await import('@/utils/apiClient');
@@ -211,6 +232,24 @@ export function useSettingsAccess({
}
}
+ function loadSecurityStatus(): Promise<void> {
+ if (securityStatusRequest) {
+ return securityStatusRequest;
+ }
+ const request = fetchSecurityStatus().finally(() => {
+ securityStatusRequest = null;
+ });
+ securityStatusRequest = request;
+ return request;
+ }
+
+ // Capability resolution belongs to the access model. Other Settings hooks
+ // may await the same request, but panel safety must not depend on an
+ // unrelated infrastructure bootstrap continuing to mount.
+ onMount(() => {
+ void loadSecurityStatus();
+ });
+
return {
securityStatus,
securityStatusLoading,
diff --git a/frontend-modern/src/types/config.ts b/frontend-modern/src/types/config.ts
index 68f13692b9..2946c637f6 100644
--- a/frontend-modern/src/types/config.ts
+++ b/frontend-modern/src/types/config.ts
@@ -97,6 +97,11 @@ export interface NodesConfig {
*/
export interface SecurityStatusSettingsCapabilities {
infrastructureRead: boolean;
+ availabilityRead: boolean;
+ pulseIntelligenceRead: boolean;
+ diagnosticsRead: boolean;
+ systemLogsRead: boolean;
+ reportingRead: boolean;
/**
* The same RequireAdmin + settings:read gate as infrastructureRead, scoped to
* the System > Network / Pulse server updates / Recovery tabs. A sibling
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 577fb090aa..19b0e2bbff 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -11051,6 +11051,139 @@ func TestContract_SecurityStatusSystemSettingsReadTracksSettingsReadScope(t *tes
}
}
+func TestContract_SecurityStatusAdminOnlySettingsCapabilitiesTrackMountRoutes(t *testing.T) {
+ surfaces := []struct {
+ name string
+ read func(securityStatusSettingsCapabilities) bool
+ routes []string
+ }{
+ {
+ "availabilityRead",
+ func(c securityStatusSettingsCapabilities) bool { return c.AvailabilityRead },
+ []string{"/api/availability-targets"},
+ },
+ {
+ "pulseIntelligenceRead",
+ func(c securityStatusSettingsCapabilities) bool { return c.PulseIntelligenceRead },
+ []string{"/api/settings/ai"},
+ },
+ {
+ "diagnosticsRead",
+ func(c securityStatusSettingsCapabilities) bool { return c.DiagnosticsRead },
+ []string{"/api/diagnostics"},
+ },
+ {
+ "systemLogsRead",
+ func(c securityStatusSettingsCapabilities) bool { return c.SystemLogsRead },
+ []string{"/api/logs/level"},
+ },
+ {
+ "reportingRead",
+ func(c securityStatusSettingsCapabilities) bool { return c.ReportingRead },
+ []string{"/api/admin/reports/catalog"},
+ },
+ }
+
+ for _, tc := range []struct {
+ name string
+ scopes []string
+ want bool
+ }{
+ {"settings read grants panel mount routes", []string{config.ScopeSettingsRead}, true},
+ {"monitoring read withholds panel mount routes", []string{config.ScopeMonitoringRead}, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ rawToken := fmt.Sprintf("contract-admin-settings-%s.12345678", strings.ReplaceAll(tc.name, " ", "-"))
+ record := newTokenRecord(t, rawToken, tc.scopes, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)
+ req.Header.Set("X-API-Token", rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("security status = %d, want 200 (%s)", rec.Code, rec.Body.String())
+ }
+
+ var payload struct {
+ SettingsCapabilities securityStatusSettingsCapabilities `json:"settingsCapabilities"`
+ }
+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {
+ t.Fatalf("decode security status payload: %v", err)
+ }
+
+ for _, surface := range surfaces {
+ if got := surface.read(payload.SettingsCapabilities); got != tc.want {
+ t.Fatalf("settingsCapabilities.%s = %v, want %v", surface.name, got, tc.want)
+ }
+ for _, path := range surface.routes {
+ probe := httptest.NewRequest(http.MethodGet, path, nil)
+ probe.Header.Set("X-API-Token", rawToken)
+ probeRec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(probeRec, probe)
+ refused := probeRec.Code == http.StatusForbidden
+ if refused == tc.want {
+ t.Fatalf("GET %s = %d, contradicting %s=%v", path, probeRec.Code, surface.name, tc.want)
+ }
+ }
+ }
+ })
+ }
+}
+
+func TestContract_SecurityStatusPermissionedSettingsCapabilitiesIncludeRouteAuthorization(t *testing.T) {
+ prevAuthorizer := authpkg.GetAuthorizer()
+ authpkg.SetAuthorizer(&allowRulesAuthorizer{
+ rules: map[string]bool{
+ "read:settings": true,
+ "read:nodes": false,
+ },
+ })
+ defer authpkg.SetAuthorizer(prevAuthorizer)
+
+ rawToken := "contract-permissioned-settings.12345678"
+ record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodGet, "/api/security/status", nil)
+ req.Header.Set("X-API-Token", rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("security status = %d, want 200 (%s)", rec.Code, rec.Body.String())
+ }
+ var payload struct {
+ SettingsCapabilities securityStatusSettingsCapabilities `json:"settingsCapabilities"`
+ }
+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {
+ t.Fatalf("decode security status payload: %v", err)
+ }
+ if !payload.SettingsCapabilities.PulseIntelligenceRead {
+ t.Fatal("pulseIntelligenceRead = false with read:settings permission")
+ }
+ if payload.SettingsCapabilities.ReportingRead {
+ t.Fatal("reportingRead = true without read:nodes permission")
+ }
+
+ for _, probe := range []struct {
+ path string
+ want int
+ }{
+ {"/api/settings/ai", http.StatusOK},
+ {"/api/admin/reports/catalog", http.StatusForbidden},
+ } {
+ request := httptest.NewRequest(http.MethodGet, probe.path, nil)
+ request.Header.Set("X-API-Token", rawToken)
+ response := httptest.NewRecorder()
+ router.Handler().ServeHTTP(response, request)
+ if response.Code != probe.want {
+ t.Fatalf("GET %s = %d, want %d", probe.path, response.Code, probe.want)
+ }
+ }
+}
+
func TestContract_SecurityStatusSplitsAuditLogCapabilityFromSettingsRead(t *testing.T) {
prevAuthorizer := authpkg.GetAuthorizer()
authpkg.SetAuthorizer(&allowRulesAuthorizer{
diff --git a/internal/api/security_status_capabilities.go b/internal/api/security_status_capabilities.go
index 89a09c77c5..cd0b07d4c3 100644
--- a/internal/api/security_status_capabilities.go
+++ b/internal/api/security_status_capabilities.go
@@ -20,6 +20,20 @@ type securityStatusSettingsCapabilities struct {
// that would otherwise mount 15s and 30s pollers whose every request is
// refused and logged at warn level.
InfrastructureRead bool `json:"infrastructureRead"`
+ // AvailabilityRead, DiagnosticsRead, and SystemLogsRead mirror the
+ // RequireAdmin + settings:read guards on the read routes mounted by those
+ // Settings panels.
+ AvailabilityRead bool `json:"availabilityRead"`
+ DiagnosticsRead bool `json:"diagnosticsRead"`
+ SystemLogsRead bool `json:"systemLogsRead"`
+ // PulseIntelligenceRead also includes read:settings authorization because
+ // /api/settings/ai applies RequirePermission before its handler repeats the
+ // settings:read admin/scope check.
+ PulseIntelligenceRead bool `json:"pulseIntelligenceRead"`
+ // ReportingRead includes read:nodes authorization as well as the explicit
+ // admin session and settings:read checks on the reporting catalog route.
+ // The advanced_reporting feature gate remains a separate UI concern.
+ ReportingRead bool `json:"reportingRead"`
// SystemSettingsRead mirrors the same RequireAdmin + settings:read gate for
// the System → Network, Pulse server updates, and Recovery tabs, whose
// panels read and write the public URL and CORS boundaries, the server
@@ -263,24 +277,33 @@ func (r *Router) securityStatusSettingsCapabilitiesFromSnapshot(snapshot securit
canReadAudit := snapshot.passesPrivilegedSessionGate() &&
r.canAccessPermissionSurface(snapshot, internalauth.ActionRead, internalauth.ResourceAuditLogs, config.ScopeAuditRead)
canManageRoles := snapshot.passesPrivilegedSessionGate() && canManageUsers
+ canReadPulseIntelligence := canReadSettings &&
+ r.canAccessPermissionSurface(snapshot, internalauth.ActionRead, internalauth.ResourceSettings, config.ScopeSettingsRead)
+ canReadReporting := canReadSettings &&
+ r.canAccessPermissionSurface(snapshot, internalauth.ActionRead, internalauth.ResourceNodes, config.ScopeSettingsRead)
return securityStatusSettingsCapabilities{
- InfrastructureRead: canReadSettings,
- SystemSettingsRead: canReadSettings,
- APIAccessRead: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsRead),
- APIAccessWrite: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsWrite),
- AuthenticationRead: canReadSettings,
- AuthenticationWrite: canAdminSettings,
- SingleSignOnRead: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsRead),
- SingleSignOnWrite: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsWrite),
- Roles: canManageRoles,
- Users: canManageRoles,
- AuditLog: canReadAudit,
- AuditWebhooksRead: snapshot.passesPrivilegedSessionGate() && r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceAuditLogs, config.ScopeSettingsRead),
- AuditWebhooksWrite: snapshot.passesPrivilegedSessionGate() && r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceAuditLogs, config.ScopeSettingsWrite),
- RelayRead: canReadSettings,
- RelayWrite: canAdminSettings,
- BillingAdmin: r.canAccessPlatformAdminSurface(snapshot),
+ InfrastructureRead: canReadSettings,
+ AvailabilityRead: canReadSettings,
+ PulseIntelligenceRead: canReadPulseIntelligence,
+ DiagnosticsRead: canReadSettings,
+ SystemLogsRead: canReadSettings,
+ ReportingRead: canReadReporting,
+ SystemSettingsRead: canReadSettings,
+ APIAccessRead: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsRead),
+ APIAccessWrite: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsWrite),
+ AuthenticationRead: canReadSettings,
+ AuthenticationWrite: canAdminSettings,
+ SingleSignOnRead: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsRead),
+ SingleSignOnWrite: r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceUsers, config.ScopeSettingsWrite),
+ Roles: canManageRoles,
+ Users: canManageRoles,
+ AuditLog: canReadAudit,
+ AuditWebhooksRead: snapshot.passesPrivilegedSessionGate() && r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceAuditLogs, config.ScopeSettingsRead),
+ AuditWebhooksWrite: snapshot.passesPrivilegedSessionGate() && r.canAccessPermissionSurface(snapshot, internalauth.ActionAdmin, internalauth.ResourceAuditLogs, config.ScopeSettingsWrite),
+ RelayRead: canReadSettings,
+ RelayWrite: canAdminSettings,
+ BillingAdmin: r.canAccessPlatformAdminSurface(snapshot),
}
}
diff --git a/internal/api/security_status_capability_enforcement_test.go b/internal/api/security_status_capability_enforcement_test.go
index 2c0e924655..ebe10904f5 100644
--- a/internal/api/security_status_capability_enforcement_test.go
+++ b/internal/api/security_status_capability_enforcement_test.go
@@ -77,6 +77,11 @@ func TestSettingsCapabilitiesMatchRouteEnforcementWithoutRBAC(t *testing.T) {
"authenticationRead",
"authenticationWrite",
"infrastructureRead",
+ "availabilityRead",
+ "pulseIntelligenceRead",
+ "diagnosticsRead",
+ "systemLogsRead",
+ "reportingRead",
// Sibling of infrastructureRead for the admin-only System tabs. Same
// derivation today, but each names its own surface so tightening one
// gate cannot silently hide the other's tabs.
@@ -96,6 +101,13 @@ func TestSettingsCapabilitiesMatchRouteEnforcementWithoutRBAC(t *testing.T) {
// them, so a withheld infrastructureRead has to line up with a refusal.
{http.MethodGet, "/api/config/nodes"},
{http.MethodGet, "/api/system/settings"},
+ {http.MethodGet, "/api/availability-targets"},
+ {http.MethodGet, "/api/settings/ai"},
+ {http.MethodGet, "/api/diagnostics"},
+ {http.MethodGet, "/api/logs/level"},
+ {http.MethodGet, "/api/logs/stream"},
+ {http.MethodGet, "/api/admin/reports/catalog"},
+ {http.MethodGet, "/api/admin/reports/schedules"},
} {
req := httptest.NewRequest(probe.method, probe.path, nil)
req.AddCookie(capabilitySessionCookie(t, "sso:[email protected]"))
@@ -118,11 +130,40 @@ func TestSettingsCapabilitiesGrantConfiguredAdminWithoutRBAC(t *testing.T) {
router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
caps := fetchSettingsCapabilities(t, router, capabilitySessionCookie(t, "admin"))
- for _, key := range []string{"apiAccessRead", "apiAccessWrite", "singleSignOnRead", "singleSignOnWrite", "infrastructureRead", "systemSettingsRead"} {
+ for _, key := range []string{
+ "apiAccessRead",
+ "apiAccessWrite",
+ "singleSignOnRead",
+ "singleSignOnWrite",
+ "infrastructureRead",
+ "availabilityRead",
+ "pulseIntelligenceRead",
+ "diagnosticsRead",
+ "systemLogsRead",
+ "reportingRead",
+ "systemSettingsRead",
+ } {
if caps[key] != true {
t.Fatalf("%s = %v for the configured admin, want true", key, caps[key])
}
}
+
+ for _, path := range []string{
+ "/api/availability-targets",
+ "/api/settings/ai",
+ "/api/diagnostics",
+ "/api/logs/level",
+ "/api/admin/reports/catalog",
+ "/api/admin/reports/schedules",
+ } {
+ req := httptest.NewRequest(http.MethodGet, path, nil)
+ req.AddCookie(capabilitySessionCookie(t, "admin"))
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code == http.StatusForbidden {
+ t.Fatalf("GET %s = 403 for the configured admin, contradicting its capability", path)
+ }
+ }
}
// On the OIDC-only pattern there is no local admin, so SSO principals are the