diff --git a/.changeset/34008-ban-without-admin-plugin-prose.md b/.changeset/34008-ban-without-admin-plugin-prose.md new file mode 100644 index 00000000000..46494609453 --- /dev/null +++ b/.changeset/34008-ban-without-admin-plugin-prose.md @@ -0,0 +1,16 @@ +--- +'@objectstack/spec': patch +--- + +docs(spec): the admin-plugin descriptions no longer say ban, unban, unlock and set-password need the plugin + +Clause-②: no +Metadata-protocol: none + +`POST {routes.auth}/admin/ban-user`, `/admin/unban-user`, `/admin/unlock-user` and `/admin/set-user-password` are ObjectStack mounts, served whether or not the better-auth admin plugin is on. Three descriptions still said otherwise, and now say this: + +- `AuthFamiliesSchema.admin` (`@objectstack/spec/api`, served as `authFamilies.admin` on discovery): the family whose routes answer a plain `404` when the flag is false is `list-users`, `set-role`, `update-user`, `impersonate-user` and the other better-auth routes. `ban-user` and `unban-user` are not in it. +- `features.admin` on `GET {routes.auth}/config`: creating and impersonating users are the operations that need the plugin. Banning, unbanning, unlocking and setting a password answer without it (the console still shows its unlock and set-password actions only when the flag is true). +- `plugins.admin` in the auth config: its description and JSDoc list what needs the plugin (`create-user`, which answers `501` without it, impersonation and the vendor routes such as `set-role` and `list-users`) apart from the ObjectStack mounts served without it (`ban-user`, `unban-user`, `unlock-user`, `set-user-password`). The JSDoc no longer says better-auth enforces the admin check on every route: the ObjectStack mounts, `create-user`, `remove-user` and `impersonate-user` run the ADR-0068 platform-admin gate, the vendor routes keep better-auth's legacy-role check, and `stop-impersonating` is admitted on the impersonated session with its signed `admin_session` cookie. + +The `requiresFeature` example in the actions guide gates `impersonate_user` on `admin`, in place of `ban_user`. Nothing a schema accepts or refuses changes. diff --git a/content/docs/protocol/objectui/actions.mdx b/content/docs/protocol/objectui/actions.mdx index ab9aba18121..0810fef374e 100644 --- a/content/docs/protocol/objectui/actions.mdx +++ b/content/docs/protocol/objectui/actions.mdx @@ -410,10 +410,10 @@ When an action (or param) only works with an opt-in auth capability behind it ```yaml # Hidden entirely when the admin plugin is off (instead of a button that 404s) -name: ban_user -label: Ban User +name: impersonate_user +label: Impersonate User type: api -target: /api/v1/auth/admin/ban-user +target: /api/v1/auth/admin/impersonate-user requiresFeature: admin # Composes with a residual row predicate: diff --git a/content/docs/references/api/auth-endpoints.mdx b/content/docs/references/api/auth-endpoints.mdx index 57966a916b4..e31eff3e7ce 100644 --- a/content/docs/references/api/auth-endpoints.mdx +++ b/content/docs/references/api/auth-endpoints.mdx @@ -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 user administration (creating, banning, unlocking and impersonating users, setting their passwords) is available; the console shows those 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; the console still shows its unlock and set-password actions only when it is true. 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 | @@ -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 user administration (creating, banning, unlocking and impersonating users, setting their passwords) is available; the console shows those 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; the console still shows its unlock and set-password actions only when it is true. 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 | diff --git a/content/docs/references/api/discovery.mdx b/content/docs/references/api/discovery.mdx index e56d4f80e79..14833bed434 100644 --- a/content/docs/references/api/discovery.mdx +++ b/content/docs/references/api/discovery.mdx @@ -57,7 +57,7 @@ Which optional better-auth route families are mounted under routes.auth | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, ban-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. | +| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, impersonate-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. ban-user and unban-user are not in the family: they are ObjectStack mounts, served whatever this says. | --- @@ -166,7 +166,7 @@ Which optional better-auth route families are mounted under routes.auth | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, ban-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. | +| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, impersonate-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. ban-user and unban-user are not in the family: they are ObjectStack mounts, served whatever this says. | --- diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 7b082da542c..3e1ee93144a 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1177,7 +1177,7 @@ This schema accepts one of the following structures: | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, ban-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. | +| **admin** | `boolean` | ✅ | Whether the better-auth admin family (`{routes.auth}`/admin/*: list-users, set-role, update-user, impersonate-user, …) is mounted. Same value as features.admin on GET `{routes.auth}`/config, read from the same source; false means those routes answer a plain 404 on this deployment. ban-user and unban-user are not in the family: they are ObjectStack mounts, served whatever this says. | --- diff --git a/content/docs/references/system/auth-config.mdx b/content/docs/references/system/auth-config.mdx index 2f1e4a1984a..834ffeead3f 100644 --- a/content/docs/references/system/auth-config.mdx +++ b/content/docs/references/system/auth-config.mdx @@ -104,7 +104,7 @@ Advanced / low-level Better-Auth options | **oidcProvider** | `boolean` | optional (default: `false`) | Enable the OpenID Connect provider plugin (acts as an OIDC IdP) | | **dynamicClientRegistration** | `boolean` | optional | Allow unauthenticated RFC 7591 Dynamic Client Registration (default: follows OS_MCP_SERVER_ENABLED) | | **deviceAuthorization** | `boolean` | optional (default: `false`) | Enable RFC 8628 Device Authorization Grant (CLI / TV-style login) | -| **admin** | `boolean` | optional | Enable platform admin operations (ban/unban, set-password, impersonate, set-role). Unset: forced on by effective SCIM (ADR-0134), otherwise off. An explicit false beside effective SCIM is a conflict refused at construction time. | +| **admin** | `boolean` | optional | Enable the better-auth admin plugin: create-user, impersonation and the vendor admin routes (set-role, list-users, …). Ban/unban, unlock and set-password are served without it. Unset: forced on by effective SCIM (ADR-0134), otherwise off. An explicit false beside effective SCIM is a conflict refused at construction time. | | **phoneNumber** | `boolean` | optional (default: `false`) | Enable phone-number sign-in (phone + password; OTP sign-in/reset when an SMS service is configured) | | **scim** | `boolean` | optional | Enable the SCIM 2.0 provisioning surface. Unset: OS_SCIM_ENABLED decides (absent = off); an explicit value wins over the env var. Effective SCIM forces the admin plugin on when admin is unset; an explicit admin: false beside effective SCIM is refused at construction time. | | **sso** | `boolean` | optional | Enable enterprise SSO (domain-routed OIDC/SAML sign-in). Unset: OS_SSO_ENABLED decides (absent = off); an explicit value wins over the env var. | @@ -214,7 +214,7 @@ OIDC / Generic OAuth2 provider configuration for enterprise SSO | **oidcProvider** | `boolean` | optional (default: `false`) | Enable the OpenID Connect provider plugin (acts as an OIDC IdP) | | **dynamicClientRegistration** | `boolean` | optional | Allow unauthenticated RFC 7591 Dynamic Client Registration (default: follows OS_MCP_SERVER_ENABLED) | | **deviceAuthorization** | `boolean` | optional (default: `false`) | Enable RFC 8628 Device Authorization Grant (CLI / TV-style login) | -| **admin** | `boolean` | optional | Enable platform admin operations (ban/unban, set-password, impersonate, set-role). Unset: forced on by effective SCIM (ADR-0134), otherwise off. An explicit false beside effective SCIM is a conflict refused at construction time. | +| **admin** | `boolean` | optional | Enable the better-auth admin plugin: create-user, impersonation and the vendor admin routes (set-role, list-users, …). Ban/unban, unlock and set-password are served without it. Unset: forced on by effective SCIM (ADR-0134), otherwise off. An explicit false beside effective SCIM is a conflict refused at construction time. | | **phoneNumber** | `boolean` | optional (default: `false`) | Enable phone-number sign-in (phone + password; OTP sign-in/reset when an SMS service is configured) | | **scim** | `boolean` | optional | Enable the SCIM 2.0 provisioning surface. Unset: OS_SCIM_ENABLED decides (absent = off); an explicit value wins over the env var. Effective SCIM forces the admin plugin on when admin is unset; an explicit admin: false beside effective SCIM is refused at construction time. | | **sso** | `boolean` | optional | Enable enterprise SSO (domain-routed OIDC/SAML sign-in). Unset: OS_SSO_ENABLED decides (absent = off); an explicit value wins over the env var. | diff --git a/packages/spec/src/api/auth-endpoints.zod.ts b/packages/spec/src/api/auth-endpoints.zod.ts index 00c382e0685..7eaaa47eab3 100644 --- a/packages/spec/src/api/auth-endpoints.zod.ts +++ b/packages/spec/src/api/auth-endpoints.zod.ts @@ -366,8 +366,8 @@ export const AuthFeaturesConfigSchema = lazySchema(() => z.object({ + 'Absent means not wired', ), admin: z.boolean().optional().describe( - 'Admin plugin wired (forced on whenever SCIM is enabled), so user administration (creating, banning, unlocking and impersonating users, setting their passwords) is available; ' - + 'the console shows those actions only when it is true. Absent means not wired', + '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', ), termsUrl: z.string().optional().describe( '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', diff --git a/packages/spec/src/api/discovery.zod.ts b/packages/spec/src/api/discovery.zod.ts index 0b8a0b5b93d..00fe0d1e3fe 100644 --- a/packages/spec/src/api/discovery.zod.ts +++ b/packages/spec/src/api/discovery.zod.ts @@ -287,9 +287,10 @@ export function readChannelRoute(svc: unknown): string | undefined { */ export const AuthFamiliesSchema = lazySchema(() => z.object({ admin: z.boolean().describe( - 'Whether the better-auth admin family ({routes.auth}/admin/*: list-users, set-role, update-user, ban-user, …) ' + 'Whether the better-auth admin family ({routes.auth}/admin/*: list-users, set-role, update-user, impersonate-user, …) ' + 'is mounted. Same value as features.admin on GET {routes.auth}/config, read from the same source; ' - + 'false means those routes answer a plain 404 on this deployment.' + + 'false means those routes answer a plain 404 on this deployment. ban-user and unban-user are not in the family: ' + + 'they are ObjectStack mounts, served whatever this says.' ), }).describe('Which optional better-auth route families are mounted under routes.auth')); diff --git a/packages/spec/src/system/auth-config.zod.ts b/packages/spec/src/system/auth-config.zod.ts index 04a58ddb6ae..caa95a36b5d 100644 --- a/packages/spec/src/system/auth-config.zod.ts +++ b/packages/spec/src/system/auth-config.zod.ts @@ -78,25 +78,34 @@ export const AuthPluginConfigSchema = lazySchema(() => z.object({ 'Enable RFC 8628 Device Authorization Grant (CLI / TV-style login)', ), /** - * Enable better-auth's `admin` plugin so platform admins can ban / unban - * users, set their password (out-of-band recovery), impersonate them for - * support sessions, and assign global platform roles. + * Enable better-auth's `admin` plugin so platform admins can create users, + * impersonate them for support sessions, and reach better-auth's own admin + * routes (`set-role`, `list-users`, …). * - * Endpoints exposed under the auth route: - * - `POST /admin/ban-user` / `POST /admin/unban-user` - * - `POST /admin/set-user-password` + * Endpoints under the auth route that need it: + * - `POST /admin/create-user` (answers `501 NOT_IMPLEMENTED` without it) * - `POST /admin/impersonate-user` / `POST /admin/stop-impersonating` * - `POST /admin/set-role` - * - `POST /admin/create-user` / `POST /admin/remove-user` - * - `POST /admin/list-users` / `POST /admin/list-user-sessions` + * - `POST /admin/remove-user` + * - `GET /admin/list-users` / `POST /admin/list-user-sessions` * - `POST /admin/revoke-user-session(s)` * + * Served with the plugin off as well as on, as ObjectStack mounts rather + * than the plugin's own routes: `POST /admin/ban-user` / + * `POST /admin/unban-user`, `POST /admin/unlock-user` and + * `POST /admin/set-user-password`. + * * The plugin augments `sys_user` with `role`, `banned`, `ban_reason`, * `ban_expires` and `sys_session` with `impersonated_by`. These columns * are mapped to snake_case by `buildAdminPluginSchema()`. * - * Only callers whose user has a platform admin role (default: `admin`) - * can hit these endpoints; better-auth enforces this internally. + * The ObjectStack mounts, `create-user`, `remove-user` and the rebuilt + * `impersonate-user` run the ADR-0068 platform-admin gate; the vendor routes + * left as better-auth ships them (`set-role`, `list-users`, …) keep + * better-auth's own check of the legacy `user.role` scalar. The exception is + * `stop-impersonating`, which is neither: better-auth admits it on the + * impersonated session together with the signed `admin_session` cookie + * that `impersonate-user` set. * * Tri-state on purpose (#13816, maintainer ruling 2026-09-01): when left * UNSET, effective SCIM decides — SCIM provisioning forces the admin @@ -110,7 +119,8 @@ export const AuthPluginConfigSchema = lazySchema(() => z.object({ * admin plugin, or disable SCIM. */ admin: z.boolean().optional().describe( - 'Enable platform admin operations (ban/unban, set-password, impersonate, set-role). ' + + 'Enable the better-auth admin plugin: create-user, impersonation and the vendor admin routes (set-role, list-users, …). ' + + 'Ban/unban, unlock and set-password are served without it. ' + 'Unset: forced on by effective SCIM (ADR-0134), otherwise off. An explicit false beside ' + 'effective SCIM is a conflict refused at construction time.', ),