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
Reserve API token owner metadata
rcourtmanc874da9ab831
diff --git a/docs/release-control/v6/internal/IDENTITY_INVARIANTS.md b/docs/release-control/v6/internal/IDENTITY_INVARIANTS.mdindex 836216477e..09907d94ea 100644--- a/docs/release-control/v6/internal/IDENTITY_INVARIANTS.md+++ b/docs/release-control/v6/internal/IDENTITY_INVARIANTS.md@@ -58,7 +58,8 @@ principal once a stable user ID exists.- Shape: token hash plus token metadata in config/auth storage.- Owns: API credential identity, scope, and revocation.- `owner_user_id` metadata must carry the authenticated principal, not an- arbitrary email copied from a browser payload.+ arbitrary email copied from a browser payload. Token minting helpers must+ reject caller-supplied metadata that attempts to set `owner_user_id`.8. Mobile/relay device identity- Shape: relay/mobile device registration IDs and platform device tokens.diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex b99729d734..34c8b779f9 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -185,6 +185,9 @@ profile and assignment columns, but embedded table framing must route throughlifecycle surfaces may display contact email when supplied by the sharedauth boundary, but they must not reinterpret SSO or Stripe email as thecanonical user identifier for setup, install, or fleet-management actions.+ API-token owner metadata follows the same rule: lifecycle-adjacent setup or+ mobile-pairing token flows may consume the shared token helper, but they+ must not pass extension metadata that authors or overwrites `owner_user_id`.The canonical durable-principal vocabulary for those shared auth routes isrecorded in `docs/release-control/v6/internal/IDENTITY_INVARIANTS.md`; agentlifecycle work may consume that identity but must not define a paralleldiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 6c3e4d7066..fa610972f2 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -222,6 +222,10 @@ product API routes free of maintainer commercial analytics.session revocation must still delete the full session token set rather thanleaving any retained replacement token valid.48. `internal/api/security_tokens.go` shared with `security-privacy`: the security token handlers are both a security/privacy control surface and a canonical API payload contract boundary.+ Token owner identity is reserved for the server-authenticated principal:+ shared token-minting helpers must derive `owner_user_id` from the current+ session or caller token and reject extension metadata that tries to+ overwrite that field.The dedicated Pulse Mobile relay token route is part of that same APIcontract even though its runtime capability is Relay-owned:`POST /api/security/tokens/relay-mobile` must pass normal admin and@@ -3156,7 +3160,9 @@ the broader API lane.The `/api/security/tokens` payload contract now also carries explicit ownerbinding: token create/list responses must preserve the originating`ownerUserId` together with org scope so long-lived automation credentials-cannot appear detached from their intended human identity.+cannot appear detached from their intended human identity, and shared+token-minting helpers must reject caller-supplied metadata that attempts to+overwrite the reserved `owner_user_id` field.The shared direct-node/discovery settings boundary now also includes`frontend-modern/src/utils/infrastructureSettingsPresentation.ts`, so thecustomer-facing mutation and validation copy used by the governed runtimediff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.mdindex 528bd40f6f..509ce12c29 100644--- a/docs/release-control/v6/internal/subsystems/security-privacy.md+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md@@ -266,6 +266,10 @@ helper. Security surfaces may consume compatibility-normalized`platformType: 'truenas'` resources, but they must not reintroduce a separate`resource.type === 'truenas'` trust path when calculating token usage,revocation targets, or operator-facing token ownership.+That same token-management boundary also reserves token-owner identity for the+server-authenticated principal. Token-minting helpers must derive+`owner_user_id` from the authenticated session or caller token and reject any+extension metadata that attempts to overwrite that field.Telemetry/privacy disclosures now also route through the shipped frontend docsboundary: `frontend-modern/src/utils/docsLinks.ts` is the canonical frontendowner for privacy-document URLs, while `frontend-modern/public/docs/PRIVACY.md`diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 8d2c54be5b..8421e958c3 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -160,6 +160,10 @@ stale-plan hash, blast-radius model, or execution protocol outsideshared metric-color helper instead of carrying storage-local usage colorbands.4. Route transport changes for storage and recovery endpoints through `internal/api/` and the owning `api-contracts` proof routes+ Shared API-token transport helpers may be consumed by storage/recovery-+ adjacent flows, but `owner_user_id` remains server-authored token identity+ metadata; storage/recovery extensions must not pass metadata that authors+ or overwrites that owner field.Shared setup-script transport may be reused by storage and recovery-linkedsetup flows, but it remains API/lifecycle-owned: generated PVE scripts mustpreserve Proxmox `authorized_keys` symlinks by resolving the target before@@ -2517,7 +2521,10 @@ shared auth/security helpers may inspect token metadata, but they must nottreat a displayed relay pairing token as disposable once canonical metadatashows `lastUsedAt`. Shared transport mutations must preserve used-tokencontinuity instead of deleting a credential that an already paired device-still depends on.+still depends on. Storage- and recovery-adjacent helpers must also treat+`owner_user_id` as API-authored identity metadata, not caller-supplied storage+or recovery metadata, so shared token records cannot be rebound through+extension-specific metadata maps.That same shared backend helper layer now also owns hosted relay bootstrapcontinuity. Storage- and recovery-adjacent consumers may read relay status ormobile onboarding payloads, but they must not assume hosted tenants need adiff --git a/internal/api/identity_invariant_contract_test.go b/internal/api/identity_invariant_contract_test.goindex 78fe346dad..a78968aab8 100644--- a/internal/api/identity_invariant_contract_test.go+++ b/internal/api/identity_invariant_contract_test.go@@ -25,6 +25,7 @@ func TestContract_HostedIdentityUsesStablePrincipals(t *testing.T) {"payments_webhook_handlers.go": readIdentityContractFile(t, "payments_webhook_handlers.go"),"saml_handlers.go": readIdentityContractFile(t, "saml_handlers.go"),"auth_principal_identity.go": readIdentityContractFile(t, "auth_principal_identity.go"),+ "security_tokens.go": readIdentityContractFile(t, "security_tokens.go"),"../cloudcp/stripe/provisioner.go": readIdentityContractFile(t, "../cloudcp/stripe/provisioner.go"),"../models/organization.go": readIdentityContractFile(t, "../models/organization.go"),"../../docs/release-control/v6/internal/IDENTITY_INVARIANTS.md": readIdentityContractFile(t, "../../docs/release-control/v6/internal/IDENTITY_INVARIANTS.md"),@@ -59,6 +60,11 @@ func TestContract_HostedIdentityUsesStablePrincipals(t *testing.T) {"ssoLegacyPrincipalCandidates","applySSORoleAssignments",},+ "security_tokens.go": {+ "mergeAPITokenMetadata",+ "reserved token metadata key",+ "apiTokenOwnerUserIDForRequest",+ },"../cloudcp/stripe/provisioner.go": {"ownerUserID = strings.TrimSpace(user.ID)","org.OwnerEmail = ownerEmail",@@ -74,6 +80,7 @@ func TestContract_HostedIdentityUsesStablePrincipals(t *testing.T) {"Email is contact metadata","Pulse control-plane user ID","SSO provider subject",+ "reject caller-supplied metadata","Self-hosted SSO sessions now use provider-scoped",},}diff --git a/internal/api/security_tokens.go b/internal/api/security_tokens.goindex 2a930e11de..37c027fed4 100644--- a/internal/api/security_tokens.go+++ b/internal/api/security_tokens.go@@ -30,6 +30,26 @@ const apiTokenMetadataOwnerUserID = "owner_user_id"const apiTokenMetadataPurpose = "purpose"const apiTokenPurposeRelayMobileAccess = "relay_mobile_access"+func mergeAPITokenMetadata(record *config.APITokenRecord, metadata map[string]string) error {+ if record == nil || len(metadata) == 0 {+ return nil+ }+ if record.Metadata == nil {+ record.Metadata = make(map[string]string)+ }+ for key, value := range metadata {+ key = strings.TrimSpace(key)+ if key == "" {+ continue+ }+ if key == apiTokenMetadataOwnerUserID {+ return fmt.Errorf("reserved token metadata key %q cannot be supplied by caller metadata", apiTokenMetadataOwnerUserID)+ }+ record.Metadata[key] = value+ }+ return nil+}+func apiTokenOwnerUserID(record config.APITokenRecord) string {if record.Metadata == nil {return ""@@ -175,13 +195,8 @@ func (r *Router) createAPITokenRecord(}record.Metadata[apiTokenMetadataOwnerUserID] = ownerUserID}- if len(metadata) > 0 {- if record.Metadata == nil {- record.Metadata = make(map[string]string)- }- for key, value := range metadata {- record.Metadata[key] = value- }+ if err := mergeAPITokenMetadata(record, metadata); err != nil {+ return "", nil, err}if expiresIn != nil && *expiresIn != "" {diff --git a/internal/api/security_tokens_owner_binding_test.go b/internal/api/security_tokens_owner_binding_test.goindex 0fdc0359e0..5a18ba499e 100644--- a/internal/api/security_tokens_owner_binding_test.go+++ b/internal/api/security_tokens_owner_binding_test.go@@ -108,3 +108,37 @@ func TestSecurityTokens_CreateInheritsOwnerUserIDFromTokenCaller(t *testing.T) {t.Fatalf("stored child org = %q, want acme", got)}}++func TestSecurityTokens_CreateRejectsCallerMetadataOwnerOverride(t *testing.T) {+ cfg := &config.Config{}+ persistence := config.NewConfigPersistence(t.TempDir())+ router := &Router{+ config: cfg,+ persistence: persistence,+ }++ req := httptest.NewRequest(http.MethodPost, "/api/security/tokens", strings.NewReader(`{}`))+ req = req.WithContext(authpkg.WithUser(req.Context(), "alice"))++ _, record, err := router.createAPITokenRecord(+ req,+ "bad-owner",+ []string{config.ScopeMonitoringRead},+ nil,+ map[string]string{+ apiTokenMetadataOwnerUserID: "[email protected]",+ },+ )+ if err == nil {+ t.Fatalf("expected reserved owner_user_id metadata to be rejected")+ }+ if !strings.Contains(err.Error(), "reserved token metadata key") {+ t.Fatalf("expected reserved metadata error, got %v", err)+ }+ if record != nil {+ t.Fatalf("expected no token record after rejected metadata, got %+v", record)+ }+ if len(cfg.APITokens) != 0 {+ t.Fatalf("expected no stored tokens after rejected metadata, got %d", len(cfg.APITokens))+ }+}