Skip to content

Commit 1cbcf46

Browse files
fix(platform-objects): with SSO-only mode on, Set Password is not offered on an IdP-provisioned user (#39360)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg4SUAdM9jHAnrRj2SwqK64X)_ Fixes #34225 Thread session: `session_01Utp6CbZLcNVF5cbbuDifLD` (card thread of zone data-1203, claim 7381634042) ## What changes - `sys_user.set_user_password`'s `visible` gains one `&&` conjunct, `!(SSO_ONLY_REFUSED_ROW)`: with SSO-only mode on, Set Password is not offered on an IdP-provisioned row (`source == 'idp_provisioned'`) unless it is the caller's own row (the break-glass password a platform administrator may set for themselves). - It reads the two facts the door reads: `features.ssoEnforced` is served from `resolveSsoOnly()` (`auth-manager.ts:6187`), the same accessor the door's `isSsoOnlyMode()` returns (`auth-manager.ts:5847`, read at `admin-user-endpoints.ts:1246`), and the row's stored `source`, which `judgeSsoOnlyLocalPassword` reads (`sso-only-local-password.ts:212`). - `has()` on the flag and on `source` keeps today's offer when the console holds neither; the door still judges. - `idp_pending` is not refused by this rule (only by the cloud-managed one, where the action is already hidden), so it keeps the offer. - `feature-gate-guard.test.ts`: the registry books only whole-input conjunct gates, so a row-scoped read gets a guard-local list, `ROW_SCOPED_HIDES` (beside `SHOWN_WHEN_ON`). The reverse walk accepts it, and a new row asserts the input carries `!(has(features.F) && features.F == true && <row terms>)` and is not also booked in `gatedInputs`. - `public-auth-features.ts`: `ssoEnforced`'s `exempt.reason` text says Set Password reads it to hide those rows. No served key, semantics or surface changes. - `platform-objects.test.ts`: the lowering matrix row for `set_user_password` pins the new predicate. ## Why With SSO-only mode on, Setup → Users offered Set Password on an IdP-provisioned user and the door then answered `409 RESOURCE_CONFLICT`. The action is now offered only where the door would accept it. ## Verification - New `identity/sso-only-set-password-visibility.test.ts` evaluates the parsed predicate through `@objectstack/formula`: hidden on an IdP-provisioned row under SSO-only mode; CONTROLs offered on `env_native`, `null` source, `idp_pending`, the admin's own IdP row, an unprojected `source`; SSO-only off or no flag served keeps every row's offer; non-admin and cloud-managed still hide. - Ablation: dropping the new conjunct turns 2 rows red (the pin above and the `ROW_SCOPED_HIDES` guard row); restored green. - `packages/platform-objects`: 133 files / 2364 tests pass. `packages/spec` `src/kernel`: 65 files / 1519 pass. Clause-②: no Metadata-protocol: none ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed (a reason string only; no generated artifact carries it). - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Utp6CbZLcNVF5cbbuDifLD --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5788b13 commit 1cbcf46

6 files changed

Lines changed: 160 additions & 6 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/platform-objects': patch
3+
'@objectstack/spec': patch
4+
---
5+
6+
fix(platform-objects): with SSO-only mode on, Setup → Users no longer offers Set Password on a user the identity provider provisioned
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Who sees it: a platform administrator on Setup → Users of an environment in SSO-only mode (`ssoOnlyMode` / `OS_AUTH_SSO_ONLY`).
12+
13+
- **Set Password is hidden on an IdP-provisioned user's row** (`source = idp_provisioned`) while SSO-only mode is on. The server refuses that password write (`409`), so the button only ever led to a refusal.
14+
- **Still offered:** on local-password users, on your own row (the break-glass password a platform administrator may set for themselves), and on every row when SSO-only mode is off. If the console has not received the SSO-only flag, or the row's identity source, the button shows as before and the server still decides.
15+
- The `ssoEnforced` entry of the public auth feature registry now says that Set Password reads it to hide those rows; no served flag changes.

‎packages/platform-objects/src/feature-gate-guard.test.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ const SHOWN_WHEN_ON: ReadonlyArray<[string, PublicAuthFeatureName]> = [
199199
['sys_user.actions.remove_sso_user', 'cloudManaged'],
200200
];
201201

202+
/**
203+
* Inputs that read a flag only to hide the ROWS their door refuses while it is
204+
* on, never the input as a whole — the other polarity the registry does not
205+
* model (its gates are whole-input conjuncts). These are: Set Password, whose
206+
* door refuses an IdP-provisioned user under SSO-only mode unless the caller
207+
* names themselves (#34225). Each must carry, as one `&&` conjunct, the
208+
* negation of a group that starts `has(features.F) && features.F == true`, so
209+
* a console holding no flag keeps the input offered (a faulting action
210+
* predicate SHOWS anyway), and the flag on hides only the rows the rest of the
211+
* group names. Its verdicts are pinned in
212+
* `identity/sso-only-set-password-visibility.test.ts`.
213+
*/
214+
const ROW_SCOPED_HIDES: ReadonlyArray<[string, PublicAuthFeatureName]> = [
215+
['sys_user.actions.set_user_password', 'ssoEnforced'],
216+
];
217+
202218
describe('feature-gate completeness guard (#2874)', () => {
203219
it('sanity: the walker actually sees the platform objects', () => {
204220
for (const name of ['sys_user', 'sys_organization', 'sys_oauth_application', 'sys_two_factor']) {
@@ -346,7 +362,11 @@ describe('feature-gate completeness guard (#2874)', () => {
346362
const booked = inputsByFlag.get(flag);
347363
expect(booked, `features.${flag} is a registry flag`).toBeDefined();
348364
const shown = SHOWN_WHEN_ON.some(([p, f]) => p === path && f === flag);
349-
expect(booked!.has(path) || shown, `${path} is booked in ${flag}.gatedInputs (or in SHOWN_WHEN_ON)`).toBe(true);
365+
const rowScoped = ROW_SCOPED_HIDES.some(([p, f]) => p === path && f === flag);
366+
expect(
367+
booked!.has(path) || shown || rowScoped,
368+
`${path} is booked in ${flag}.gatedInputs (or in SHOWN_WHEN_ON / ROW_SCOPED_HIDES)`,
369+
).toBe(true);
350370
});
351371
});
352372

@@ -362,4 +382,19 @@ describe('feature-gate completeness guard (#2874)', () => {
362382
}
363383
});
364384
});
385+
386+
describe('the inputs a flag hides only on some rows (ROW_SCOPED_HIDES)', () => {
387+
it.each(ROW_SCOPED_HIDES)('%s carries a negated row group opened by %s', (path, flag) => {
388+
const booked = (PUBLIC_AUTH_FEATURES[flag] as { gatedInputs?: readonly string[] }).gatedInputs ?? [];
389+
expect(booked, `${path} is not also booked as a whole-input gate`).not.toContain(path);
390+
const { visibleSource } = resolveGatedInput(path);
391+
expect(visibleSource, `${path} has a visible predicate`).toBeDefined();
392+
const negated = conjuncts(visibleSource!).filter((c) => c.startsWith('!(') && isWrappedInParens(c.slice(1)));
393+
const opened = negated.some((c) => {
394+
const inner = conjuncts(c.slice(2, -1));
395+
return inner[0] === `has(features.${flag})` && inner[1] === `features.${flag} == true` && inner.length > 2;
396+
});
397+
expect(opened, `${path}: "${visibleSource}" must carry !(has(features.${flag}) && features.${flag} == true && <row terms>)`).toBe(true);
398+
});
399+
});
365400
});
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [#34225] With SSO-only mode on, Setup → Users does not offer Set Password
5+
* (`sys_user.set_user_password`) on a row its door refuses. The door,
6+
* plugin-auth's `admin/set-user-password`, refuses an IdP-provisioned user
7+
* (`source == 'idp_provisioned'`) under SSO-only mode unless the platform
8+
* administrator is setting their own break-glass password
9+
* (`sso-only-local-password.ts`, `judgeSsoOnlyLocalPassword`). The predicate
10+
* reads the two facts that door reads: `features.ssoEnforced` (served from the
11+
* same SSO-only accessor) and the row's `source`.
12+
*
13+
* CONTROLs: a local-password row keeps the offer under SSO-only mode, the
14+
* administrator's own IdP-provisioned row keeps it (break-glass), and with
15+
* SSO-only mode off, or no flag served, or `source` not projected, every row
16+
* keeps today's offer. The cloud-managed and platform-admin terms are pinned
17+
* by `cloud-managed-visibility.test.ts` and `action-state-visibility.test.ts`.
18+
*
19+
* The predicate is EVALUATED through the canonical engine the console
20+
* delegates to (`@objectstack/formula`), on the parsed object.
21+
*/
22+
23+
import { describe, expect, it } from 'vitest';
24+
import { celEngine } from '@objectstack/formula';
25+
import { SysUser } from './sys-user.object.js';
26+
27+
const ADMIN = { id: 'u_admin', email: 'admin@example.com', positions: ['org_owner'], isPlatformAdmin: true };
28+
29+
/** What a self-hosted kernel serves, SSO-only mode on. */
30+
const SSO_ONLY = { admin: true, cloudManaged: false, ssoEnforced: true };
31+
32+
const IDP_ROW = { id: 'usr_idp', email: 'idp@example.com', source: 'idp_provisioned' };
33+
34+
function visibleSource(): string {
35+
const action = ((SysUser.actions ?? []) as Array<Record<string, unknown>>).find((a) => a.name === 'set_user_password');
36+
if (!action) throw new Error('sys_user declares no action named "set_user_password"');
37+
const raw = action.visible;
38+
const source = typeof raw === 'string' ? raw : (raw as { source?: unknown } | undefined)?.source;
39+
if (typeof source !== 'string') throw new Error('set_user_password has no CEL source');
40+
return source;
41+
}
42+
43+
/** The verdict, or the fault spelled out so a faulting predicate fails loudly. */
44+
function offered(record: Record<string, unknown>, features: Record<string, unknown>, subject = ADMIN): boolean | string {
45+
const r = celEngine.evaluate(
46+
{ dialect: 'cel', source: visibleSource() },
47+
{ record, extra: { current_user: subject, user: subject, ctx: { user: subject }, features } },
48+
);
49+
if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`;
50+
return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`;
51+
}
52+
53+
describe('Set Password is not offered on a row SSO-only mode refuses', () => {
54+
it('is hidden on an IdP-provisioned row while SSO-only mode is on', () => {
55+
expect(offered(IDP_ROW, SSO_ONLY)).toBe(false);
56+
});
57+
58+
it.each([
59+
['a local-password row (env_native)', { ...IDP_ROW, source: 'env_native' }],
60+
['a row with no stored source (null)', { ...IDP_ROW, source: null }],
61+
['a pending row (idp_pending), which this rule does not refuse', { ...IDP_ROW, source: 'idp_pending' }],
62+
["the administrator's own IdP-provisioned row (break-glass)", { ...IDP_ROW, id: ADMIN.id }],
63+
['a row the console did not project source for', { id: 'usr_idp', email: 'idp@example.com' }],
64+
])('CONTROL: is offered on %s while SSO-only mode is on', (_row, record) => {
65+
expect(offered(record, SSO_ONLY)).toBe(true);
66+
});
67+
68+
it.each([
69+
['SSO-only mode is off', { ...SSO_ONLY, ssoEnforced: false }],
70+
['no ssoEnforced flag is served', { admin: true, cloudManaged: false }],
71+
])('CONTROL: every row keeps today\'s offer when %s', (_case, features) => {
72+
for (const source of ['idp_provisioned', 'env_native', null]) {
73+
expect(offered({ ...IDP_ROW, source }, features), String(source)).toBe(true);
74+
}
75+
});
76+
77+
it('CONTROL: a platform admin is still required, and cloud-managed still hides it', () => {
78+
const notAdmin = { ...ADMIN, isPlatformAdmin: false };
79+
expect(offered({ ...IDP_ROW, source: 'env_native' }, SSO_ONLY, notAdmin)).toBe(false);
80+
expect(offered({ ...IDP_ROW, source: 'env_native' }, { ...SSO_ONLY, cloudManaged: true })).toBe(false);
81+
});
82+
});

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ const MANAGED_ADD_PERSON_VISIBLE =
8383
const MANAGED_REMOVE_PENDING_PERSON_VISIBLE =
8484
`${MANAGED_ADD_PERSON_VISIBLE} && has(record.source) && record.source == 'idp_pending'`;
8585

86+
/**
87+
* [#34225] Not on a row SSO-only mode keeps off local passwords: with SSO-only
88+
* mode on, `admin/set-user-password` refuses an IdP-provisioned user
89+
* (`sys_user.source = 'idp_provisioned'`) unless the platform administrator
90+
* is setting their own break-glass password (plugin-auth
91+
* `sso-only-local-password.ts`, `judgeSsoOnlyLocalPassword`). The predicate
92+
* reads the same two facts the door reads: `features.ssoEnforced`, served from
93+
* the one SSO-only accessor the door asks, and the row's stored `source`. A
94+
* console holding neither (no served flag, an unprojected `source`) keeps
95+
* today's offer, and the door still judges.
96+
*/
97+
const SSO_ONLY_REFUSED_ROW =
98+
"has(features.ssoEnforced) && features.ssoEnforced == true && has(record.source) && record.source == 'idp_provisioned'"
99+
+ ' && !(has(record.id) && record.id == current_user.id)';
100+
86101
const TEMPORARY_PASSWORD_LABEL = 'Temporary password: copy it now, it is shown only once and never stored';
87102

88103
/**
@@ -638,8 +653,9 @@ export const SysUser = ObjectSchema.create({
638653
requiredPermissions: [...PLATFORM_ADMIN_USERS_GATE],
639654
// Platform-admin standing (ADR-0068 D4) — see the block header above —
640655
// and hidden while cloud-managed (`features.cloudManaged`, hide-when-on):
641-
// the door refuses every target there (plugin-auth `cloud-managed.ts`).
642-
visible: 'current_user.isPlatformAdmin == true && features.cloudManaged != true',
656+
// the door refuses every target there (plugin-auth `cloud-managed.ts`);
657+
// and not on a row SSO-only mode refuses (`SSO_ONLY_REFUSED_ROW`, #34225).
658+
visible: `current_user.isPlatformAdmin == true && features.cloudManaged != true && !(${SSO_ONLY_REFUSED_ROW})`,
643659
recordIdParam: 'userId',
644660
successMessage: 'Password updated',
645661
refreshAfter: false,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,9 @@ describe('feature-gate lowering matrix (#2874)', () => {
867867
['SysUser', SysUser, 'ban_user', `${STANDING} && has(record.banned) && record.banned != true`],
868868
['SysUser', SysUser, 'unban_user', `${STANDING} && has(record.banned) && record.banned == true`],
869869
['SysUser', SysUser, 'unlock_user', `${STANDING} && ((has(record.locked_until) && record.locked_until != null) || (has(record.two_factor_enabled) && record.two_factor_enabled == true))`],
870-
['SysUser', SysUser, 'set_user_password', `${STANDING} && ${MANAGED}`],
870+
// …and Set Password is not offered on a row SSO-only mode refuses (#34225;
871+
// truth table in `identity/sso-only-set-password-visibility.test.ts`).
872+
['SysUser', SysUser, 'set_user_password', `${STANDING} && ${MANAGED} && !(has(features.ssoEnforced) && features.ssoEnforced == true && has(record.source) && record.source == 'idp_provisioned' && !(has(record.id) && record.id == current_user.id))`],
871873
['SysUser', SysUser, 'impersonate_user', `(${STANDING}) && features.admin == true`],
872874
['SysUser', SysUser, 'enable_two_factor', '(has(record.id) && record.id == ctx.user.id && has(record.two_factor_enabled) && record.two_factor_enabled != true) && features.twoFactor == true'],
873875
['SysUser', SysUser, 'disable_two_factor', '(has(record.id) && record.id == ctx.user.id && has(record.two_factor_enabled) && record.two_factor_enabled == true) && features.twoFactor == true'],

‎packages/spec/src/kernel/public-auth-features.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,12 @@ export const PUBLIC_AUTH_FEATURES = {
245245
semantics: 'opt-in',
246246
exempt: {
247247
reason:
248-
'Login-surface only: objectui LoginForm hides the password form and ' +
249-
'self-registration (break-glass link remains). No spec input to gate.',
248+
'Login-surface consumption: objectui LoginForm hides the password form and ' +
249+
'self-registration (break-glass link remains). No spec input is gated on it ' +
250+
'as a whole: sys_user.actions.set_user_password reads it only to hide the ' +
251+
'rows its door refuses under SSO-only mode (IdP-provisioned, not the ' +
252+
"caller's own), a row-scoped read booked in platform-objects' " +
253+
'feature-gate guard (ROW_SCOPED_HIDES), not here (#34225).',
250254
},
251255
},
252256
directSignIn: {

0 commit comments

Comments
 (0)