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
15 changes: 15 additions & 0 deletions .changeset/34010-unlock-without-admin-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@objectstack/platform-objects': patch
'@objectstack/spec': patch
---

fix(platform-objects): Setup → Users offers Unlock Account on environments without the better-auth admin plugin

Clause-②: no
Metadata-protocol: none

`sys_user.unlock_user` no longer carries `requiresFeature: 'admin'`. Its door, `POST /api/v1/auth/admin/unlock-user`, already works without the better-auth admin plugin: the sign-in lockout is ObjectStack's own (`sys_user.locked_until` / `failed_login_count`), and the unlock clears it through the data engine. The action was still hidden wherever `features.admin` is off, so a platform administrator there could not release a locked-out person early and had to wait for the lock to expire.

It is now offered on every environment that runs without the admin plugin, self-hosted and cloud-managed alike, to a platform administrator only, and only on an account that has a lock stamp or two-factor enabled. Nothing else changes: `requiredPermissions` and the predicate stay as they were, environments with the admin plugin (or SCIM, which turns it on) see no difference, and `create_user` and `impersonate_user` keep their admin-plugin gate (Set Password is released the same way, in its own note).

`PUBLIC_AUTH_FEATURES.admin.gatedInputs` in `@objectstack/spec/kernel` no longer lists `sys_user.actions.unlock_user`, since it is no longer gated on that flag.
17 changes: 17 additions & 0 deletions .changeset/34130-set-password-without-admin-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/platform-objects': patch
'@objectstack/spec': patch
---

fix(platform-objects): Setup → Users offers Set Password on self-hosted environments without the better-auth admin plugin

Clause-②: no (as #33989 and #34124 judge a gate drop)
Metadata-protocol: none

`sys_user.set_user_password` no longer carries `requiresFeature: 'admin'`. Its door, `POST /api/v1/auth/admin/set-user-password`, is ObjectStack's own wrapper and already works without the better-auth admin plugin: it hashes and writes the password through better-auth's core, which every environment carries. The action was still hidden wherever `features.admin` is off, so a platform administrator there could not set or reset a person's password from the console.

It is now offered to a platform administrator on every environment that runs without the admin plugin and is not cloud-managed. Its other rule is unchanged: it stays hidden on a cloud-managed environment, whose door refuses every target, and the door's own refusals (a pending person, SSO-only mode) answer as before. `create_user` and `impersonate_user` keep their admin-plugin gate.

`PUBLIC_AUTH_FEATURES.admin.gatedInputs` in `@objectstack/spec/kernel` no longer lists `sys_user.actions.set_user_password`, since it is no longer gated on that flag.

The `features.admin` description in `@objectstack/spec` (`AuthFeaturesConfigSchema`, and the generated auth-endpoints reference page) no longer says the console shows Unlock Account and Set Password only when it is true: whether the console offers banning, unbanning, unlocking or setting a password does not depend on it.
11 changes: 6 additions & 5 deletions content/docs/permissions/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1158,9 +1158,10 @@ new AuthPlugin({

### Admin User Management

With `plugins: { admin: true }` (forced on when SCIM is enabled), platform
admins get email-independent account management on the Users list — the
`create_user` / `set_user_password` actions there drive these endpoints. All
Platform admins get email-independent account management on the Users list
— the `create_user` / `set_user_password` actions there drive these
endpoints. Creating a user needs `plugins: { admin: true }` (forced on when
SCIM is enabled); setting a password works with or without it. All
three routes are gated server-side on the session's `isPlatformAdmin` — the
`PLATFORM_ADMIN` standing of ADR-0095 D3 — with the legacy better-auth `role`
scalar of `admin` still accepted as a back-compat fallback; the
Expand Down Expand Up @@ -1545,7 +1546,7 @@ All endpoints are available under `/api/v1/auth/*`:
- `POST /api/v1/auth/phone-number/request-password-reset` - Request an OTP-based password reset (requires an SMS service)
- `POST /api/v1/auth/phone-number/reset-password` - Complete an OTP-based password reset

#### Admin User Management (requires `plugins.admin`; platform-admin gated)
#### Admin User Management (platform-admin gated)

- `POST /api/v1/auth/admin/create-user` - Create a login-capable account (optional one-time temporary password + forced change)
- `POST /api/v1/auth/admin/set-user-password` - Set/reset a user's password (also provisions a credential for SSO-onboarded users)
Expand All @@ -1556,7 +1557,7 @@ All endpoints are available under `/api/v1/auth/*`:
- `POST /api/v1/auth/admin/add-sso-user` - Add one pending person who signs in only through the hosting organisation's identity provider (cloud-managed environments only)
- `POST /api/v1/auth/admin/import-sso-users` - Add pending people from a CSV or JSON rows (cloud-managed environments only; ≤500 rows, per-row results)

`ban-user`, `unban-user`, `add-sso-user` and `import-sso-users` answer without `plugins.admin` too.
`create-user` and `import-users` need `plugins.admin` (without it they answer `501 NOT_IMPLEMENTED`). `set-user-password`, `unlock-user`, `ban-user`, `unban-user`, `add-sso-user` and `import-sso-users` answer with or without it.

#### Organization Membership (requires `plugins.organization`; platform-admin gated)

Expand Down
4 changes: 2 additions & 2 deletions content/docs/references/api/auth-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const result = AuthEndpointSchema.parse(data);
| **degradedTenancy** | `boolean` | optional | Degraded tenancy: true when multi-organization isolation was requested but is not active (the deployment booted only because OS_ALLOW_DEGRADED_TENANCY=1), so no engine enforces organization boundaries; the console can raise an operator warning off it. A status signal, not a capability gate; absent means not degraded |
| **oidcProvider** | `boolean` | optional | Embedded OIDC authorization server wired, from the same decision that mounts it, so OAuth applications can be registered and managed; on by default alongside the MCP surface. It says nothing about sign-in providers, which socialProviders lists; the flag is default-on, so absent reads as on |
| **deviceAuthorization** | `boolean` | optional | Device authorization (browser-approved CLI login) wired, so the device-code endpoints answer; when false the console device-approval page says device authorization is not enabled instead of calling them. Absent means not wired |
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it; the console still shows its unlock and set-password actions only when it is true. Absent means not wired |
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |

Expand Down Expand Up @@ -227,7 +227,7 @@ This schema accepts one of the following structures:
| **degradedTenancy** | `boolean` | optional | Degraded tenancy: true when multi-organization isolation was requested but is not active (the deployment booted only because OS_ALLOW_DEGRADED_TENANCY=1), so no engine enforces organization boundaries; the console can raise an operator warning off it. A status signal, not a capability gate; absent means not degraded |
| **oidcProvider** | `boolean` | optional | Embedded OIDC authorization server wired, from the same decision that mounts it, so OAuth applications can be registered and managed; on by default alongside the MCP surface. It says nothing about sign-in providers, which socialProviders lists; the flag is default-on, so absent reads as on |
| **deviceAuthorization** | `boolean` | optional | Device authorization (browser-approved CLI login) wired, so the device-code endpoints answer; when false the console device-approval page says device authorization is not enabled instead of calling them. Absent means not wired |
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it; the console still shows its unlock and set-password actions only when it is true. Absent means not wired |
| **admin** | `boolean` | optional | Admin plugin wired (forced on whenever SCIM is enabled), so creating and impersonating users is available; the console shows those actions only when it is true. Banning, unbanning, unlocking and setting a password answer without it, and whether the console offers those actions does not depend on it. Absent means not wired |
| **termsUrl** | `string` | optional | Terms-of-service link shown beneath the login and register cards: the trimmed OS_TERMS_URL value when set, otherwise the public ObjectStack terms page; absent when the operator set OS_TERMS_URL to an empty or blank (whitespace-only) value to suppress the link |
| **privacyUrl** | `string` | optional | Privacy-policy link shown beneath the login and register cards: the trimmed OS_PRIVACY_URL value when set, otherwise the public ObjectStack privacy page; absent when the operator set OS_PRIVACY_URL to an empty or blank (whitespace-only) value to suppress the link |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,19 @@ describe('sys_user Ban / Unban switch with `banned`', () => {
});

/**
* Ban / Unban are offered on a kernel WITHOUT the better-auth admin plugin:
* their doors (plugin-auth `admin/ban-user` / `admin/unban-user`) are mounted
* and enforce the ban there too, so `features.admin` off, the flag every such
* kernel serves, managed or not, hides neither. The actions whose doors still
* need the plugin keep their `requiresFeature: 'admin'` gate.
* Ban / Unban / Unlock / Set Password are offered on a kernel WITHOUT the
* better-auth admin plugin: their doors (plugin-auth `admin/ban-user` /
* `admin/unban-user` / `admin/unlock-user` / `admin/set-user-password`) are
* mounted and work there too, so `features.admin` off, the flag every such
* kernel serves, managed or not, hides none of them (Set Password keeps its
* own hide-when-cloud-managed rule). The actions whose doors still need the
* plugin keep their `requiresFeature: 'admin'` gate.
*/
describe('sys_user Ban / Unban are offered without the admin plugin', () => {
describe('sys_user Ban / Unban / Unlock / Set Password are offered without the admin plugin', () => {
const ban = visibleOf(SysUser, 'ban_user');
const unban = visibleOf(SysUser, 'unban_user');
const unlock = visibleOf(SysUser, 'unlock_user');
const setPassword = visibleOf(SysUser, 'set_user_password');
/** What a kernel without the plugin serves: unmanaged (self-hosted) and managed (a Free or Team environment). */
const WITHOUT_PLUGIN = [
{ admin: false, apiKey: true, cloudManaged: false },
Expand All @@ -109,21 +113,36 @@ describe('sys_user Ban / Unban are offered without the admin plugin', () => {
}
});

it('a locked or two-factor account is offered Unlock and one with neither is not, managed or not', () => {
for (const features of WITHOUT_PLUGIN) {
const where = JSON.stringify(features);
expect(offered(unlock, { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: false }, ADMIN, features), where).toBe(true);
expect(offered(unlock, { locked_until: null, two_factor_enabled: true }, ADMIN, features), where).toBe(true);
expect(offered(unlock, { locked_until: null, two_factor_enabled: false }, ADMIN, features), where).toBe(false);
}
});

it('Set Password is offered unmanaged and stays hidden managed, its own rule kept', () => {
const [unmanaged, managed] = WITHOUT_PLUGIN;
expect(offered(setPassword, { source: 'env_native' }, ADMIN, unmanaged!)).toBe(true);
expect(offered(setPassword, { source: 'env_native' }, ADMIN, managed!)).toBe(false);
});

it('the standing leg stays: a caller without it is offered neither with the plugin off', () => {
for (const features of WITHOUT_PLUGIN) {
for (const banned of [true, false]) {
expect(offered(ban, { banned }, MEMBER, features)).toBe(false);
expect(offered(unban, { banned }, MEMBER, features)).toBe(false);
}
expect(offered(unlock, { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: true }, MEMBER, features)).toBe(false);
expect(offered(setPassword, { source: 'env_native' }, MEMBER, features)).toBe(false);
}
});

// CONTROL: the admin-plugin-only actions. Each row is one its predicate
// otherwise offers, so the flag alone decides.
const PLUGIN_ONLY: ReadonlyArray<[string, Record<string, unknown>]> = [
['unlock_user', { locked_until: '2999-01-01T00:00:00.000Z', two_factor_enabled: true }],
['create_user', {}],
['set_user_password', { source: 'env_native' }],
['impersonate_user', {}],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
* flag the payload lacks (`default-on` ones too), so that case is the
* consumer's fault handling, the same for every flag.
*
* Each of the six already carries another flag's gate (`organization` or
* `admin`) through `requiresFeature`, so the `cloudManaged` gate is written in
* `visible` and the two compose. The predicates are EVALUATED through the
* Five of the six also carry another flag's gate (`organization` or `admin`)
* through `requiresFeature`, so the `cloudManaged` gate is written in
* `visible` and the two compose. `set_user_password` carries none: its door
* works without the better-auth admin plugin (the admin block header in
* `sys-user.object.ts`), so `cloudManaged` is its only flag. The predicates are EVALUATED through the
* canonical engine the console delegates to (`@objectstack/formula`), on the
* parsed object, so the lowered envelope is what is judged; a string match
* would stay green on a predicate that faults or never answers true.
Expand All @@ -33,7 +35,7 @@ import { SysOrganization } from './sys-organization.object.js';
/** Holds every standing the six doors ask for: the platform-admin rung and the owner grade. */
const ADMIN = { id: 'u_admin', email: 'admin@example.com', positions: ['org_owner'], isPlatformAdmin: true };

/** The other flags the six inputs are gated on, all on, so `cloudManaged` alone decides. */
/** The other flags five of the six inputs are gated on, all on, so `cloudManaged` alone decides. */
const OTHER_FLAGS = { organization: true, admin: true };

const SIX: ReadonlyArray<[string, { actions?: unknown }, string]> = [
Expand Down Expand Up @@ -73,9 +75,18 @@ describe('features.cloudManaged hides the six doors that add people', () => {
expect(offered(visibleOf(def, name), { ...OTHER_FLAGS, cloudManaged: false })).toBe(true);
});

it.each(SIX)('%s keeps its other flag: off hides it whatever cloudManaged says', (_site, def, name) => {
/** The five that carry another flag; `set_user_password` carries only `cloudManaged`. */
const GATED_TWICE = SIX.filter(([site]) => site !== 'sys_user.set_user_password');

it.each(GATED_TWICE)('%s keeps its other flag: off hides it whatever cloudManaged says', (_site, def, name) => {
expect(offered(visibleOf(def, name), { organization: false, admin: false, cloudManaged: false })).toBe(false);
});

it('sys_user.set_user_password reads no other flag: offered with the admin plugin off, hidden managed', () => {
const source = visibleOf(SysUser, 'set_user_password');
expect(offered(source, { organization: false, admin: false, cloudManaged: false })).toBe(true);
expect(offered(source, { organization: false, admin: false, cloudManaged: true })).toBe(false);
});
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ describe('the visible predicate: offered on every row, the SCIM-held refusal is
});

it('⛔ is NOT gated on features.admin, and that is deliberate', () => {
// The `admin` flag hides buttons whose endpoint is "only wired when
// `auth.plugins.admin` is enabled" — the 404-avoidance the block header on
// the admin actions states. This route is not one of those: it is an
// The `admin` flag hides buttons whose endpoint needs the better-auth
// admin plugin, so that the UI does not render buttons that 404 (the block
// header on the admin actions). This route is not one of those: it is an
// ObjectStack mount registered unconditionally beside `unlock-user` and
// authorized by the ADR-0068 platform-admin gate, so gating it would hide
// a WORKING affordance on every host that never opted into that plugin —
Expand Down
Loading
Loading