Skip to content

Commit e1a0350

Browse files
committed
fix(plugin-auth): set-user-manager refuses only a SCIM-held identity
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
1 parent 895783a commit e1a0350

15 files changed

Lines changed: 296 additions & 91 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/platform-objects': patch
4+
'@objectstack/lint': patch
5+
---
6+
7+
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.

‎content/docs/automation/approvals.mdx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ row's `manager` result: a link it cannot make never fails the user it imported.
100100
The column is also written by a seed, or by any other system-context write, which bypasses the
101101
managed-update whitelist. SCIM provisioning and directory sync can populate it too, but only
102102
through a provisioning path your own deployment supplies: this platform declares the SCIM
103-
`manager` attribute without projecting it onto the column. Where an identity carries
104-
`source: 'idp_provisioned'` the admin operation **refuses**, so that directory stays the one
105-
surface that authors its manager. A user a SCIM connection provisions carries that value from its
106-
creation unless it holds a local password, so for such a user the column is written only by that
107-
deployment-supplied path, and a value the column already holds stays as it is.
103+
`manager` attribute without projecting it onto the column. Where a SCIM directory holds an
104+
identity (it carries `source: 'idp_provisioned'` and the directory has provisioned or linked it)
105+
the admin operation **refuses**, the import's `manager_id` column included, so that directory
106+
stays the one surface that authors its manager; for such a user the column is written only by that
107+
deployment-supplied path, and a value the column already holds stays as it is. A person who only
108+
signs in through SSO also carries `source: 'idp_provisioned'`, but no directory holds them: their
109+
manager is set with **Set Manager** or the import like anyone else's.
108110

109111
Setting the column is still something you have to *do*. Where `manager_id` is unset the rung
110112
expands to nobody, and under the default `onEmptyApprovers: 'admin_rescue'` the request opens on

‎content/docs/capabilities/approvals.mdx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ A specific person · everyone holding a position (e.g. sales managers) · the su
1515
**Routing to the submitter's manager needs each user's manager set.** This style resolves
1616
`sys_user.manager_id`, which is not a profile field: editing the user does not set it. A platform
1717
admin sets it one user at a time from **Setup → Users → ⋯ → Set Manager**, which calls
18-
`POST /api/v1/auth/admin/set-user-manager`. For many users at once, provisioning fills it: the
18+
`POST /api/v1/auth/admin/set-user-manager` — for anyone, people who sign in through SSO included,
19+
except a person a SCIM directory holds, whose manager is changed in that directory. For many users at once, provisioning fills it: the
1920
admin bulk-import endpoint reads a `manager_id` column, and a seed, or a SCIM / directory-sync
2021
path your deployment supplies, can write it too. Until it is set, a manager-only approval step
2122
resolves to nobody and the node's `onEmptyApprovers` policy decides what happens — by default the

‎content/docs/permissions/authentication.mdx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ sign-in through any other one leaves the person pending. Their positions, permis
12901290
from the moment they are added, so seed data and approval flows can name them
12911291
before they sign in. Off a managed environment both doors answer `409`.
12921292

1293+
Signing in does not lock the manager: a platform administrator still changes
1294+
it with **Set Manager** (`POST /api/v1/auth/admin/set-user-manager`). That
1295+
endpoint refuses only a person a SCIM directory holds, whose manager is changed
1296+
in the directory.
1297+
12931298
A host can be told about people as they come and go: the `environmentUserHost`
12941299
option of the auth plugin is called after a person is added, and before a
12951300
person is deactivated (`admin/ban-user`) or reactivated (`admin/unban-user`).

‎packages/lint/src/rule-explanations.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,9 +3336,10 @@ const MANAGER_ONLY_ROUTES =
33363336
'write, which bypasses the managed-update whitelist. SCIM provisioning and directory sync can ' +
33373337
'populate it too, but only through a provisioning path your own deployment supplies: this ' +
33383338
'platform declares the SCIM \'manager\' attribute without projecting it onto the column — and ' +
3339-
'where an identity carries source \'idp_provisioned\' the admin operation refuses, the import\'s ' +
3339+
'where a SCIM directory holds an identity the admin operation refuses, the import\'s ' +
33403340
'manager_id column included, leaving that directory the one surface that authors its ' +
3341-
'manager. Or declare onEmptyApprovers: \'fallback\' on the node, with a ' +
3341+
'manager. An identity that only signs in through SSO, with no SCIM directory behind it, is set ' +
3342+
'through the admin operation like any other. Or declare onEmptyApprovers: \'fallback\' on the node, with a ' +
33423343
'fallbackApprovers list: an empty manager rung then opens the request on those people instead ' +
33433344
'of on the organization\'s administrators, which needs no write to the column at all.';
33443345

‎packages/lint/src/validate-approval-approvers.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,18 @@ describe('unset-manager dead-end (#16748)', () => {
375375
// ⛔ And they must not be deleted: a deployment running a real directory
376376
// sync may well populate the column, and the defect was presenting all
377377
// three as equally available, never naming them at all. They now also take
378-
// PRECEDENCE — the endpoint refuses an `idp_provisioned` identity, and so
379-
// does the import's `manager_id` column, which runs the same derivation —
378+
// PRECEDENCE — the endpoint refuses an identity a SCIM directory holds, and
379+
// so does the import's `manager_id` column, which runs the same derivation —
380380
// so the hint must not read as "use the endpoint instead of your directory".
381381
expect(remedy).toContain('SCIM provisioning and directory sync can populate it');
382-
expect(remedy).toContain("source 'idp_provisioned' the admin operation refuses");
382+
expect(remedy).toContain('where a SCIM directory holds an identity the admin operation refuses');
383383
expect(remedy).toContain("the import's manager_id column included");
384+
// ⛔ But only where a directory exists: the `idp_provisioned` mark alone
385+
// also covers a person who only signs in through SSO, whose manager the
386+
// endpoint sets (maintainer ruling record 6895645364). A remedy that sent
387+
// that admin to a directory they do not have cannot be carried out.
388+
expect(remedy).not.toContain("source 'idp_provisioned' the admin operation refuses");
389+
expect(remedy).toContain('only signs in through SSO');
384390
});
385391

386392
it('the one-line `fix:` names the first route and the escape, and never the Console form', () => {

‎packages/lint/src/validate-approval-approvers.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ const STAYS_LOCKED = ', and (lockRecord) the record stays locked';
144144
* It reaches the column under a SYSTEM context — by context, ⛔ not by a
145145
* whitelist entry — which is why the whitelist reading above is unchanged.
146146
* It refuses self-assignment, a link that closes a cycle, a chain past its
147-
* depth cap, a manager provably outside the user's organizations, and any
148-
* identity whose `sys_user.source` is `idp_provisioned`.
147+
* depth cap, a manager provably outside the user's organizations, and an
148+
* identity a SCIM directory holds (`sys_user.source` `idp_provisioned` AND
149+
* a `sys_scim_subject` row). An `idp_provisioned` identity with no SCIM
150+
* subject — a person who only signs in through SSO — is set like any other
151+
* (maintainer ruling record 6895645364).
149152
* - Seed, or any other system-context write — AVAILABLE HERE, unchanged.
150153
* Both write guards gate on `isUserContextWrite`, spelled identically in
151154
* each: `Boolean(userId) && isSystem !== true` (plugin-security
@@ -179,7 +182,7 @@ const STAYS_LOCKED = ', and (lockRecord) the record stays locked';
179182
* one may well populate the column through it — but named as something the
180183
* operator's own provisioning supplies, ⛔ never as something this repo gives
181184
* them. They also now have PRECEDENCE over the endpoint rather than merely
182-
* sitting beside it: on an `idp_provisioned` identity the endpoint refuses, so
185+
* sitting beside it: on an identity a SCIM directory holds the endpoint refuses, so
183186
* the directory is the one authoring surface for those rows.
184187
*
185188
* ⛔ WHAT DID NOT CHANGE — and why this rule is not deleted. The dead end the

‎packages/platform-objects/src/identity/sys-user-set-manager-action.test.ts‎

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@
1515
* managed-update whitelist is `{name, image, locale}`, so a picker that
1616
* PATCHed `/api/v1/data/sys_user/:id` would be refused by the identity
1717
* write guard — correctly — and would read as a Console bug.
18-
* 2. **The `visible` predicate carries the directory-sync term and NOT the
19-
* self-service ownership term.** The three self-service identity actions
20-
* on this object spell `record.source != "idp_provisioned"` as one half of
21-
* `record.id == ctx.user.id && …`. Copying that predicate whole — the
22-
* natural thing to do, and what a reader of the card would do — would hide
23-
* an ADMIN action on someone else's row from every admin. The failure is
24-
* silent and fail-closed (#8990): the button simply is not offered.
18+
* 2. **The `visible` predicate reads NO record column — neither the
19+
* self-service ownership term nor the `source` term.** The three
20+
* self-service identity actions on this object spell
21+
* `record.source != "idp_provisioned"` beside `record.id == ctx.user.id`.
22+
* Copying either half — the natural thing to do — hides an ADMIN action
23+
* from rows the endpoint accepts: the ownership half from every admin,
24+
* the `source` half from every person who only signs in through SSO
25+
* (ADR-0135 D4 stamps them `idp_provisioned` with no directory behind
26+
* them; maintainer ruling record 6895645364, option A, has the endpoint
27+
* refuse only an identity a SCIM directory holds). The failure is silent
28+
* and fail-closed (#8990): the button simply is not offered.
2529
* 3. **No second copy of the server's refusals.** Self-assignment, cycle,
26-
* depth, cross-organization and directory-owned identity are all enforced
30+
* depth, cross-organization and SCIM-held identity are all enforced
2731
* at the write, in one derivation (`applyUserManagerLink`), which the bulk
2832
* importer already routes onto rather than re-deriving. A client-side
2933
* duplicate is the drift, not the safety net — so this file pins that the
30-
* declaration reads exactly one record column and declares no predicate
31-
* for any of the other four refusals.
34+
* declaration reads no record column and declares no predicate for any
35+
* of the five refusals.
3236
*
3337
* The sweep in `action-predicate-sparse-face.test.ts` already covers this
3438
* action's predicate for the sparse-face guard; that is deliberately not
@@ -130,14 +134,17 @@ describe('#19249 — sys_user.set_user_manager posts the admin endpoint', () =>
130134
it('⛔ declares no second copy of the server-side refusals', () => {
131135
// Every refusal is enforced at the write and surfaces from there. What
132136
// would go wrong quietly is a client-side re-derivation drifting from the
133-
// endpoint's; so the predicate is pinned to the ONE column it reads, and
134-
// the declaration to having no other gate at all.
137+
// endpoint's; so the predicate is pinned to reading no record column at
138+
// all, and the declaration to having no other gate.
135139
const visible = sourceOf(ACTION.visible);
136140
expect(visible).toBeDefined();
141+
// Positive control: the standing term really is there, so the empty column
142+
// set below is a reading of the predicate, not of an absent one.
143+
expect(visible).toContain('current_user.isPlatformAdmin == true');
137144
const columns = new Set(
138145
[...visible!.matchAll(/record\.([a-z_][a-z0-9_]*)/gi)].map((m) => m[1]),
139146
);
140-
expect([...columns]).toEqual(['source']);
147+
expect([...columns]).toEqual([]);
141148
expect(ACTION.disabled).toBeUndefined();
142149
// The manager chain, the organization screen and the self-assignment check
143150
// are the endpoint's; none of them is expressible — or declared — here.
@@ -148,15 +155,22 @@ describe('#19249 — sys_user.set_user_manager posts the admin endpoint', () =>
148155
});
149156
});
150157

151-
describe('#19249 — the visible predicate: directory-sync term, NOT the self-service one', () => {
158+
describe('the visible predicate: offered on every row, the SCIM-held refusal is the server\'s', () => {
152159
const visible = (): string => {
153160
const source = sourceOf(ACTION.visible);
154161
if (!source) throw new Error('set_user_manager has no CEL source');
155162
return source;
156163
};
157164

158-
it('is hidden for a directory-owned identity (the server answers 403 idp_provisioned)', () => {
159-
expect(evaluate(visible(), { source: 'idp_provisioned' })).toBe(false);
165+
it('⭐ is OFFERED on an idp_provisioned row — an SSO-only person\'s manager is set here', () => {
166+
// The endpoint answers 200 for this row unless a SCIM directory holds it,
167+
// and no column on the row says which; hiding the button here hid it from
168+
// every person who ever signed in through SSO.
169+
expect(evaluate(visible(), { id: 'someone_else', source: 'idp_provisioned' })).toBe(true);
170+
});
171+
172+
it('is OFFERED on the sparse face too (no source column projected)', () => {
173+
expect(evaluate(visible(), { id: 'someone_else' })).toBe(true);
160174
});
161175

162176
it('⭐ is OFFERED to an admin on someone else\'s env-native row', () => {
@@ -165,13 +179,22 @@ describe('#19249 — the visible predicate: directory-sync term, NOT the self-se
165179
expect(evaluate(visible(), { id: 'someone_else', source: 'env_native' })).toBe(true);
166180
});
167181

168-
it('carries the same directory-sync term the self-service actions spell', () => {
169-
// Byte-identical term, so the two never drift into two spellings of one
170-
// rule — while the ownership half they also carry stays out (asserted
171-
// above by the offered-to-an-admin verdict).
172-
expect(visible()).toContain('record.source != "idp_provisioned"');
182+
it('⛔ does NOT carry the self-service actions\' source term', () => {
183+
// Positive control: the term is still spelled on the self-service side
184+
// (password and identity edits stay hidden for a managed identity, ADR-0135
185+
// D4), so its absence here is a reading, not a rename.
173186
const selfService = actionsOf().find((a) => a.name === 'change_my_password');
174187
expect(sourceOf(selfService?.visible)).toContain('record.source != "idp_provisioned"');
188+
expect(visible()).not.toContain('record.source');
189+
});
190+
191+
it('is still hidden from a caller without platform-admin standing', () => {
192+
const member = { id: 'm_1', isPlatformAdmin: false, positions: [] as string[] };
193+
const r = celEngine.evaluate(
194+
{ dialect: 'cel', source: visible() },
195+
{ record: { id: 'someone_else', source: 'idp_provisioned' }, extra: { current_user: member, user: member, ctx: { user: member }, os: { user: member }, features: {} } },
196+
);
197+
expect(r.ok && r.value).toBe(false);
175198
});
176199

177200
it('⛔ is NOT gated on features.admin, and that is deliberate', () => {

‎packages/platform-objects/src/identity/sys-user.object.ts‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -675,23 +675,22 @@ export const SysUser = ObjectSchema.create({
675675
recordIdParam: 'userId',
676676
successMessage: 'Manager updated',
677677
refreshAfter: true,
678-
// Hidden for a directory-managed identity, whose manager the IdP owns:
679-
// the endpoint's refusal 5 answers 403 / `idp_provisioned`, so the
680-
// button would be an affordance the server side refuses by design.
681-
// This carries the SAME `record.source` term the three self-service
682-
// identity actions below carry — and only that term: this is an admin
683-
// action on someone else's row, so their `record.id == ctx.user.id`
684-
// half is deliberately NOT copied (it would hide the button from every
685-
// admin). `has()` per operand for the sparse action face (#8990) — the
686-
// rationale is on the self-service block below.
678+
// Offered on every row, `idp_provisioned` ones included, and the
679+
// endpoint refuses the one case it must. Its refusal 5 answers 403 /
680+
// `idp_provisioned` only for an identity a SCIM directory HOLDS (a
681+
// `sys_scim_subject` row, maintainer ruling record 6895645364, option
682+
// A); a person who only signs in through SSO carries the same `source`
683+
// with no directory behind them, and their manager is set here. No
684+
// column on this row says "held by SCIM", so ⛔ a `record.source` term
685+
// would hide the button from every SSO-only person — the defect this
686+
// predicate used to carry — and a SCIM-held row is answered by the
687+
// server's refusal, which names the directory to go to.
687688
//
688-
// ANDed ahead of it, the platform-admin standing the door's gate judges
689-
// (ADR-0068 D4, the admin block header above): without it the button
690-
// was offered to every caller who could open a user row, and the door
691-
// refused each one 403 `PERMISSION_DENIED`. One flat conjunction, the
692-
// principal term first, the way the self-service predicates below lead
693-
// with theirs.
694-
visible: 'current_user.isPlatformAdmin == true && has(record.source) && record.source != "idp_provisioned"',
689+
// The platform-admin standing the door's gate judges (ADR-0068 D4, the
690+
// admin block header above): without it the button was offered to every
691+
// caller who could open a user row, and the door refused each one 403
692+
// `PERMISSION_DENIED`.
693+
visible: 'current_user.isPlatformAdmin == true',
695694
// The action collects a param, so its explanatory line rides
696695
// `description` and ⛔ never `confirmText` — pairing the two shows two
697696
// dialogs for one decision (#7278/#7309).

‎packages/platform-objects/src/platform-objects.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ describe('feature-gate lowering matrix (#2874)', () => {
772772
// The rest of the platform-admin family. Three carry no feature gate, so
773773
// the authored predicate is served as written — no lowering — and is
774774
// pinned here anyway, beside add_member, so every member has its row.
775-
['SysUser', SysUser, 'set_user_manager', `${STANDING} && has(record.source) && record.source != "idp_provisioned"`],
775+
['SysUser', SysUser, 'set_user_manager', STANDING],
776776
['SysSsoProvider', SysSsoProvider, 'register_sso_provider', STANDING],
777777
['SysSsoProvider', SysSsoProvider, 'register_saml_provider', STANDING],
778778
['SysSsoProvider', SysSsoProvider, 'request_domain_verification', STANDING],

0 commit comments

Comments
 (0)