From 1f6f18d288dc0ed5ab710e7557a141227b62c0ea Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 14:14:03 +0000 Subject: [PATCH 1/2] refactor(plugin-auth): derive the SCIM connection-id cap from SCIM_SERVICE_PRINCIPAL_PREFIX MAX_SCIM_CONNECTION_ID spelled the svc:scim: prefix a second time; it now reads SCIM_SERVICE_PRINCIPAL_PREFIX.length, so the cap moves with the audit actor label it protects. The cap stays 246. The pending SCIM credential-door changeset gains an Exported line for the two public AuthManager methods behind the routes. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_017ihL2bjuYso9Pes3WcUTEb --- .changeset/30958-scim-connection-credential-door.md | 2 ++ .changeset/31033-scim-connection-id-cap-from-prefix.md | 10 ++++++++++ .../plugins/plugin-auth/src/scim-connection-admin.ts | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/31033-scim-connection-id-cap-from-prefix.md diff --git a/.changeset/30958-scim-connection-credential-door.md b/.changeset/30958-scim-connection-credential-door.md index d0174f757fd..a59f4fdd903 100644 --- a/.changeset/30958-scim-connection-credential-door.md +++ b/.changeset/30958-scim-connection-credential-door.md @@ -13,4 +13,6 @@ An identity provider (Okta, Entra ID) provisions users through `/api/v1/auth/sci - `POST /api/v1/auth/admin/scim/mint-credential` with `{ connectionId, label?, expiresAt?, provisioningDomainId?, organizationId? }` answers `{ credentialId, connectionId, token, expiresAt }`. `connectionId` is at most 246 characters, so the connection's audit actor `svc:scim:` fits `sys_audit_log.actor`. The `token` is shown once, in that response only (`Cache-Control: no-store`); only its keyed one-way digest is stored, and it is not readable through the data API, the audit log or the logs. Refused `503 SERVICE_UNAVAILABLE` while SCIM is off. The credential row is owned by `organizationId` when given (it must exist), otherwise by the Default Organization. - `POST /api/v1/auth/admin/scim/revoke-credential` with `{ credentialId }` switches the credential off, so the identity provider's next SCIM request with it answers `401`. `404 RESOURCE_NOT_FOUND` for an unknown credential, `409 RESOURCE_CONFLICT` for one already revoked. Served whether or not SCIM is on. +Exported: two public `AuthManager` methods back the routes. `isScimWired()` answers whether the SCIM service provider is mounted on this deployment (the same decision that mounts `/scim/v2`), and `mintScimConnectionCredential(engine, input)` mints a connection bearer with the deployment's auth secret, the key the mounted SCIM verifier digests with. + Rotation is a second mint for the same `connectionId`, moving the identity provider to the new bearer, then revoking the old one. Each mint and each revoke writes one `sys_audit_log` row naming the administrator and the connection, never the credential. Nothing that existed changes: no route, response or stored row moves, and the credential object stays read-only on the data API. diff --git a/.changeset/31033-scim-connection-id-cap-from-prefix.md b/.changeset/31033-scim-connection-id-cap-from-prefix.md new file mode 100644 index 00000000000..3c940a0210e --- /dev/null +++ b/.changeset/31033-scim-connection-id-cap-from-prefix.md @@ -0,0 +1,10 @@ +--- +'@objectstack/plugin-auth': patch +--- + +refactor(plugin-auth): the SCIM connection-id cap is derived from the exported service-principal prefix + +Clause-②: no +Metadata-protocol: none + +`POST /api/v1/auth/admin/scim/mint-credential` refuses a `connectionId` longer than 246 characters so the connection's audit actor `svc:scim:CONNECTION_ID` fits the 255 characters of `sys_audit_log.actor`. That cap was computed from the prefix spelled out a second time; it now reads the length of `SCIM_SERVICE_PRINCIPAL_PREFIX`, the constant the actor label itself is built from, so the two can no longer drift apart. Nothing a caller sees changes: the cap is still 246, and the refusal is still `400 INVALID_REQUEST`. diff --git a/packages/plugins/plugin-auth/src/scim-connection-admin.ts b/packages/plugins/plugin-auth/src/scim-connection-admin.ts index 3518047c3ae..2d6ff5fbc50 100644 --- a/packages/plugins/plugin-auth/src/scim-connection-admin.ts +++ b/packages/plugins/plugin-auth/src/scim-connection-admin.ts @@ -67,6 +67,7 @@ import type { PlatformAdminActor } from './platform-admin-gate.js'; import { readJsonRequestBody } from './request-json-body.js'; import { SCIM_CREDENTIAL_OBJECT, + SCIM_SERVICE_PRINCIPAL_PREFIX, revokeScimConnectionCredential, type MintScimConnectionCredentialInput, type MintedScimConnectionCredential, @@ -84,9 +85,11 @@ const MAX_TEXT = 255; * A write made by a SCIM connection is audited with the service actor * `svc:scim:` (#30960), and `sys_audit_log.actor` holds 255 * characters, so a longer id would make that audit insert fail for every - * request the connection makes. 255 minus the 9-character prefix. + * request the connection makes. 255 minus the 9-character prefix, read from + * {@link SCIM_SERVICE_PRINCIPAL_PREFIX} (the one spelling the actor label is + * built from) so the cap moves with the label it protects. */ -const MAX_SCIM_CONNECTION_ID = MAX_TEXT - 'svc:scim:'.length; +const MAX_SCIM_CONNECTION_ID = MAX_TEXT - SCIM_SERVICE_PRINCIPAL_PREFIX.length; /** Execution context for the store reads and the audit write. */ const SYSTEM_CTX = { isSystem: true } as const; From 56589092ed20f16c294e2a839b3f88d372232540 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Nov 2026 14:50:44 +0000 Subject: [PATCH 2/2] chore(changeset): move the AuthManager Exported line into this change's own changeset The pending SCIM credential-door changeset is restored byte-identical to main; the Exported paragraph naming isScimWired() and mintScimConnectionCredential() rides in this change's own patch note. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_017ihL2bjuYso9Pes3WcUTEb --- .changeset/30958-scim-connection-credential-door.md | 2 -- .changeset/31033-scim-connection-id-cap-from-prefix.md | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/30958-scim-connection-credential-door.md b/.changeset/30958-scim-connection-credential-door.md index a59f4fdd903..d0174f757fd 100644 --- a/.changeset/30958-scim-connection-credential-door.md +++ b/.changeset/30958-scim-connection-credential-door.md @@ -13,6 +13,4 @@ An identity provider (Okta, Entra ID) provisions users through `/api/v1/auth/sci - `POST /api/v1/auth/admin/scim/mint-credential` with `{ connectionId, label?, expiresAt?, provisioningDomainId?, organizationId? }` answers `{ credentialId, connectionId, token, expiresAt }`. `connectionId` is at most 246 characters, so the connection's audit actor `svc:scim:` fits `sys_audit_log.actor`. The `token` is shown once, in that response only (`Cache-Control: no-store`); only its keyed one-way digest is stored, and it is not readable through the data API, the audit log or the logs. Refused `503 SERVICE_UNAVAILABLE` while SCIM is off. The credential row is owned by `organizationId` when given (it must exist), otherwise by the Default Organization. - `POST /api/v1/auth/admin/scim/revoke-credential` with `{ credentialId }` switches the credential off, so the identity provider's next SCIM request with it answers `401`. `404 RESOURCE_NOT_FOUND` for an unknown credential, `409 RESOURCE_CONFLICT` for one already revoked. Served whether or not SCIM is on. -Exported: two public `AuthManager` methods back the routes. `isScimWired()` answers whether the SCIM service provider is mounted on this deployment (the same decision that mounts `/scim/v2`), and `mintScimConnectionCredential(engine, input)` mints a connection bearer with the deployment's auth secret, the key the mounted SCIM verifier digests with. - Rotation is a second mint for the same `connectionId`, moving the identity provider to the new bearer, then revoking the old one. Each mint and each revoke writes one `sys_audit_log` row naming the administrator and the connection, never the credential. Nothing that existed changes: no route, response or stored row moves, and the credential object stays read-only on the data API. diff --git a/.changeset/31033-scim-connection-id-cap-from-prefix.md b/.changeset/31033-scim-connection-id-cap-from-prefix.md index 3c940a0210e..43cb1a46ac1 100644 --- a/.changeset/31033-scim-connection-id-cap-from-prefix.md +++ b/.changeset/31033-scim-connection-id-cap-from-prefix.md @@ -8,3 +8,5 @@ Clause-②: no Metadata-protocol: none `POST /api/v1/auth/admin/scim/mint-credential` refuses a `connectionId` longer than 246 characters so the connection's audit actor `svc:scim:CONNECTION_ID` fits the 255 characters of `sys_audit_log.actor`. That cap was computed from the prefix spelled out a second time; it now reads the length of `SCIM_SERVICE_PRINCIPAL_PREFIX`, the constant the actor label itself is built from, so the two can no longer drift apart. Nothing a caller sees changes: the cap is still 246, and the refusal is still `400 INVALID_REQUEST`. + +Exported (completing the record of the SCIM credential routes, whose release note names the routes only): two public `AuthManager` methods back them. `isScimWired()` answers whether the SCIM service provider is mounted on this deployment (the same decision that mounts `/scim/v2`), and `mintScimConnectionCredential(engine, input)` mints a connection bearer with the deployment's auth secret, the key the mounted SCIM verifier digests with.