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
Retain accepted token row bindings across confirmed table edits
pulse-triage[bot]363b74b3040c
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 5dfed8840a..af874be32a 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -13509,3 +13509,10 @@ values, not the containing security-status object's identity. An ordinary statusrefresh or primary-token hint change with the same user/permission must notwithdraw a confirmed token or start another inventory read. The registeredunchanged-principal status-refresh test pins this boundary.++Accepted token rows retain their inventory-read generation across confirmed+scope/name replacements. Keyed desktop-table reconciliation may retain the+earlier raw object; that current-read object remains usable for the same live+ID. A later full read, context withdrawal or deletion invalidates the old+confirmation. The registered sequential scope-edit/revoke consumer regression+and earlier-read rejection test cover both sides without ID-only admission.diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex 5c13684460..99f98ce9cf 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -4016,3 +4016,10 @@ values, not the containing security-status object's identity. An ordinary statusrefresh or primary-token hint change with the same user/permission must notwithdraw a confirmed token or start another inventory read. The registeredunchanged-principal status-refresh test pins this boundary.++Accepted token rows retain their inventory-read generation across confirmed+scope/name replacements. Keyed desktop-table reconciliation may retain the+earlier raw object; that current-read object remains usable for the same live+ID. A later full read, context withdrawal or deletion invalidates the old+confirmation. The registered sequential scope-edit/revoke consumer regression+and earlier-read rejection test cover both sides without ID-only admission.diff --git a/frontend-modern/src/components/Settings/__tests__/APITokenLifetimes.test.tsx b/frontend-modern/src/components/Settings/__tests__/APITokenLifetimes.test.tsxindex 6de14e0bed..1c3d5fd0c3 100644--- a/frontend-modern/src/components/Settings/__tests__/APITokenLifetimes.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/APITokenLifetimes.test.tsx@@ -306,9 +306,10 @@ describe('API token request lifetimes', () => {it('rejects a row retained from an earlier accepted inventory', async () => {await ready();+ const obsolete = state.sortedTokens()[0];+ vi.mocked(SecurityAPI.listTokens).mockResolvedValueOnce([{ ...record }]);await state.loadTokens();- // Same ID, different accepted object is not the earlier confirmation.- const obsolete = { ...record };+ // Same ID in a new read must not re-admit the preceding read's object.expect(await state.handleRename(obsolete, 'Wrong')).toBe(false);expect(await state.handleUpdateScopes(obsolete, ['*'])).toBe(false);await state.handleDelete(obsolete);diff --git a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsxindex 5883ae4458..c987f34512 100644--- a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx@@ -891,6 +891,35 @@ describe('APITokenManager', () => {expect(apiTokenManagerSource).toContain('desktopMinWidth="960px"');});+ it('keeps the reconciled desktop row actionable after a confirmed scope edit', async () => {+ const token = makeToken({ name: 'Sequential token', scopes: [MONITORING_READ_SCOPE] });+ listTokensMock.mockResolvedValue([token]);+ updateTokenScopesMock.mockResolvedValue({+ ...token,+ scopes: [MONITORING_READ_SCOPE, SETTINGS_READ_SCOPE],+ });+ render(() => <APITokenManager canManage />);+ fireEvent.click(within(await findTokenTableRow('Sequential token')).getByRole('button', {+ name: 'Edit scopes',+ }));+ const dialog = await screen.findByRole('dialog', { name: 'Edit API token scopes' });+ fireEvent.click(within(dialog).getByRole('checkbox', { name: /^Settings \(read\)/ }));+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save scopes' }));+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());+ fireEvent.click(within(getTokenTableRow('Sequential token')).getByRole('button', {+ name: 'Revoke',+ }));+ const revoke = await screen.findByRole('dialog', { name: 'Revoke API token' });+ fireEvent.click(within(revoke).getByRole('button', { name: 'Revoke token' }));+ await waitFor(() => expect(deleteTokenMock).toHaveBeenCalledWith(+ token.id,+ expect.objectContaining({ expectedOrgID: 'default', signal: expect.any(AbortSignal) }),+ ));+ await screen.findByText(/No tokens yet/);+ expect(updateTokenScopesMock).toHaveBeenCalledTimes(1);+ expect(deleteTokenMock).toHaveBeenCalledTimes(1);+ });+it('edits a token scope set in place without rotating or revoking it', async () => {const onTokensChanged = vi.fn();listTokensMock.mockResolvedValue([diff --git a/frontend-modern/src/components/Settings/useAPITokenManagerState.ts b/frontend-modern/src/components/Settings/useAPITokenManagerState.tsindex c5992cdfe3..5820c75276 100644--- a/frontend-modern/src/components/Settings/useAPITokenManagerState.ts+++ b/frontend-modern/src/components/Settings/useAPITokenManagerState.ts@@ -100,11 +100,19 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {let readController: AbortController | undefined;let mutationController: AbortController | undefined;let ownedReveal: ReturnType<typeof tokenRevealState> = null;+ let inventoryVersion = 0;+ const recordBindings = new WeakMap<APITokenRecord, number>();+ const rememberToken = (record: APITokenRecord) => {+ recordBindings.set(unwrap(record), inventoryVersion);+ return record;+ };const contextIsCurrent = () =>!disposed && selectedOrg() === currentOrg() && selectedUser() === authenticatedUser();const canManage = () => contextIsCurrent() && managementAllowed();const isCurrentRecord = (record: APITokenRecord) =>- tokensLoaded() && tokens().includes(unwrap(record));+ tokensLoaded() &&+ recordBindings.get(unwrap(record)) === inventoryVersion &&+ tokens().some((current) => current.id === record.id);const clearTokenValue = () => {// A different issuer may have replaced the global dialog. Never dismiss theirs.@@ -115,6 +123,7 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {};const invalidateRequests = () => {+ inventoryVersion += 1;setContextVersion((version) => version + 1);readController?.abort();readController = undefined;@@ -252,6 +261,11 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {expectedOrgID: selectedOrg(),});if (!isCurrent()) return;+ // Keyed table reconciliation retains a row's raw object across confirmed+ // edits. Bind accepted objects to this read, not the latest replacement's+ // identity, while excluding every object from an earlier inventory read.+ inventoryVersion += 1;+ list.forEach(rememberToken);setTokens(list);setTokensLoaded(true);} catch (err) {@@ -438,6 +452,7 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {);if (!mutation.isCurrent()) return;+ rememberToken(record);setTokens((previous) => [record, ...previous]);setNewTokenRecord(record);setNewTokenValue(token);@@ -544,6 +559,7 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {mutation.options,);if (!mutation.isCurrent()) return false;+ rememberToken(updated);setTokens((previous) => previous.map((token) => (token.id === updated.id ? updated : token)));if (newTokenRecord()?.id === updated.id) {setNewTokenRecord(updated);@@ -575,6 +591,7 @@ export const useAPITokenManagerState = (props: APITokenManagerProps) => {try {const updated = await SecurityAPI.renameToken(record.id, trimmedName, mutation.options);if (!mutation.isCurrent()) return false;+ rememberToken(updated);setTokens((previous) => previous.map((token) => (token.id === updated.id ? updated : token)));setNewTokenRecord((current) => (current?.id === updated.id ? updated : current));notificationStore.success('Token renamed');