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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Bind saved permissions to the user access read that produced them
pulse-triage[bot]0ac8c5463fdd
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex a44d211722..6d6bfaabc8 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -21,6 +21,23 @@## Purpose+### Admit saved permissions before presenting user access++`RBACAPI.getUserPermissions` admits the existing array response only when every+member has nonempty string `action` and `resource` fields. Empty arrays are+valid; null, missing, malformed or partially unreadable responses reject as a+whole rather than inventing absence or a smaller permission set. Wildcards and+future nonempty strings remain intact. Stable principals stay URL-encoded+without substituting display names. The backend already distinguishes storage+failure from a healthy empty array, and no endpoint or authority changes.++`rbac.test.ts` checks response admission, complete rejection and encoded+principals. User Access keeps loading/failed reads distinct from an accepted+saved snapshot, binds results to the current dialog request, preserves role+drafts across explicit read-only retry and does not call any mutation as part+of retry. `RBACPaywallPanels.test.tsx` and desktop/narrow consuming browser+proof cover that state and identity boundary.+### Token inventory must be read before absence is presentedThe API Access consumer distinguishes loading, failed and accepted tokendiff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.mdindex f86e142bbd..762cc38bc5 100644--- a/docs/release-control/v6/internal/subsystems/organization-settings.md+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md@@ -15,6 +15,27 @@## Purpose+### Saved permissions belong to one open user-access dialog++User Access displays only an admitted saved-permissions read for the principal+currently being managed. Opening or closing a dialog invalidates earlier reads,+including earlier reads for the same principal; an obsolete success, failure or+completion cannot replace data or finish loading in a newer dialog. Disposal+and loss of the existing RBAC capability invalidate the pending read too.+Pending or failed reads never retain another user's permission badges or+claim that the selected user has no access. A persistent, fixed-text failure+notice offers an explicit read-only retry that preserves unsaved role selections+and permits at most one current read. It never retries a role update or removal.++The saved-permissions section is not a simulation of unsaved role choices.+Only an accepted empty response describes empty saved permissions; it does not+predict access after save. Normal-suite `RBACPaywallPanels.test.tsx` covers+cross-user and same-user reopen races, loading and failure, explicit retry,+draft preservation, accepted empty results and unchanged exact-principal writes.+Desktop and narrow browser proof exercises the real User Access route and API+client with safe HTTP fixtures. Backend authorization and the existing RBAC+gate remain the authority; a successful read grants no write capability.+A member test announces and reveals its result beside that exact member ratherthan leaving feedback in the off-screen global footer. The normal primaryTest connection result stays in the footer; both remain endpoint-qualifieddiff --git a/frontend-modern/src/api/__tests__/rbac.test.ts b/frontend-modern/src/api/__tests__/rbac.test.tsindex 416a35f46f..94d119ae10 100644--- a/frontend-modern/src/api/__tests__/rbac.test.ts+++ b/frontend-modern/src/api/__tests__/rbac.test.ts@@ -148,6 +148,14 @@ describe('RBACAPI', () => {});describe('getUserPermissions', () => {+ it('preserves a refused read rather than converting it to an empty permission set', async () => {+ const denial = Object.assign(new Error('private refusal detail'), { status: 403 });+ vi.mocked(apiFetchJSON).mockRejectedValueOnce(denial);++ await expect(RBACAPI.getUserPermissions('alice')).rejects.toBe(denial);+ expect(apiFetchJSON).toHaveBeenCalledTimes(1);+ });+it('fetches user permissions', async () => {const mockPermissions = [{ action: 'read', resource: 'alerts' }];vi.mocked(apiFetchJSON).mockResolvedValueOnce(mockPermissions);diff --git a/frontend-modern/src/api/rbac.ts b/frontend-modern/src/api/rbac.tsindex e87a50044c..5d8ad15d0e 100644--- a/frontend-modern/src/api/rbac.ts+++ b/frontend-modern/src/api/rbac.ts@@ -29,6 +29,25 @@ export const RBACAPI = {deleteUser: (username: string) =>apiFetchJSON(`/api/admin/users/${encodeURIComponent(username)}`, { method: 'DELETE' }),- getUserPermissions: (username: string) =>- apiFetchJSON<Permission[]>(`/api/admin/users/${encodeURIComponent(username)}/permissions`),+ getUserPermissions: async (username: string): Promise<Permission[]> => {+ const permissions = await apiFetchJSON<unknown>(+ `/api/admin/users/${encodeURIComponent(username)}/permissions`,+ );+ if (+ !Array.isArray(permissions) ||+ !permissions.every(+ (permission) =>+ permission !== null &&+ typeof permission === 'object' &&+ !Array.isArray(permission) &&+ typeof permission.action === 'string' &&+ permission.action.trim().length > 0 &&+ typeof permission.resource === 'string' &&+ permission.resource.trim().length > 0,+ )+ ) {+ throw new Error('Invalid saved permissions response.');+ }+ return permissions;+ },};diff --git a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsxindex 132a05fbd3..ca932cb8b6 100644--- a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx+++ b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx@@ -1,6 +1,7 @@import { Component, For, Show } from 'solid-js';import { Dialog } from '@/components/shared/Dialog';import { LoadingSpinner } from '@/components/shared/LoadingSpinner';+import { InlineNotice } from '@/components/shared/InlineNotice';import type { Permission, Role, UserRoleAssignment } from '@/types/rbac';import BadgeCheck from 'lucide-solid/icons/badge-check';import Shield from 'lucide-solid/icons/shield';@@ -12,11 +13,13 @@ interface UserAssignmentsDialogProps {formRoleIds: string[];isOpen: boolean;loadingPermissions: boolean;+ permissionsError: string | null;roles: Role[];saving: boolean;- userPermissions: Permission[];+ userPermissions: Permission[] | null;onClose: () => void;onSave: () => void;+ onRetryPermissions: () => void;onToggleRole: (roleId: string) => void;}@@ -98,32 +101,56 @@ export const UserAssignmentsDialog: Component<UserAssignmentsDialogProps> = (pro<div class="flex items-center justify-between"><h4 class="text-sm font-semibold text-base-content flex items-center gap-2"><BadgeCheck class="w-4 h-4 text-blue-500" />- Effective Permissions Preview+ Saved permissions</h4><Show when={props.loadingPermissions}><LoadingSpinner size="md" tone="info" label="Loading effective permissions" /></Show></div><div class="bg-surface-hover rounded-md p-4 border border-border-subtle">- <Show when={!props.loadingPermissions && props.userPermissions.length === 0}>- <p class="text-xs text-muted italic text-center py-2">- No effective permissions. This user will have no access.- </p>+ <Show when={!props.loadingPermissions && props.permissionsError}>+ {(message) => (+ <InlineNotice+ tone="warning"+ role="alert"+ aria-live="polite"+ actionLabel="Retry saved permissions"+ actionOnClick={props.onRetryPermissions}+ >+ {message()}+ </InlineNotice>+ )}+ </Show>+ <Show+ when={!props.loadingPermissions && !props.permissionsError && props.userPermissions}+ >+ {(permissions) => (+ <>+ <Show when={permissions().length === 0}>+ <p class="text-xs text-muted italic text-center py-2">+ No permissions were returned for this user's saved roles.+ </p>+ </Show>+ <div class="flex flex-wrap gap-2">+ <For each={permissions()}>+ {(permission) => (+ <span class="inline-flex max-w-full flex-wrap items-center break-all rounded-md bg-surface px-2.5 py-1 text-xs font-semibold text-base-content border border-border shadow-xs">+ <span class="text-blue-600 dark:text-blue-400">+ {permission.action}+ </span>+ <span class="mx-1 text-slate-400">:</span>+ <span class="text-blue-600 dark:text-blue-400">+ {permission.resource}+ </span>+ </span>+ )}+ </For>+ </div>+ </>+ )}</Show>- <div class="flex flex-wrap gap-2">- <For each={props.userPermissions}>- {(permission) => (- <span class="inline-flex items-center rounded-md bg-surface px-2.5 py-1 text-xs font-semibold text-base-content border border-border shadow-xs">- <span class="text-blue-600 dark:text-blue-400">{permission.action}</span>- <span class="mx-1 text-slate-400">:</span>- <span class="text-blue-600 dark:text-blue-400">{permission.resource}</span>- </span>- )}- </For>- </div>- <p class="mt-4 text-[10px] text-muted uppercase tracking-widest font-bold">- Note: Permissions are recalculated on save. This preview shows current server-side- state.+ <p class="mt-4 text-xs text-muted">+ This read checks saved roles only. Unsaved role selections are not included.</p></div></div>diff --git a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsxindex 593a1f59cc..cb6204c772 100644--- a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx+++ b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx@@ -200,11 +200,13 @@ export const UserAssignmentsPanel: Component = () => {formRoleIds={state.formRoleIds()}isOpen={state.showModal()}loadingPermissions={state.loadingPermissions()}+ permissionsError={state.permissionsError()}roles={state.roles()}saving={state.saving()}userPermissions={state.userPermissions()}onClose={state.closeModal}onSave={state.handleSaveAssignments}+ onRetryPermissions={() => void state.loadUserPermissions()}onToggleRole={state.toggleRole}/>diff --git a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsxindex 3aab3f484a..e70e878a96 100644--- a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx@@ -1,5 +1,6 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/testing-library';+import { createSignal } from 'solid-js';import { RolesPanel } from '../RolesPanel';import { UserAssignmentsPanel } from '../UserAssignmentsPanel';@@ -406,6 +407,36 @@ describe('RBAC paywall settings panels', () => {expect(getUserPermissionsMock).toHaveBeenCalledTimes(2);});+ it('discards pending permission reads when the RBAC capability is lost', async () => {+ const [enabled, setEnabled] = createSignal(true);+ const pending = deferred<{ action: string; resource: string }[]>();+ hasFeatureMock.mockImplementation(() => enabled());+ getUserPermissionsMock.mockReturnValueOnce(pending.promise);+ render(() => <UserAssignmentsPanel />);+ fireEvent.click(await screen.findByRole('button', { name: 'Manage access for alice' }));+ expect(await screen.findByRole('dialog', { name: 'Manage access: alice' })).toBeInTheDocument();++ setEnabled(false);+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();+ expect(screen.getByText('Centralized Access Control')).toBeInTheDocument();+ pending.resolve([{ action: 'write', resource: 'obsolete-resource' }]);+ await pending.promise;+ expect(screen.queryByText('obsolete-resource')).not.toBeInTheDocument();+ expect(updateUserRolesMock).not.toHaveBeenCalled();+ });++ it('ignores a permission read failure after the panel is disposed', async () => {+ const pending = deferred<{ action: string; resource: string }[]>();+ getUserPermissionsMock.mockReturnValueOnce(pending.promise);+ const view = render(() => <UserAssignmentsPanel />);+ fireEvent.click(await screen.findByRole('button', { name: 'Manage access for alice' }));+ view.unmount();+ pending.reject(new Error('obsolete private failure'));+ await pending.promise.catch(() => undefined);+ expect(loggerErrorMock).not.toHaveBeenCalled();+ expect(notificationErrorMock).not.toHaveBeenCalled();+ });+it('shows readable SSO identity details and confirms deprovisioning', async () => {const user = {username: 'sso:oidc:okta:opaque_subject',diff --git a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.tsindex afb7cacd36..8b3ee05031 100644--- a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts+++ b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts@@ -1,4 +1,4 @@-import { createEffect, createMemo, createSignal } from 'solid-js';+import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';import { RBACAPI } from '@/api/rbac';import type { Permission, Role, UserRoleAssignment } from '@/types/rbac';import { notificationStore } from '@/stores/notifications';@@ -19,8 +19,10 @@ export function useUserAssignmentsPanelState() {const [showModal, setShowModal] = createSignal(false);const [editingUser, setEditingUser] = createSignal<UserRoleAssignment | null>(null);const [saving, setSaving] = createSignal(false);- const [userPermissions, setUserPermissions] = createSignal<Permission[]>([]);+ const [userPermissions, setUserPermissions] = createSignal<Permission[] | null>(null);const [loadingPermissions, setLoadingPermissions] = createSignal(false);+ const [permissionsError, setPermissionsError] = createSignal<string | null>(null);+ let permissionsRequest = 0;const [formRoleIds, setFormRoleIds] = createSignal<string[]>([]);const [loadError, setLoadError] = createSignal<string | null>(null);const [deletingUser, setDeletingUser] = createSignal(false);@@ -68,10 +70,12 @@ export function useUserAssignmentsPanelState() {createEffect(() => {if (!featureGate.licenseReady()) {+ closeModal();setLoading(true);return;}if (!featureGate.rbacEnabled()) {+ closeModal();setAssignments([]);setRoles([]);setLoadError(null);@@ -95,35 +99,49 @@ export function useUserAssignmentsPanelState() {);});- const loadUserPermissions = async (username: string) => {- if (!featureGate.rbacEnabled()) {- setUserPermissions([]);- return;- }+ const loadUserPermissions = async () => {+ const username = editingUser()?.username;+ if (!username || !showModal() || !featureGate.rbacEnabled() || loadingPermissions()) return;++ const request = ++permissionsRequest;+ const isCurrentRead = () =>+ request === permissionsRequest &&+ showModal() &&+ editingUser()?.username === username &&+ featureGate.rbacEnabled();+ setUserPermissions(null);+ setPermissionsError(null);setLoadingPermissions(true);try {const permissions = await RBACAPI.getUserPermissions(username);- setUserPermissions(permissions || []);+ if (isCurrentRead()) setUserPermissions(permissions);} catch (err) {- if (err instanceof Error && /feature not included in license/i.test(err.message)) {- setUserPermissions([]);- return;- }+ if (!isCurrentRead()) return;+ setPermissionsError('Saved permissions could not be loaded. Access is unknown.');logger.error('Failed to load user permissions', err);} finally {- setLoadingPermissions(false);+ if (isCurrentRead()) setLoadingPermissions(false);}};const closeModal = () => {+ permissionsRequest += 1;+ setUserPermissions(null);+ setPermissionsError(null);+ setLoadingPermissions(false);setShowModal(false);};+ onCleanup(() => {+ permissionsRequest += 1;+ });+const openManageAccess = async (assignment: UserRoleAssignment) => {+ closeModal();setEditingUser(assignment);setFormRoleIds([...assignment.roleIds]);setShowModal(true);- await loadUserPermissions(assignment.username);+ await loadUserPermissions();};const openDeleteUser = (assignment: UserRoleAssignment) => {@@ -198,8 +216,10 @@ export function useUserAssignmentsPanelState() {loadData,loadError,loadingPermissions,+ loadUserPermissions,openManageAccess,openDeleteUser,+ permissionsError,roles,saving,searchQuery,