Repository navigation
fix(plugin-auth): Set Manager refuses only a person a SCIM directory holds - #33991
Conversation
The directory refusal read sys_user.source = idp_provisioned alone, a mark ADR-0135 D4 stamps on every SSO link without a local password, so an admin could not change the manager of anyone who had signed in through SSO. It now also requires a sys_scim_subject row, through the SCIM-held predicate the adoption judge uses (extracted, not copied). Set Manager shows for every platform admin; the lint remedy and docs say who is refused. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
…tity Its set-manager refusal now needs a sys_scim_subject row beside the idp_provisioned mark, so the fixture carries one. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
📓 Docs Drift CheckThis PR changes 3 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 26 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 866f210f821ba351173e709307ba23ac5f7ff840 && git checkout 866f210f821ba351173e709307ba23ac5f7ff840
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bc6b7ffd454ba9c2c420975c84a400779cb02262 5787dda5126ee75af2bb2cef8ab2f1b5d3776d33 && git checkout -B drift-repro bc6b7ffd454ba9c2c420975c84a400779cb02262 && git merge --no-ff 5787dda5126ee75af2bb2cef8ab2f1b5d3776d33
node scripts/docs-audit/affected-docs.mjs --json bc6b7ffd454ba9c2c420975c84a400779cb02262
|
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Contract reviewServed-tier: ① Derived judgments
② Semver levelminor-or-patch behaviour widening on a server door: no schema, export of a published package surface, key or wire field added or removed. ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv Request: review · PR #33991 · S1/A1 · Fixes #33200 · head fa70eaa · 2026-11-15T16:06Z Reviewer: review-a of seat |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM |
|
domain:server#5 · zhuangjianguo · session_01QsR2jTjrNnh6b2BkCXFugM Review — PASSHead-sha: Contract face: What holds
Nits (no re-review needed)
Gates: at review time 58 success, 10 skipped, none red, so every check is green. |
|
domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv 席位核对 · ACCEPT · Head-sha: 5787dda · 2026-11-15T16:48Z
|
…wered with the generic message and logged (objectstack-ai#34050) Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:plugin-auth 三个辅助结果映射器(admin 用户门共用的 `mapAuthApiError`、服务账号注册的成员映射、`set-initial-password` 映射)以及 `sys-oauth-application/register` 路由的内层 catch,对未分类的内部故障改答通用文案,并用插件已有的 logger 按路由名记一次 error 日志。 - 为什么改:与 `auth-plugin.ts` 各路由 catch 已执行的同一条规则对齐:未分类的内部故障只答通用文案并在服务端记日志;厂商带 body code 的拒绝、4xx 的拒绝保持原样。 - 风险与回滚:仅 500 类答复的 message 文本变化,code(`INTERNAL_ERROR`)与 status 不变;无文档或客户端解析该文本。回滚即还原本 PR。 - 先看:`packages/plugins/plugin-auth/src/admin-user-endpoints.ts`(`mapAuthApiError` 的分类分支)、`auth-plugin.ts`(`sys-oauth-application/register` 内层 catch)、`service-account-doors.ts`(`vendorRefusal`)。 - 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/set-initial-password.test.ts`,预期全部通过,其中「an unclassified internal failure is answered with the generic message and logged once」一组为绿。 - 需要你做的:无,席位落地 ## What changes The rule, already applied by every route catch in `auth-plugin.ts`: a route's unclassified internal failure is answered with a generic message, and the error is logged server-side. A refusal the vendor classifies (it carries a body code) keeps its own message and status, and so does a throw whose status addresses the caller (4xx). This PR applies it to the three result mappers the auth doors answer through, and to one route catch that did not yet follow it: - `mapAuthApiError` (`admin-user-endpoints.ts`), shared by create-user, set-user-password, import-users, add-sso-user / import-sso-users (organization join) and `/organization/add-member`: an unclassified failure answers `INTERNAL_ERROR` with `INTERNAL_ERROR_MESSAGE` from `@objectstack/types`, the constant those routes' own catches use, and is logged once as `[AuthPlugin] ROUTE failed`. - `vendorRefusal` (`service-account-doors.ts`), the membership step of `/service-account/register`: after the existing declared-refusal check, an unclassified failure answers `INTERNAL_ERROR` with `The request could not be completed.`, the words that route's own catch (and this file's `WITHHELD_SERVER_MESSAGE`) uses, and is logged once as `[AuthPlugin] service-account/register failed`. - `mapSetPasswordError` (`set-initial-password.ts`): an unclassified failure answers `INTERNAL_ERROR` with `INTERNAL_ERROR_MESSAGE`, logged once as `[AuthPlugin] set-initial-password failed`. - The inner catch of `POST /sys-oauth-application/register` (`auth-plugin.ts`, the client-creation call): a throw with no vendor body and no 4xx status answers `OAUTH_REGISTER_FAILED` with `INTERNAL_ERROR_MESSAGE` (the constant the route's outer catch uses) at the status `resolveThrownHttpError` reads, logged once with `ctx.logger` as `[AuthPlugin] sys-oauth-application/register failed`. A vendor refusal (it carries a body) keeps its `error_description`, its `details.upstreamError` and its status. Logging seam: each helper is handed the logger the plugin already holds (`ctx.logger`), through an optional `logger` on its deps or options (`error` added as optional to the existing `logger` on `AdminUserEndpointDeps`, `IdentityImportDeps`, `PendingSsoUserDeps`; a new optional `logger` on `OrganizationAddMemberDeps`, `ServiceAccountDoorDeps`, `SetInitialPasswordOptions`; an optional third argument on `mapAuthApiError`). Otherwise `auth-plugin.ts` gains only those hand-offs at three call sites (`set-initial-password`, the service-account deps factory, `/organization/add-member`); no other route catch, no before-hook and no vendor-classified refusal changes. No new dependency, no module-level console, no new error code, nothing in `packages/spec`. **Why this is not breaking.** For each changed answer the status and the code (`INTERNAL_ERROR`, or `OAUTH_REGISTER_FAILED` at the OAuth registration) are unchanged; only the message of an unclassified internal failure changes. Measured: no page under `content/docs/**` names these routes' 500 message text, the error catalog (`packages/spec/src/api/errors.zod.ts`, the error-code ledger) pins the code only, and `git grep` over `ui/`, `packages/client` and `packages/client-react` finds no consumer that reads these fallback texts. Every refusal (a vendor body code, a declared hook refusal, a 4xx status) answers byte-identically. The new deps fields and the third argument are optional, so an existing host compiles and answers the generic message without a log line. Hence a `patch` changeset with `Clause-②: no`. ## Tests Named by the rule, each helper beside its CONTROLs: - `set-initial-password.test.ts` — the existing unclassified-throw row now asserts the rule: the generic answer, and the logger called once with the route and the error; a thrown non-Error reaches the logger as an `Error`; CONTROL a vendor body-coded refusal keeps its message, code and status and is not logged; CONTROL a 4xx throw keeps its answer. - `admin-user-endpoints.test.ts` — the shared mapper directly, then through create-user and set-user-password; CONTROLs for a vendor body-coded refusal (409 normalisation included) and a 4xx throw. - `organization-add-member.test.ts`, `admin-import-users.test.ts` — the two other mapper callers hand the logger on; CONTROL a vendor body-coded refusal at add-member. - `oauth-register-refusal-status.test.ts` — on the real route over real better-auth: a client-creation call that throws with no declared status answers 500 in the generic words and the route's log line receives the error once; CONTROL a vendor refusal keeps the vendor's own description, `upstreamError` and status, with no log line. The file's existing pins (declared 4xx statuses, the storage fault at 500, the accepted registration) stay green. - `service-account-doors.test.ts` — the membership step: generic answer, logged once, nothing written; CONTROL a vendor body-coded refusal keeps its prefixed message and status; CONTROL a 4xx throw keeps its answer. The suite's deps now carry the logger. <details><summary>Measured before the fix (rule rows red), and the suite after</summary> - Before (the rule tests against the source of the base commit, tests otherwise as in this PR): `Test Files 5 failed (5) · Tests 8 failed | 194 passed (202)`; the 8 failures are exactly the unclassified rows across the three mappers; every CONTROL passed. The OAuth registration row, before its fix: `Tests 1 failed | 8 passed (9)`, the CONTROL passing. - After, `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2` at `dbe556761a`: `Test Files 277 passed (277) · Tests 5531 passed | 10 skipped (5541)`, lock VERDICT command-exit 0. - `pnpm --filter @objectstack/plugin-auth typecheck` (after building the package for its examples program): exit 0; `check:test-typecheck: OK`. </details> ## Acceptance notes - The cloud twin of `set-initial-password` calls `runSetInitialPassword` without a logger: it now answers the generic message, and logs only once it passes its own logger in `SetInitialPasswordOptions.logger`. - A body-less throw with a 4xx status keeps its message at these mappers (the repo's thrown-error rule: a 4xx message is addressed to the caller). Such a throw is still answered with the code `INTERNAL_ERROR` rather than a code its status derives; that pre-existing labelling is unchanged here. - `PR objectstack-ai#33991` touches a docblock of `admin-import-users.ts` far from these hunks; no overlap. ## Verification <details><summary>Ablation: each site's generic arm put back to the thrown-message arm, then restored</summary> Each mutation went through `scripts/ablation-replace.mjs` (anchor hit 1 to 0, blob changed) on a committed head, and each restore was proven by the tool (blob equal to HEAD, `git diff HEAD` empty): - `set-initial-password.ts`: `Tests 2 failed | 9 passed (11)`, then restored. - `admin-user-endpoints.ts` (`mapAuthApiError`, with the add-member and import-users suites): `Tests 5 failed | 156 passed (161)`, then restored. - `service-account-doors.ts`: `Tests 1 failed | 29 passed (30)`, then restored. - `auth-plugin.ts` (the OAuth registration inner catch): `Tests 1 failed | 8 passed (9)`, then restored. The tests import each subject from `src/` by relative path, so no `dist/` sits between the mutation and the run. </details> Local readings on the final head `8c878cc253`: - `dispatch-gates --commands`: 76 families derived, all 76 run (`--ran`: 76 derived, 76 run, 0 NOT-MEASURED, 0 UNRUN), every exit 0. `check:optional-error-sink` flagged the first logger shape at `dbe556761a`; the fix is in this head and the gate now exits 0. - Dogfood battery, under the verify lock: `Test Files 467 passed | 3 skipped (470)` · `Tests 3962 passed | 42 skipped (4004)`, no failures, VERDICT command-exit 0. Every other family is CI's. --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_ <!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steedos · project thread
Fixes #33200
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
idp_provisioned,旧规则把他们全当成「目录持有」,登录后上级就再也改不了,按上级流转的审批跟不上组织调整。按裁决记录 6895645364 选项 A 修。sys_scim_subject,读失败返回 500 且不写入。回滚即 revert 本 PR。admin-set-user-manager.ts的 refusal 5 判断(applyUserManagerLink);scim-sso-adoption.ts新导出的isHeldByScimDirectory;sys-user.object.ts的set_user_managervisible。pnpm --filter @objectstack/plugin-auth exec vitest run src/admin-set-user-manager.test.ts,预期 38 个全过,其中 "an SSO-only identity ... is SET like a local one" 为 200 并写入manager_id。What changes
Built to the maintainer ruling recorded in 6895645364 (option A: only identities a SCIM directory holds stay locked).
POST /api/v1/auth/admin/set-user-manager(refusal 5). It refused onsys_user.source = 'idp_provisioned'alone. ADR-0135 D4 stamps that value on every federated link without a local password, so a person who only signs in through SSO carried it with no directory behind them. The refusal now also needs asys_scim_subjectrow. The answer for a SCIM-held identity keeps its envelope (403 PERMISSION_DENIED,details.reason: 'idp_provisioned'), and the message says to change the manager in the directory. It no longer claims a sync would revert the value, because nothing projects the SCIMmanagerattribute onto the column today. The self, cycle, depth and cross-organization refusals are unchanged.scim-sso-adoption.tsnow exportsisHeldByScimDirectory(engine, userId). It is the samesys_scim_subjectread its adoption judge already ran as condition 2, moved into an exported function. The judge calls it, and so does the endpoint. A missingsys_scim_subjecttable reads as "not held" at the endpoint. Any other read failure propagates, so the mount answers 500 and writes nothing.sourceterm stays a conjunct. A SCIM-provisioned user with a local password isenv_nativeunder D4 and was accepted before. Requiring the SCIM row alone would have refused that user, so the endpoint still checkssourcetoo, and no request that was served before is refused now.applyUserManagerLink, so theirmanager_idlinks follow the same rule with no code change. The import docblock now says who is refused.sys_user.set_user_managervisibility iscurrent_user.isPlatformAdmin == true. No column on the row says "held by SCIM", so the button is shown on every row and the endpoint refuses a SCIM-held one with its message. No new field or key.os explain approval-approvers-may-resolve-emptynow says the operation refuses an identity a SCIM directory holds, and that an identity that only signs in through SSO is set like any other. The docblock invalidate-approval-approvers.tssays the same.content/docs/automation/approvals.mdx,content/docs/capabilities/approvals.mdxandcontent/docs/permissions/authentication.mdxstate the narrowed refusal.idp_provisionedstamp (ADR-0135 D4) and the password refusals are untouched.Tests
On head
fa70eaa06:admin-set-user-manager.test.ts, refusal 5 rewritten. SCIM-held SET and CLEAR give 403PERMISSION_DENIED/idp_provisioned, write nothing, and readsys_scim_subjectfor that user. SSO-only SET and CLEAR give 200, andupdategets{ id, manager_id }. An SSO-only self-assignment is still a 400self_assignment.env_nativegives 200, also with a SCIM subject, and the SCIM table is not read. A missing table gives 200. A failed read rejects and writes nothing.admin-import-users-manager-pass.test.ts: a SCIM-held row is refused withidp_provisioned. An SSO-only row islinked, andmanager_idis written. The no-fork pin also asserts that the importer spells neithersys_scim_subjectnorisHeldByScimDirectory.demo-staff.test.ts: the refusal fixture is now a SCIM-held identity.sys-user-set-manager-action.test.tsandplatform-objects.test.ts: the action is offered on anidp_provisionedrow and on the sparse face. It is hidden from a non-admin. It reads no record column, which has a positive control on the standing term.validate-approval-approvers.test.ts: the new prescription is present, and the oldsource 'idp_provisioned'sentence is absent.Suite runs
@objectstack/plugin-authfull suite (locked, before the demo-staff fixture fix): 276/277 files. The one red wasdemo-staff.test.ts, whose fixture is fixed in the next commit. Re-run:demo-staff.test.ts+demo-staff-provisioning.test.ts32/32.@objectstack/platform-objectsfull: 122 files, 1994 tests passed.@objectstack/lintfull: 212 files, 9026 tests passed.check:test-typecheck), platform-objects and lint.@objectstack/runtimeplatform-admin-action-gate.test.ts16/16.Ablations (each mutation landed by ablation-replace.mjs, restored to the HEAD blob)
sourcealone (the old predicate): 7 red, incl. every SSO-only pin in both endpoint and import suites.sourceconjunct): 1 red, "env_native ... even one that owns a SCIM subject".record.sourceterm back onvisible: 5 red acrosssys-user-set-manager-action.test.tsandplatform-objects.test.ts.Acceptance notes
managerprojection lands. The ruling records this and the separate card SCIM: project the enterprisemanagerattribute into sys_user.manager_id, so SCIM-held users' managers can change at all #33918 carries it.helpTextstill lists the four other refusals and not the SCIM one. The endpoint message names the directory. ChanginghelpTextwould move nine translation bundles, so it is left as it is.details.reasonkeeps the valueidp_provisionedso no client keyed on it changes. Only the predicate behind it narrowed.Verification
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 105 derived families. 101 exit 0. 3 exit 3 (prerequisite not met, NOT MEASURED, left to CI):check:skill-examples,check:dual-build-cjs-loads,check:i18n. 1 not run:check:type-check-debt, because the verify lock was held by another run for more than 60 minutes.--ranreconciliation agrees.--tier: no path-derived mandate. The same verdict as merged fix(runtime,service-automation)!: the flow doors judge the served holders, so a disabled holder's slot answers no bare name (ADR-0150 D3) #33646 and fix(cloud-connection, driver-sql): a package upgrade relaxes the NOT NULL its own declaration makes nullable #33769..tsfiles: exit 0.check-nul-bytes: OK.git merge-tree --write-treeof this head againstorigin/main, fix(platform-objects): hide Resend Invitation on a cloud-managed environment #33956, fix(auth)!: a cloud-managed environment sets no local password for anyone, a platform administrator included #33268 and branchclaude/area-A2-33828: clean, no conflicted paths.Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
🤖 Generated with Claude Code