Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/33200-set-manager-scim-held-only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/plugin-auth': patch
'@objectstack/platform-objects': patch
'@objectstack/lint': patch
---

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

Clause-②: yes (widening)
Metadata-protocol: none

`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.

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.

`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.

`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.

The `idp_provisioned` stamp itself (ADR-0135 D4) and the password refusals are unchanged.
12 changes: 7 additions & 5 deletions content/docs/automation/approvals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ row's `manager` result: a link it cannot make never fails the user it imported.
The column is also written by a seed, or by any other system-context write, which bypasses the
managed-update whitelist. SCIM provisioning and directory sync can populate it too, but only
through a provisioning path your own deployment supplies: this platform declares the SCIM
`manager` attribute without projecting it onto the column. Where an identity carries
`source: 'idp_provisioned'` the admin operation **refuses**, so that directory stays the one
surface that authors its manager. A user a SCIM connection provisions carries that value from its
creation unless it holds a local password, so for such a user the column is written only by that
deployment-supplied path, and a value the column already holds stays as it is.
`manager` attribute without projecting it onto the column. Where a SCIM directory holds an
identity (it carries `source: 'idp_provisioned'` and the directory has provisioned or linked it)
the admin operation **refuses**, the import's `manager_id` column included, so that directory
stays the one surface that authors its manager; for such a user the column is written only by that
deployment-supplied path, and a value the column already holds stays as it is. A person who only
signs in through SSO also carries `source: 'idp_provisioned'`, but no directory holds them: their
manager is set with **Set Manager** or the import like anyone else's.

Setting the column is still something you have to *do*. Where `manager_id` is unset the rung
expands to nobody, and under the default `onEmptyApprovers: 'admin_rescue'` the request opens on
Expand Down
3 changes: 2 additions & 1 deletion content/docs/capabilities/approvals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ A specific person · everyone holding a position (e.g. sales managers) · the su
**Routing to the submitter's manager needs each user's manager set.** This style resolves
`sys_user.manager_id`, which is not a profile field: editing the user does not set it. A platform
admin sets it one user at a time from **Setup → Users → ⋯ → Set Manager**, which calls
`POST /api/v1/auth/admin/set-user-manager`. For many users at once, provisioning fills it: the
`POST /api/v1/auth/admin/set-user-manager` — for anyone, people who sign in through SSO included,
except a person a SCIM directory holds, whose manager is changed in that directory. For many users at once, provisioning fills it: the
admin bulk-import endpoint reads a `manager_id` column, and a seed, or a SCIM / directory-sync
path your deployment supplies, can write it too. Until it is set, a manager-only approval step
resolves to nobody and the node's `onEmptyApprovers` policy decides what happens — by default the
Expand Down
5 changes: 5 additions & 0 deletions content/docs/permissions/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,11 @@ sign-in through any other one leaves the person pending. Their positions, permis
from the moment they are added, so seed data and approval flows can name them
before they sign in. Off a managed environment both doors answer `409`.

Signing in does not lock the manager: a platform administrator still changes
it with **Set Manager** (`POST /api/v1/auth/admin/set-user-manager`). That
endpoint refuses only a person a SCIM directory holds, whose manager is changed
in the directory.

A host can be told about people as they come and go: the `environmentUserHost`
option of the auth plugin is called after a person is added, and before a
person is deactivated (`admin/ban-user`) or reactivated (`admin/unban-user`).
Expand Down
5 changes: 3 additions & 2 deletions packages/lint/src/rule-explanations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3336,9 +3336,10 @@ const MANAGER_ONLY_ROUTES =
'write, which bypasses the managed-update whitelist. SCIM provisioning and directory sync can ' +
'populate it too, but only through a provisioning path your own deployment supplies: this ' +
'platform declares the SCIM \'manager\' attribute without projecting it onto the column — and ' +
'where an identity carries source \'idp_provisioned\' the admin operation refuses, the import\'s ' +
'where a SCIM directory holds an identity the admin operation refuses, the import\'s ' +
'manager_id column included, leaving that directory the one surface that authors its ' +
'manager. Or declare onEmptyApprovers: \'fallback\' on the node, with a ' +
'manager. An identity that only signs in through SSO, with no SCIM directory behind it, is set ' +
'through the admin operation like any other. Or declare onEmptyApprovers: \'fallback\' on the node, with a ' +
'fallbackApprovers list: an empty manager rung then opens the request on those people instead ' +
'of on the organization\'s administrators, which needs no write to the column at all.';

Expand Down
12 changes: 9 additions & 3 deletions packages/lint/src/validate-approval-approvers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,18 @@ describe('unset-manager dead-end (#16748)', () => {
// ⛔ And they must not be deleted: a deployment running a real directory
// sync may well populate the column, and the defect was presenting all
// three as equally available, never naming them at all. They now also take
// PRECEDENCE — the endpoint refuses an `idp_provisioned` identity, and so
// does the import's `manager_id` column, which runs the same derivation —
// PRECEDENCE — the endpoint refuses an identity a SCIM directory holds, and
// so does the import's `manager_id` column, which runs the same derivation —
// so the hint must not read as "use the endpoint instead of your directory".
expect(remedy).toContain('SCIM provisioning and directory sync can populate it');
expect(remedy).toContain("source 'idp_provisioned' the admin operation refuses");
expect(remedy).toContain('where a SCIM directory holds an identity the admin operation refuses');
expect(remedy).toContain("the import's manager_id column included");
// ⛔ But only where a directory exists: the `idp_provisioned` mark alone
// also covers a person who only signs in through SSO, whose manager the
// endpoint sets (maintainer ruling record 6895645364). A remedy that sent
// that admin to a directory they do not have cannot be carried out.
expect(remedy).not.toContain("source 'idp_provisioned' the admin operation refuses");
expect(remedy).toContain('only signs in through SSO');
});

it('the one-line `fix:` names the first route and the escape, and never the Console form', () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/lint/src/validate-approval-approvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ const STAYS_LOCKED = ', and (lockRecord) the record stays locked';
* It reaches the column under a SYSTEM context — by context, ⛔ not by a
* whitelist entry — which is why the whitelist reading above is unchanged.
* It refuses self-assignment, a link that closes a cycle, a chain past its
* depth cap, a manager provably outside the user's organizations, and any
* identity whose `sys_user.source` is `idp_provisioned`.
* depth cap, a manager provably outside the user's organizations, and an
* identity a SCIM directory holds (`sys_user.source` `idp_provisioned` AND
* a `sys_scim_subject` row). An `idp_provisioned` identity with no SCIM
* subject — a person who only signs in through SSO — is set like any other
* (maintainer ruling record 6895645364).
* - Seed, or any other system-context write — AVAILABLE HERE, unchanged.
* Both write guards gate on `isUserContextWrite`, spelled identically in
* each: `Boolean(userId) && isSystem !== true` (plugin-security
Expand Down Expand Up @@ -179,7 +182,7 @@ const STAYS_LOCKED = ', and (lockRecord) the record stays locked';
* one may well populate the column through it — but named as something the
* operator's own provisioning supplies, ⛔ never as something this repo gives
* them. They also now have PRECEDENCE over the endpoint rather than merely
* sitting beside it: on an `idp_provisioned` identity the endpoint refuses, so
* sitting beside it: on an identity a SCIM directory holds the endpoint refuses, so
* the directory is the one authoring surface for those rows.
*
* ⛔ WHAT DID NOT CHANGE — and why this rule is not deleted. The dead end the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@
* managed-update whitelist is `{name, image, locale}`, so a picker that
* PATCHed `/api/v1/data/sys_user/:id` would be refused by the identity
* write guard — correctly — and would read as a Console bug.
* 2. **The `visible` predicate carries the directory-sync term and NOT the
* self-service ownership term.** The three self-service identity actions
* on this object spell `record.source != "idp_provisioned"` as one half of
* `record.id == ctx.user.id && …`. Copying that predicate whole — the
* natural thing to do, and what a reader of the card would do — would hide
* an ADMIN action on someone else's row from every admin. The failure is
* silent and fail-closed (#8990): the button simply is not offered.
* 2. **The `visible` predicate reads NO record column — neither the
* self-service ownership term nor the `source` term.** The three
* self-service identity actions on this object spell
* `record.source != "idp_provisioned"` beside `record.id == ctx.user.id`.
* Copying either half — the natural thing to do — hides an ADMIN action
* from rows the endpoint accepts: the ownership half from every admin,
* the `source` half from every person who only signs in through SSO
* (ADR-0135 D4 stamps them `idp_provisioned` with no directory behind
* them; maintainer ruling record 6895645364, option A, has the endpoint
* refuse only an identity a SCIM directory holds). The failure is silent
* and fail-closed (#8990): the button simply is not offered.
* 3. **No second copy of the server's refusals.** Self-assignment, cycle,
* depth, cross-organization and directory-owned identity are all enforced
* depth, cross-organization and SCIM-held identity are all enforced
* at the write, in one derivation (`applyUserManagerLink`), which the bulk
* importer already routes onto rather than re-deriving. A client-side
* duplicate is the drift, not the safety net — so this file pins that the
* declaration reads exactly one record column and declares no predicate
* for any of the other four refusals.
* declaration reads no record column and declares no predicate for any
* of the five refusals.
*
* The sweep in `action-predicate-sparse-face.test.ts` already covers this
* action's predicate for the sparse-face guard; that is deliberately not
Expand Down Expand Up @@ -130,14 +134,17 @@ describe('#19249 — sys_user.set_user_manager posts the admin endpoint', () =>
it('⛔ declares no second copy of the server-side refusals', () => {
// Every refusal is enforced at the write and surfaces from there. What
// would go wrong quietly is a client-side re-derivation drifting from the
// endpoint's; so the predicate is pinned to the ONE column it reads, and
// the declaration to having no other gate at all.
// endpoint's; so the predicate is pinned to reading no record column at
// all, and the declaration to having no other gate.
const visible = sourceOf(ACTION.visible);
expect(visible).toBeDefined();
// Positive control: the standing term really is there, so the empty column
// set below is a reading of the predicate, not of an absent one.
expect(visible).toContain('current_user.isPlatformAdmin == true');
const columns = new Set(
[...visible!.matchAll(/record\.([a-z_][a-z0-9_]*)/gi)].map((m) => m[1]),
);
expect([...columns]).toEqual(['source']);
expect([...columns]).toEqual([]);
expect(ACTION.disabled).toBeUndefined();
// The manager chain, the organization screen and the self-assignment check
// are the endpoint's; none of them is expressible — or declared — here.
Expand All @@ -148,15 +155,22 @@ describe('#19249 — sys_user.set_user_manager posts the admin endpoint', () =>
});
});

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

it('is hidden for a directory-owned identity (the server answers 403 idp_provisioned)', () => {
expect(evaluate(visible(), { source: 'idp_provisioned' })).toBe(false);
it('⭐ is OFFERED on an idp_provisioned row — an SSO-only person\'s manager is set here', () => {
// The endpoint answers 200 for this row unless a SCIM directory holds it,
// and no column on the row says which; hiding the button here hid it from
// every person who ever signed in through SSO.
expect(evaluate(visible(), { id: 'someone_else', source: 'idp_provisioned' })).toBe(true);
});

it('is OFFERED on the sparse face too (no source column projected)', () => {
expect(evaluate(visible(), { id: 'someone_else' })).toBe(true);
});

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

it('carries the same directory-sync term the self-service actions spell', () => {
// Byte-identical term, so the two never drift into two spellings of one
// rule — while the ownership half they also carry stays out (asserted
// above by the offered-to-an-admin verdict).
expect(visible()).toContain('record.source != "idp_provisioned"');
it('⛔ does NOT carry the self-service actions\' source term', () => {
// Positive control: the term is still spelled on the self-service side
// (password and identity edits stay hidden for a managed identity, ADR-0135
// D4), so its absence here is a reading, not a rename.
const selfService = actionsOf().find((a) => a.name === 'change_my_password');
expect(sourceOf(selfService?.visible)).toContain('record.source != "idp_provisioned"');
expect(visible()).not.toContain('record.source');
});

it('is still hidden from a caller without platform-admin standing', () => {
const member = { id: 'm_1', isPlatformAdmin: false, positions: [] as string[] };
const r = celEngine.evaluate(
{ dialect: 'cel', source: visible() },
{ record: { id: 'someone_else', source: 'idp_provisioned' }, extra: { current_user: member, user: member, ctx: { user: member }, os: { user: member }, features: {} } },
);
expect(r.ok && r.value).toBe(false);
});

it('⛔ is NOT gated on features.admin, and that is deliberate', () => {
Expand Down
31 changes: 15 additions & 16 deletions packages/platform-objects/src/identity/sys-user.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,23 +675,22 @@ export const SysUser = ObjectSchema.create({
recordIdParam: 'userId',
successMessage: 'Manager updated',
refreshAfter: true,
// Hidden for a directory-managed identity, whose manager the IdP owns:
// the endpoint's refusal 5 answers 403 / `idp_provisioned`, so the
// button would be an affordance the server side refuses by design.
// This carries the SAME `record.source` term the three self-service
// identity actions below carry — and only that term: this is an admin
// action on someone else's row, so their `record.id == ctx.user.id`
// half is deliberately NOT copied (it would hide the button from every
// admin). `has()` per operand for the sparse action face (#8990) — the
// rationale is on the self-service block below.
// Offered on every row, `idp_provisioned` ones included, and the
// endpoint refuses the one case it must. Its refusal 5 answers 403 /
// `idp_provisioned` only for an identity a SCIM directory HOLDS (a
// `sys_scim_subject` row, maintainer ruling record 6895645364, option
// A); a person who only signs in through SSO carries the same `source`
// with no directory behind them, and their manager is set here. No
// column on this row says "held by SCIM", so ⛔ a `record.source` term
// would hide the button from every SSO-only person — the defect this
// predicate used to carry — and a SCIM-held row is answered by the
// server's refusal, which names the directory to go to.
//
// ANDed ahead of it, the platform-admin standing the door's gate judges
// (ADR-0068 D4, the admin block header above): without it the button
// was offered to every caller who could open a user row, and the door
// refused each one 403 `PERMISSION_DENIED`. One flat conjunction, the
// principal term first, the way the self-service predicates below lead
// with theirs.
visible: 'current_user.isPlatformAdmin == true && has(record.source) && record.source != "idp_provisioned"',
// The platform-admin standing the door's gate judges (ADR-0068 D4, the
// admin block header above): without it the button was offered to every
// caller who could open a user row, and the door refused each one 403
// `PERMISSION_DENIED`.
visible: 'current_user.isPlatformAdmin == true',
// The action collects a param, so its explanatory line rides
// `description` and ⛔ never `confirmText` — pairing the two shows two
// dialogs for one decision (#7278/#7309).
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-objects/src/platform-objects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ describe('feature-gate lowering matrix (#2874)', () => {
// The rest of the platform-admin family. Three carry no feature gate, so
// the authored predicate is served as written — no lowering — and is
// pinned here anyway, beside add_member, so every member has its row.
['SysUser', SysUser, 'set_user_manager', `${STANDING} && has(record.source) && record.source != "idp_provisioned"`],
['SysUser', SysUser, 'set_user_manager', STANDING],
['SysSsoProvider', SysSsoProvider, 'register_sso_provider', STANDING],
['SysSsoProvider', SysSsoProvider, 'register_saml_provider', STANDING],
['SysSsoProvider', SysSsoProvider, 'request_domain_verification', STANDING],
Expand Down
Loading
Loading