You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fb79d47
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-auth): Set Manager refuses only a person a SCIM directory holds (#33991)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbSUQWB2j9eHYsRcrCiq1X1C)_Fixes#33200
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- **改了什么:** 「设置上级」(Set Manager) 现在只拒绝真正由 SCIM 目录同步的人;只通过 SSO
登录、背后没有目录的人,管理员可以照常改上级。按钮对平台管理员在每一行用户上都显示。
- **为什么改:** 托管环境里第一次通过平台 SSO 登录的人都会被标成
`idp_provisioned`,旧规则把他们全当成「目录持有」,登录后上级就再也改不了,按上级流转的审批跟不上组织调整。按裁决记录
6895645364 选项 A 修。
- **风险与回滚:** 只放宽:以前能成功的请求没有一个变成拒绝。SCIM 判定多读一次 `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_manager`
`visible`。
- **两分钟验证:** `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
on `sys_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 a `sys_scim_subject` row. 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 SCIM `manager` attribute onto the
column today. The self, cycle, depth and cross-organization refusals are
unchanged.
- **One predicate, imported.** `scim-sso-adoption.ts` now exports
`isHeldByScimDirectory(engine, userId)`. It is the same
`sys_scim_subject` read its adoption judge already ran as condition 2,
moved into an exported function. The judge calls it, and so does the
endpoint. A missing `sys_scim_subject` table reads as "not held" at the
endpoint. Any other read failure propagates, so the mount answers 500
and writes nothing.
- **The `source` term stays a conjunct.** A SCIM-provisioned user with a
local password is `env_native` under D4 and was accepted before.
Requiring the SCIM row alone would have refused that user, so the
endpoint still checks `source` too, and no request that was served
before is refused now.
- **Bulk import and demo staff.** Both run `applyUserManagerLink`, so
their `manager_id` links follow the same rule with no code change. The
import docblock now says who is refused.
- **`sys_user.set_user_manager` visibility** is
`current_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.
- **Lint prescription.** `os explain
approval-approvers-may-resolve-empty` now 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 in
`validate-approval-approvers.ts` says the same.
- **Docs.** `content/docs/automation/approvals.mdx`,
`content/docs/capabilities/approvals.mdx` and
`content/docs/permissions/authentication.mdx` state the narrowed
refusal.
- ⛔ The `idp_provisioned` stamp (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 403 `PERMISSION_DENIED` / `idp_provisioned`, write
nothing, and read `sys_scim_subject` for that user. SSO-only SET and
CLEAR give 200, and `update` gets `{ id, manager_id }`. An SSO-only
self-assignment is still a 400 `self_assignment`. `env_native` gives
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
with `idp_provisioned`. An SSO-only row is `linked`, and `manager_id` is
written. The no-fork pin also asserts that the importer spells neither
`sys_scim_subject` nor `isHeldByScimDirectory`.
- `demo-staff.test.ts`: the refusal fixture is now a SCIM-held identity.
- `sys-user-set-manager-action.test.ts` and `platform-objects.test.ts`:
the action is offered on an `idp_provisioned` row 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 old `source 'idp_provisioned'` sentence is absent.
<details><summary>Suite runs</summary>
- `@objectstack/plugin-auth` full suite (locked, before the demo-staff
fixture fix): 276/277 files. The one red was `demo-staff.test.ts`, whose
fixture is fixed in the next commit. Re-run: `demo-staff.test.ts` +
`demo-staff-provisioning.test.ts` 32/32.
- Targeted: plugin-auth 3 files 76/76; platform-objects 2 files 169/169;
lint 1 file 64/64.
- `@objectstack/platform-objects` full: 122 files, 1994 tests passed.
`@objectstack/lint` full: 212 files, 9026 tests passed.
- Typecheck exit 0 for plugin-auth (all three legs, incl.
`check:test-typecheck`), platform-objects and lint.
- Dependent: `@objectstack/runtime` `platform-admin-action-gate.test.ts`
16/16.
</details>
<details><summary>Ablations (each mutation landed by
ablation-replace.mjs, restored to the HEAD blob)</summary>
- A1, refuse on `source` alone (the old predicate): 7 red, incl. every
SSO-only pin in both endpoint and import suites.
- A2, no refusal 5 at all: 4 red, incl. SCIM-held SET, CLEAR and the
import row.
- A3, refuse on the SCIM row alone (drop the `source` conjunct): 1 red,
"env_native ... even one that owns a SCIM subject".
- A4, swallow every SCIM read failure: 1 red, "a FAILED SCIM-subject
read is never read as no directory".
- A5, put the `record.source` term back on `visible`: 5 red across
`sys-user-set-manager-action.test.ts` and `platform-objects.test.ts`.
- A6, put the old lint sentence back: 1 red, "GRADES the routes".
- A7, missing table rethrows: 1 red, "a missing sys_scim_subject table
means no directory".
</details>
## Acceptance notes
- SCIM-held users stay unchangeable from both sides until the SCIM
`manager` projection lands. The ruling records this and the separate
card #33918 carries it.
- The action's `helpText` still lists the four other refusals and not
the SCIM one. The endpoint message names the directory. Changing
`helpText` would move nine translation bundles, so it is left as it is.
- `details.reason` keeps the value `idp_provisioned` so 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. `--ran` reconciliation agrees.
- `--tier`: no path-derived mandate. The same verdict as merged #33646
and #33769.
- eslint on the changed `.ts` files: exit 0. `check-nul-bytes`: OK.
- `git merge-tree --write-tree` of this head against `origin/main`,
#33956, #33268 and branch `claude/area-A2-33828`: clean, no conflicted
paths.
Session: https://claude.ai/code/session_01QsR2jVPGBoi3MCGoKbW1Hv
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
fix(plugin-auth): Set Manager refuses only a person a SCIM directory holds, so an admin can change the manager of someone who signs in through SSO
8
+
9
+
Clause-②: yes (widening)
10
+
Metadata-protocol: none
11
+
12
+
`POST /api/v1/auth/admin/set-user-manager` refused every user whose `sys_user.source` is `idp_provisioned` with `403 PERMISSION_DENIED`, saying a directory owns their manager. ADR-0135 D4 stamps that value on every sign-in through an identity provider by a person with no local password: the platform's own SSO on a hosted environment, and any social or enterprise OIDC provider. Those people have no directory behind them. So after their first sign-in, nobody could change their manager, and approvals routed to the manager could not follow a reorganisation.
13
+
14
+
The endpoint now refuses only a person a SCIM directory holds: `source` is `idp_provisioned` and a SCIM connection has provisioned or linked them (a `sys_scim_subject` row). The answer is unchanged for them (`403 PERMISSION_DENIED`, `details.reason: 'idp_provisioned'`), and its message says to change the manager in the directory. Everyone else gets the answer a local user gets. The admin user import's `manager_id` column runs the same check, so an SSO-only row's manager link now lands. The self-assignment, cycle, depth and cross-organization refusals are unchanged. Nothing that was accepted before is refused now.
15
+
16
+
`sys_user`'s **Set Manager** action is now offered to a platform admin on every user row. It used to be hidden on `idp_provisioned` rows. A SCIM-held row is refused by the endpoint, which names the directory.
17
+
18
+
`os explain approval-approvers-may-resolve-empty` now says the admin operation refuses an identity a SCIM directory holds, and that an identity that only signs in through SSO is set like any other.
19
+
20
+
The `idp_provisioned` stamp itself (ADR-0135 D4) and the password refusals are unchanged.
0 commit comments