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 token usage identity local

rcourtman31d9d96f8228
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index bd44816c94..399b795417 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -177,6 +177,12 @@ Own canonical runtime payload shapes between backend and frontend.
The API layer already uses contract tests in many places, but every major live
contract should continue moving toward canonical-only runtime shapes.
+The shared API-token management surface now also preserves canonical local
+operator identity when explaining where a token is currently in use. Runtime
+and infrastructure usage labels in the revoke flow keep the local instance
+name for Docker hosts, agents, PBS, PMG, and similar monitored systems
+instead of replacing those identities with governed summary text, so
+revocation decisions remain instance-specific and auditable.
The unified resource API payload now carries the richer domain facets directly
through the owned backend response: resource objects can expose canonical
`capabilities`, `relationships`, `recentChanges`, and derived `facetCounts`
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index c5882861ce..14c997cb75 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -286,6 +286,12 @@ canonical scope constants. `apiTokenManagerModel.ts` may expose a
`getAPITokenScopePresets()` factory, but it must not freeze preset scope data
at module-load time in a way that can break security settings initialization in
production chunks.
+That same revoke/usage surface must also preserve canonical local operator
+identity for the runtimes currently bound to a token. When token usage is
+attributed to Docker hosts, agents, PBS, PMG, or similar monitored systems,
+the security settings UI must keep the local instance name instead of swapping
+in governed summary text, so the operator can revoke credentials against the
+correct concrete system.
That same governed AI trust boundary also covers unified-resource context
posture derivation: `internal/ai/resource_context_policy_model.go` is now the
canonical owner for the policy-posture summary, local-only count, and
diff --git a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
index edcc5a7d82..8abe86a091 100644
--- a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
@@ -242,6 +242,55 @@ describe('APITokenManager', () => {
});
});
+ it('keeps governed infrastructure token usage labels on local operator identity', async () => {
+ listTokensMock.mockResolvedValue([
+ makeToken({
+ id: 'token-runtime',
+ name: 'Runtime token',
+ scopes: [AGENT_REPORT_SCOPE],
+ }),
+ ]);
+
+ mockResources = [
+ makeResource({
+ id: 'pbs-resource',
+ type: 'pbs',
+ name: 'redacted-pbs',
+ displayName: 'PBS Main',
+ platformType: 'proxmox-pbs',
+ sourceType: 'api',
+ policy: {
+ display: {
+ mode: 'governed',
+ summary: 'backup server resource; status online; sources pbs',
+ },
+ } as Record<string, unknown>,
+ platformData: {
+ pbs: {
+ hostname: 'pbs.local',
+ instanceId: 'pbs-main',
+ },
+ agent: {
+ agentId: 'pbs-agent-1',
+ tokenId: 'token-runtime',
+ },
+ } as Record<string, unknown>,
+ }),
+ ];
+
+ render(() => <APITokenManager onTokensChanged={vi.fn()} canManage />);
+
+ const runtimeName = await screen.findByText('Runtime token');
+ const row = runtimeName.closest('tr');
+ expect(row).toBeTruthy();
+ expect(within(row as HTMLTableRowElement).getByText('PBS Main')).toBeInTheDocument();
+ expect(
+ within(row as HTMLTableRowElement).queryByText(
+ 'backup server resource; status online; sources pbs',
+ ),
+ ).not.toBeInTheDocument();
+ });
+
it('surfaces scope denial when token generation is blocked by caller scope', async () => {
createTokenMock.mockRejectedValueOnce(
Object.assign(new Error('Cannot grant scope "monitoring:read": your token does not have this scope'), {
diff --git a/frontend-modern/src/components/Settings/apiTokenManagerModel.ts b/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
index bcc633c983..8411093a9a 100644
--- a/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
+++ b/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
@@ -14,7 +14,7 @@ import {
getActionableDockerRuntimeIdFromResource,
hasAgentFacet as resourceHasAgentFacet,
} from '@/utils/agentResources';
-import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
+import { getPreferredInfrastructureDisplayName } from '@/utils/resourceIdentity';
import type { Resource } from '@/types/resource';
export const API_TOKEN_SCOPES_DOC_URL =
@@ -159,7 +159,7 @@ export const buildDockerTokenUsage = (resources: Resource[]): Map<string, APITok
if (!tokenId) continue;
appendUsageEntry(usage, tokenId, {
id: dockerActionIdForResource(resource),
- label: getPreferredResourceDisplayName(resource),
+ label: getPreferredInfrastructureDisplayName(resource),
});
}
return usage;
@@ -172,7 +172,7 @@ export const buildAgentTokenUsage = (resources: Resource[]): Map<string, APIToke
if (!tokenId) continue;
appendUsageEntry(usage, tokenId, {
id: agentActionIdForResource(resource),
- label: getPreferredResourceDisplayName(resource),
+ label: getPreferredInfrastructureDisplayName(resource),
});
}
return usage;