Skip to content

Commit 7bd5d28

Browse files
feat(auth): directSignIn.afterSignOut returns hosted sign-out through the identity provider (#35224)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgFLS4Fre2j1wzU3P5dVPqmJ)_ repo:objectstack#5 · os-bill · session_01Utp6CYxMsbSfVbHgmGptah Fixes #35106 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: none — the added key is `AuthFeaturesConfigSchema.afterSignOut`, a field `GET /auth/config` serves, which no metadata author writes; `git grep -n -e directSignIn -e localSignIn -e afterSignOut -- skills` answers 0 hits, so no skill teaches this surface ## 维护者速读 - 改了什么:直连登录(direct sign-in)新增 `afterSignOut: 'hold' | 'identity-provider'` 选项(环境变量 `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT` 优先),`/auth/config` 在直连登录开启时下发 `features.afterSignOut`;Console 登出在 `identity-provider` 且 `directSignIn: true` 时把身份提供方的登出回跳地址设为直连门 `/api/v1/auth/sign-in/direct`,否则仍是 `/login`。 - 为什么改:cloud#4465 裁决 8、10:托管环境登出后应落在云端登录页,不保留环境自己的登录页;cloud#4471 等这一项发版后设 `identity-provider`。 - 风险与回滚:默认 `hold`,未设新值的部署行为完全不变;非法取值启动即报错(与 `localSignIn` 同规则)。回滚 = 撤本 PR 或部署把值设回 `hold`。 - 先看:`ui/packages/auth/src/createAuthClient.ts`(`signOutReturn` 与 `signOut`)、`packages/plugins/plugin-auth/src/direct-sign-in.ts`(选项、环境变量、解析)、`packages/spec/src/api/auth-endpoints.zod.ts`(新字段)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/auth/src/__tests__/signOutProviderLogout-26618.test.tsx`,预期全绿,其中 `identity-provider` 一例的登出请求体是 `{ callbackURL: '/api/v1/auth/sign-in/direct' }`。 - 需要你做的:无,席位落地(契约面 L2 审核由席位安排)。 ## What changes - `@objectstack/plugin-auth`: `DirectSignInOptions.afterSignOut` (`'hold'` default, `'identity-provider'`), env `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT` winning field by field like the other direct sign-in settings, an off-vocabulary value throws at resolve time naming the variable and both values. `getPublicConfig()` serves `features.afterSignOut` while the direct sign-in setting is on, on the same terms as `localSignIn`. Type `DirectSignInAfterSignOut` on the package entry. - `@objectstack/spec`: optional `AuthFeaturesConfigSchema.afterSignOut` enum; `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS` gains `'afterSignOut'`; regenerated `authorable-surface/api.json` and the `auth-endpoints` reference page. - `@object-ui/auth`: `signOut()` resolves its `callbackURL` through `signOutReturn`: the start door `{basePath}/sign-in/direct` when the config reads `directSignIn: true` and `afterSignOut: 'identity-provider'`, else the sign-in page. It reads the config the tab holds; with none, one attempt bounded at 3 s; an unreadable config keeps the sign-in page. The sign-out round-trip note (the hold) is written only when the return is the sign-in page. - Docs: `content/docs/permissions/sso.mdx` (settings table, a "Sign-out through the identity provider" paragraph) and `content/docs/deployment/environment-variables.mdx`. ## Tests - `direct-sign-in.test.ts`: resolve defaults to `hold`, option and env both ways, off-vocabulary throws (option and env); `/auth/config` serves `hold` by default and `identity-provider` when set, env overriding the option; with the setting off `afterSignOut` is absent and every other key is unchanged; the bare door hit (what the provider returns to after logout, no cookie, no query) answers 302 off this origin to the identity provider's authorize endpoint, never the door again and never `/login` (the A4 no-loop pin). - `sso-oidc-refusal-cause.test.ts`: a real OIDC sign-in then sign-out with `callbackURL: '/api/v1/auth/sign-in/direct'` hands the provider `post_logout_redirect_uri` = the absolute door on this origin, and the session ends. - `signOutProviderLogout-26618.test.tsx`: `hold` sends `/_console/login` and writes the round-trip note; `identity-provider` sends the door and writes no note; a held config is reused (one config read); CONTROL rows return to `/login` when `directSignIn` is false, when no `afterSignOut` is served, and when the config cannot be read. - `createAuthClient.test.ts`: the plain sign-out test now counts the sign-out POST among the calls (with no config held, sign-out reads `/config` once first). - `auth-endpoints.test.ts` (spec): the served-features fixture carries `afterSignOut`, so the parse covers it. ## Acceptance notes - With no provider logout to follow (a provider without `end_session_endpoint`, or a password sign-in), the `callbackURL` is never used and the Console ends on the held sign-in page under either value, as the card scopes it ("the Console's sign-out `callbackURL`"). - The door's query set stays closed to `callbackURL`. The Console sends no `state` on sign-out, so a conforming provider appends nothing to the return address. - The direct door is used only while `features.directSignIn` reads `true`; otherwise it is not mounted (404) or cannot start, so the Console keeps `/login`. - `Metadata-protocol: added` (patch round): the new optional enum on `AuthFeaturesConfigSchema` moves `packages/spec/authorable-surface/api.json`, so the kind is `added` and `@objectstack/spec` is graded `minor`; `@objectstack/plugin-auth` and `@object-ui/auth` stay `patch`. The key addition is intended (the card's spec field). - Cloud side (cloud#4471): set `identity-provider` and register the absolute door address as a post-logout redirect URI once a release carrying this ships. ## Verification Readings A1–A4 (at `ec227fc7`, before the change): A1 `afterSignOut` appears only in `sso-oidc-refusal-cause.test.ts` constants; A2 Console sign-out hard-coded the sign-in page as `callbackURL`; A3 `localSignIn` is served from `getPublicConfig()` and declared in `auth-endpoints.zod.ts` and `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS`; A4 the door never reads the request's cookie or session and always starts a fresh provider sign-in, pinned above. Local gate and test readings are added in the report comment on #35106. --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CYxMsbSfVbHgmGptah)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CYxMsbSfVbHgmGptah --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ad15579 commit 7bd5d28

18 files changed

Lines changed: 301 additions & 26 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/spec': minor
4+
'@object-ui/auth': patch
5+
---
6+
7+
feat(auth): `directSignIn.afterSignOut` lets an explicit sign-out return through the identity provider's sign-in page
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: added
11+
12+
A deployment with direct sign-in on can now choose where an explicit sign-out returns once the identity provider has ended its own session. The default keeps today's behaviour, so nothing changes until a deployment sets the new value.
13+
14+
- The auth plugin's `directSignIn` option takes `afterSignOut: 'hold' | 'identity-provider'`, and the environment variable `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT` wins over it, like the other direct sign-in settings. `hold` is the default. Any other value refuses to boot, naming the variable and both values.
15+
- `GET /api/v1/auth/config` serves `features.afterSignOut` while the direct sign-in setting is on, on the same terms as `features.localSignIn`, and leaves it out otherwise. `AuthFeaturesConfigSchema` in `@objectstack/spec` gains the optional `afterSignOut` enum, and `PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS` gains `'afterSignOut'`.
16+
- `hold`: the Console's sign-out sends the sign-in page as the provider's return address, and the page holds with a button to sign in again, as before.
17+
- `identity-provider`: while `features.directSignIn` reads `true`, the Console's sign-out sends `{basePath}/sign-in/direct` instead, so after the provider's logout the browser goes through the direct sign-in door to the provider's own sign-in page. The door starts a fresh sign-in without the browser's cookies, and the provider has just ended its session, so it asks for credentials; it does not loop. Register the door's absolute address as a post-logout redirect URI at the provider.
18+
- `@object-ui/auth`: `AuthPublicConfig.features` gains the optional `afterSignOut`. When the tab holds no auth config at sign-out, the client reads it once (3 seconds at most) and keeps the sign-in page if it cannot.
19+
- Module exports on the `@objectstack/plugin-auth` entry: the type `DirectSignInAfterSignOut`. In `direct-sign-in.ts` (not on the package entry): `DIRECT_SIGN_IN_AFTER_SIGN_OUT`, and `DIRECT_SIGN_IN_ENV.afterSignOut`.

‎content/docs/deployment/environment-variables.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Read by `@objectstack/service-print` when `PrintServicePlugin` is composed; see
105105
| `OS_AUTH_DIRECT_SIGN_IN_ENABLED` | boolean | `false` | Send a signed-out visitor to the Console sign-in page straight to the identity provider, and back to the page they asked for. Wins over the auth plugin's `directSignIn` option. The sign-in page is still shown when no single provider can be started, after an identity-provider error, and for an OAuth client's hand-off. See [Skip the sign-in page](/docs/permissions/sso#skip-the-sign-in-page-direct-sign-in). |
106106
| `OS_AUTH_DIRECT_SIGN_IN_PROVIDER` | string | the one configured provider | The `providerId` direct sign-in uses: an `oidcProviders` entry or a registered SSO provider. Unset, the only configured provider is used; with none or several, the sign-in page is shown. |
107107
| `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH` | `hidden` \| `off` | `hidden` | With direct sign-in on, whether the Console sign-in form keeps the password form at `/login?local=1` (`hidden`) or offers no local way in (`off`). Server-side password sign-in is unchanged either way. Any other value refuses to boot. |
108+
| `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT` | `hold` \| `identity-provider` | `hold` | With direct sign-in on, where an explicit sign-out returns when the identity provider ends its own session: the Console sign-in page, which holds (`hold`), or the direct sign-in door, so the identity provider's own sign-in page is shown (`identity-provider`). Wins over `directSignIn.afterSignOut`. Any other value refuses to boot. |
108109
| `OS_TENANCY_POSTURE` | `single` \| `group` \| `isolated` | derived from `OS_MULTI_ORG_ENABLED` | Which organization wall the authorization kernel enforces (ADR-0105 D1). `single` = no wall. `group` = `organization_id IN accessible_org_ids` — organizations are membership boundaries over one shared dataset, with union read access across every organization the caller belongs to. `isolated` = `organization_id = <active organization>`, the hard legal-entity wall (formerly spelled `multi`). Unset derives from `OS_MULTI_ORG_ENABLED` (`true` ⇒ `isolated`, else `single`), so existing deployments are unchanged. An unrecognized value **refuses to boot** rather than silently falling back to a posture with no wall. Both walled postures require the enterprise `@objectstack/organizations` runtime — without it the request resolves to `single` and boot is refused unless `OS_ALLOW_DEGRADED_TENANCY=1`. |
109110
| `OS_MULTI_ORG_ENABLED` | boolean | `false` | Superseded by `OS_TENANCY_POSTURE`, and still honoured: `true` selects the `isolated` posture. When `true`, organization creation/switching UI is exposed. |
110111
| `OS_AUTOMATION_SCHEDULED_WORK_ENABLED` | boolean | `false` | Whether this deployment runs **package-authored scheduled work**: time-triggered flows (a `type: 'schedule'` flow with a `config.schedule` cadence, and the `timeRelative` sweep) and packaged `defineJob` cron jobs. **OFF by default in every posture and every kernel** — a clock-driven workload's cost is a fact about the deployment, not about the flow, so an author cannot decide it and no metadata key asks them to. Accepts `true`/`1`/`on`/`yes` (case-insensitive); anything else, including unset, is off. While it is off nothing arms, and every such flow is listed by `getTriggerBindingAudit()` and the CLI startup summary as **disabled by deployment policy** — never as a binding failure, and nothing about the flow needs fixing. While it is on, what a time-triggered flow owes depends on the posture: under `isolated` it must declare `config.organization` on its start node or it is not armed; under `group` the declaration is optional and an undeclared sweep reads group-wide with each run acting as its own swept record's organization (a record-less cron there carries none, and its tenant-scoped writes are refused — declare one if it writes); under `single` it needs no declaration and its runs carry no organization. ⛔ Platform-internal scheduled work — approvals escalation, the lifecycle Reaper, the messaging dispatch loop, membership backfill — is **not** gated by this: the boundary is *authored by a package*, not *runs on the job service*. `os doctor` prints the effective value. |

‎content/docs/permissions/sso.mdx‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,13 @@ OS_AUTH_DIRECT_SIGN_IN_ENABLED=true
773773
# OS_AUTH_DIRECT_SIGN_IN_PROVIDER=okta
774774
# Optional: hidden (default) or off.
775775
# OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH=hidden
776+
# Optional: hold (default) or identity-provider.
777+
# OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT=hold
776778
```
777779

778780
```ts
779781
new AuthPlugin({
780-
directSignIn: { provider: 'okta', localSignIn: 'hidden' },
782+
directSignIn: { provider: 'okta', localSignIn: 'hidden', afterSignOut: 'hold' },
781783
});
782784
```
783785

@@ -786,6 +788,7 @@ new AuthPlugin({
786788
| `OS_AUTH_DIRECT_SIGN_IN_ENABLED` | `true` / `false` | Turns it on or off, whatever the option says. |
787789
| `OS_AUTH_DIRECT_SIGN_IN_PROVIDER` | a `providerId` | An [`oidcProviders`](#enterprise-sso-oidc) entry or a registered SSO provider. Unset, the only one configured is used; with none or several configured, the sign-in page is shown as before. |
788790
| `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH` | `hidden` (default) / `off` | `hidden` keeps the password form at `/login?local=1`. `off` means the sign-in form offers no local way in. Any other value refuses to boot. |
791+
| `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT` | `hold` (default) / `identity-provider` | Where an explicit sign-out returns when the identity provider ends its own session. `hold` returns to the sign-in page, which holds (see **No loops** below). `identity-provider` returns through the direct sign-in door, so the person lands on the identity provider's own sign-in page. Any other value refuses to boot. |
789792

790793
With `off`, the sign-in form offers no local way in, in any of its states: no
791794
email or phone form, no sign-up link and no "use password" link, also on an
@@ -859,6 +862,18 @@ button (and the reason, where there is one), instead of starting again when:
859862
reads it once, so a reload of the held page, or another tab, starts the
860863
sign-in as for a fresh visit.
861864

865+
**Sign-out through the identity provider.** With `afterSignOut:
866+
'identity-provider'` (or `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT=identity-provider`),
867+
a sign-out that goes through the provider's logout comes back to
868+
`GET /api/v1/auth/sign-in/direct` instead of the sign-in page, so the person
869+
sees the identity provider's own sign-in page and no sign-in page of this
870+
deployment. Register that door's absolute address as a post-logout redirect URI
871+
at the provider. It cannot loop: the provider has just ended its own session,
872+
and the door starts a fresh sign-in without the browser's cookies, so the
873+
provider asks for credentials. The Console uses the door only while
874+
`features.directSignIn` reads `true`; otherwise, and when the provider has no
875+
logout to go through, the sign-out ends on the held sign-in page as above.
876+
862877
An OAuth client's authorization hand-off (`client_id` or `redirect_uri` on the
863878
sign-in URL) keeps today's sign-in page. API keys, bearer tokens, `/api/*` and
864879
`/mcp` are never redirected.

‎content/docs/references/api/auth-endpoints.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const result = AuthEndpointSchema.parse(data);
6363
| **ssoEnforced** | `boolean` | optional | SSO-only login enforced: the UI hides the local password form + self-registration (a break-glass "use a password" link remains) |
6464
| **directSignIn** | `boolean` | optional | Direct sign-in on and able to start: a signed-out visitor to the sign-in page is sent straight to the identity provider through GET /auth/sign-in/direct and returns to the page they opened. The served value is refined twice before answering: true only when this server mounted the start door at start-up and one provider resolves; absent or false means the sign-in page is shown as usual |
6565
| **localSignIn** | `Enum<'hidden' \| 'off'>` | optional | The local sign-in path behind direct sign-in, served while the direct sign-in setting is on, whatever directSignIn reads (it can read false when no provider can start, or when the setting was turned on after start-up and the door is not mounted): hidden keeps the sign-in form at /login?local=1, off means the sign-in form offers no local way in. It changes no server door: password sign-in answers the same either way |
66+
| **afterSignOut** | `Enum<'hold' \| 'identity-provider'>` | optional | Where an explicit sign-out returns when the identity provider ends its own session, served on the same terms as localSignIn: hold sends the browser back to the sign-in page, which holds with a button to sign in again; identity-provider sends it back through GET /auth/sign-in/direct, so the identity provider shows its own sign-in page. The sign-in page reads identity-provider only while directSignIn reads true; absent means hold |
6667
| **phoneNumber** | `boolean` | optional | Phone-number sign-in enabled (phone + password, V1.5) |
6768
| **phoneNumberOtp** | `boolean` | optional | Phone-number OTP sign-in and self-service password reset available — requires the phoneNumber plugin plus a deliverable SMS service |
6869
| **emailDelivery** | `boolean` | optional | Email leaves this deployment: the wired email service reports itself configured with a real transport, so password-reset, verification and invitation mail is delivered. False with no email service and with the stock log transport, which writes mail to the server console instead of sending it; the forgot-password page can then say a reset link cannot be emailed here and to ask an administrator. A statement about the deployment, never about an address: the password-reset request answers known and unknown addresses alike either way. Absent means not live |
@@ -215,6 +216,7 @@ This schema accepts one of the following structures:
215216
| **ssoEnforced** | `boolean` | optional | SSO-only login enforced: the UI hides the local password form + self-registration (a break-glass "use a password" link remains) |
216217
| **directSignIn** | `boolean` | optional | Direct sign-in on and able to start: a signed-out visitor to the sign-in page is sent straight to the identity provider through GET /auth/sign-in/direct and returns to the page they opened. The served value is refined twice before answering: true only when this server mounted the start door at start-up and one provider resolves; absent or false means the sign-in page is shown as usual |
217218
| **localSignIn** | `Enum<'hidden' \| 'off'>` | optional | The local sign-in path behind direct sign-in, served while the direct sign-in setting is on, whatever directSignIn reads (it can read false when no provider can start, or when the setting was turned on after start-up and the door is not mounted): hidden keeps the sign-in form at /login?local=1, off means the sign-in form offers no local way in. It changes no server door: password sign-in answers the same either way |
219+
| **afterSignOut** | `Enum<'hold' \| 'identity-provider'>` | optional | Where an explicit sign-out returns when the identity provider ends its own session, served on the same terms as localSignIn: hold sends the browser back to the sign-in page, which holds with a button to sign in again; identity-provider sends it back through GET /auth/sign-in/direct, so the identity provider shows its own sign-in page. The sign-in page reads identity-provider only while directSignIn reads true; absent means hold |
218220
| **phoneNumber** | `boolean` | optional | Phone-number sign-in enabled (phone + password, V1.5) |
219221
| **phoneNumberOtp** | `boolean` | optional | Phone-number OTP sign-in and self-service password reset available — requires the phoneNumber plugin plus a deliverable SMS service |
220222
| **emailDelivery** | `boolean` | optional | Email leaves this deployment: the wired email service reports itself configured with a real transport, so password-reset, verification and invitation mail is delivered. False with no email service and with the stock log transport, which writes mail to the server console instead of sending it; the forgot-password page can then say a reset link cannot be emailed here and to ask an administrator. A statement about the deployment, never about an address: the password-reset request answers known and unknown addresses alike either way. Absent means not live |

‎packages/plugins/plugin-auth/src/auth-manager.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,6 +6014,10 @@ export class AuthManager {
60146014
// value served only while direct sign-in is on (registered in
60156015
// PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS).
60166016
...(directSignIn.enabled ? { localSignIn: directSignIn.localSignIn } : {}),
6017+
// Where the console's explicit sign-out returns (`hold` | `identity-provider`),
6018+
// served on the same terms as `localSignIn` (registered in
6019+
// PUBLIC_AUTH_CONFIG_NON_FLAG_KEYS).
6020+
...(directSignIn.enabled ? { afterSignOut: directSignIn.afterSignOut } : {}),
60176021
...(termsUrl ? { termsUrl } : {}),
60186022
...(privacyUrl ? { privacyUrl } : {}),
60196023
// The public base URL every emailed / OAuth link is built on

‎packages/plugins/plugin-auth/src/auth-plugin.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,13 @@ export interface AuthPluginOptions extends Partial<AuthConfig> {
408408
* id); unset, the one provider configured. `localSignIn` is `hidden`
409409
* (default: the sign-in page stays at `/login?local=1`) or `off` (the page
410410
* does not offer it); the server's password sign-in is unchanged either way.
411-
* Absent ⇒ off. Self-host sets `OS_AUTH_DIRECT_SIGN_IN_ENABLED`,
412-
* `OS_AUTH_DIRECT_SIGN_IN_PROVIDER` and `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH`, which win
413-
* over this option field by field.
411+
* `afterSignOut` is `hold` (default: an explicit sign-out the identity
412+
* provider ends returns to the sign-in page, which holds) or
413+
* `identity-provider` (it returns through the start door to the identity
414+
* provider's own sign-in page). Absent ⇒ off. Self-host sets
415+
* `OS_AUTH_DIRECT_SIGN_IN_ENABLED`, `OS_AUTH_DIRECT_SIGN_IN_PROVIDER`,
416+
* `OS_AUTH_DIRECT_SIGN_IN_LOCAL_PATH` and `OS_AUTH_DIRECT_SIGN_IN_AFTER_SIGN_OUT`,
417+
* which win over this option field by field.
414418
*/
415419
directSignIn?: DirectSignInOptions;
416420

0 commit comments

Comments
 (0)