Repository navigation
feat(auth): serve the stock app's OIDC routes, dark until a provider is configured - #163
Merged
Merged
Conversation
The owner confirmed the six deviations of `POST /auth/change-password/` (JSON only; no 500 pages for odd bodies; the sign-in allowance counts a signed-in caller's guesses; sessions only, no API keys; Thrust's own cookies and CSRF refusal; no change for an account with no password) on 2026-11-14. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…is configured
The stock sign-in screen has a "Sign in with SSO" button that navigates to
`GET /auth/oidc/`. Thrust had the login in its core and under the slice's own
paths, but nothing at the paths the app uses. This adds `GET /auth/oidc/` and
`GET /auth/oidc/callback/` over `oidc_start` and `oidc_callback` (X10, D-040).
It ships dark, as the owner chose (Q-0050.9 stays for M6): `/api/instances/`
says `is_oidc_enabled` only while a provider is configured, and none is
anywhere, because the Worker cannot reach the WARP-only issuer. So no button is
drawn, and the routes answer `OIDC_NOT_CONFIGURED` to anyone who types them in.
A login that the core accepts is the same session as a password sign-in and a
302 to `/`. Every refusal is a 302 to `/?error_code=&error_message=` with no
cookie, as the pin's fork answers its own: an identity Thrust will not let in
(no verified email, no account, a deactivated one: no provisioning at a login,
Q-0050.1) is told as SIGNUP_DISABLED (5015), which is the pin's code for a
person with no account where none is made and the one the stock app has words
for; a provider that rejects, cannot be reached, or a state or code that is
missing, unknown or used is OIDC_OAUTH_PROVIDER_ERROR (5301). The app has no
text for 5300 and 5301 (checked in `authErrorHandler`): D-040 says so, and that
the person's place (`next_path`) is not carried.
The contract `e2e` pass now starts its target with no provider, as the
deployment is. Without that the sign-in journey sees the button and fails
("a sign-in method other than the password is on the sign-in page"): shown by
running the journeys with the settings left in.
Tests: 12 hermetic ones with a scripted provider (the flag follows the
provider; a dark deployment answers 5300; a 7 by 7 matrix of what the provider
says by what the browser brings, 49 worlds, with how often the provider is
asked), three contract tests on all four targets against the mock identity
provider (73 of 73 on native-memory, native-pg, worker-memory and worker-cf).
Controls: three new mutants, plus the existing unverified-email one. The flag
mutant is killed by the hermetic test only (every contract target has a
provider). The state-reusable mutant is killed by the slice's replay test at
contract level, because the mock also refuses a reused code with the same
redirect. Two new scripts/mutants.sh rows, run by hand.
Also records the owner's confirmation of D-039 (separate commit).
Not measured: a real provider (nothing has run against Zitadel or any issuer
but the mock), a browser journey of the button and the callback, a deployed
Worker, scripts/mutants.sh as a whole.
Refs: #46
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The owner confirmed the five differences of the stock app's OIDC routes from the pin's fork (the person's place is not carried; no account is made at a login; the redirect URI is configured and not built from the request; every refusal is a redirect with SIGNUP_DISABLED or the fork's 5301, and the app has no text for the fork's two OIDC codes; the fork's `spaces/oidc` pair is not built) on 2026-11-14. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`scripts/check-plane-500.sh` (the `deps` job's Plane 500 guard) refuses a compat file that writes a 500 itself: every reproduced Plane 500 goes through `thrust_plane_types::plane_500`. The refusal redirect of `oidc.rs` had a fallback that answered a 500 if its Location header could not be made. That header is built from a number and a constant name, all printable ASCII, so it cannot fail; the fallback now redirects to the root with no error code and no cookie (a refused login that says nothing), which is not a 500. I ran three of the scripts of that CI job before pushing and not this one. Every guard run of that job (dependency graph, topology and its self-test, Plane 500 and its self-test, acceptance list and its self-test, placement) now passes locally. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
G-35 said the e2e pass had run 2 of 2 journeys on worker-memory, which was true before the branch was rebased onto the password journey. After the rebase it is 3 of 3, and this change's own CI ran the same suite on the worker-cf cell (run 43568522180): every control failed with its words, slow-page passed, and the target was dark. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 14, 2026
aRustyDev
added a commit
that referenced
this pull request
Nov 15, 2026
…tests (#172) * test(contract): port the slice's OIDC checks that the compat tests lacked Step 5d of moving off /api/_slice: the slice's OIDC pair (`GET /api/_slice/auth/oidc/start` and `/callback`) has a Plane-shaped replacement since #163 (`GET /auth/oidc/` and `/auth/oidc/callback/`, D-040), so the pair and its six `oidc_` tests can go. #163's `compat_oidc_*` tests already cover most of what the six assert (login completes, the link decides by subject, a tampered, unknown, missing, refused or replayed state, the five ID-token tamperings, no verified email, no provisioning, a deactivated user by email and by link). Five assertions of the six were in no compat test, and deleting the six without them would lose real coverage, so they come first, while the slice route still exists to compare with. No test is added: they go into the two existing compat tests, so the main pass stays 73 of 73. Ported: - The OIDC session's cookies carry the attributes of a password sign-in's (Secure, HttpOnly, SameSite=Lax, Path=/, no Domain, Max-Age 30 days), a 64-hex session token and a 32-hex CSRF value. Before this, the hermetic test held Secure, HttpOnly, Lax, Path and Domain, and nothing held Max-Age for the OIDC callback. - A different subject with another account's verified email is a different login and goes to that account (the control for "the subject decides"). - The email is matched like a password sign-in's: case and padding do not matter. - A subject that is already linked does not get around the verified-email rule (a different code path from the three unlinked cases). - The mock identity provider refuses an exchange whose PKCE verifier is not the challenge's (the control that shows the target's own verifier is what makes the logins work). Controls, each a temporary mutation of one file that was reverted (the tree was clean again after each, checked), each run through the native-memory main pass. The compat test named failed at the ported assertion, read from its panic message: - The callback's cookies live half as long: `compat_oidc_login_completes...` fails at "30 days" (Max-Age 1296000). - The provider's email is not normalized: `compat_oidc_login_completes...` fails because the padded-email login is refused (the panic is in the helper's "a session cookie"; that login is the only one whose email is not already normalized). - The link is made on the issuer and not the subject: `compat_oidc_login_completes...` fails at "a different subject is a different login" (and `compat_oidc_every_refusal...` fails too, earlier, because the memory adapter's links are shared by every test of the run). - The verified-email rule is applied only to an identity not yet linked: `compat_oidc_every_refusal...` fails at "a linked subject with an unverified email" (the slice's own test failed too). - The mock accepts any PKCE verifier: `compat_oidc_login_completes...` fails because the exchange answered 200 and not 400. Checked: native-memory main 73 of 73 with the ports in. Not run here: the other three targets (CI runs them). Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * refactor(api): delete the slice's OIDC routes and their six contract tests Step 5d of moving off /api/_slice. #163 put Plane's routes (`GET /auth/oidc/` and `/auth/oidc/callback/`, D-040) over the same core `oidc_start` and `oidc_callback`, with `compat_oidc_*` contract tests, so the slice's pair has a Plane-shaped replacement and the owner's standing decision of 2026-11-11 applies: it goes. The previous commit ported what the six `oidc_` tests held that the compat tests did not. Deleted: - `GET /api/_slice/auth/oidc/start` and `/callback`, their handlers and the callback's query struct (thrust-api), and the two unused imports they leave; the two entries of `slice_auth_routes()` (so `the_slice_routes_are_gone_from_the_reserved_v1_prefix` walks 5 routes there, no longer 7) and its `no_redirect` comment. - The six `oidc_` tests of `tests/auth/mod.rs` and their helpers (`begin`, `finish`, `assert_logged_in`, `assert_refused`, `unique_sub`, the mock-IdP import). `EXPECT_MAIN` is 67. Changed: - `scripts/contract.sh` registers the mock identity provider's redirect URI as `<origin>/auth/oidc/callback/`, the app's callback (D-040 says a deployment must register that one), where it was the slice's callback. The compat tests send the browser to the URL the mock hands back, and assert that it is the app's callback, so the registration is no longer a path the target happens not to look at. No deployment has a provider (G-35), so no registration moves. - A hole found by running the mutants: G-35 records that `mutant_oidc_state_reusable` was killed at contract level only by the slice's replay test. The compat route tells a used state and a used code alike (5301) and the mock refuses a reused code too, so with the six gone the `oidc-state-reusable` row of `scripts/mutants.sh` survived: the main pass was 67 of 67 with the mutant built in. The compat refusal test now replays a used state with a second, fresh code for the same login (the mock's `authorize` can be called twice on one Location); only the used state can refuse that code, and the mutant is killed there. - Comments and docs that named the slice's pair: flows/app.md (the route rows, the OIDC paragraph, which now describes the compat routes and their redirects with `error_code`, and the error table's OIDC cases and 502 row), contract-suite.md, defect-matrix.md (X24 names the compat tests and the three mutants), status.md (G-12, G-26 with the step and its controls, G-35's note on the state mutant), the compat OIDC module's header and the stage2 script's comment. Not changed: `scripts/stage2-contract.sh` still expects 59 for its `main` set. It skips every `oidc_` test, so the set does not change here; the list of that set is 61 on main today, so the 59 was already out of date before this commit (set at #128). It is a guard of a manual run against a deployed Worker, and what it should now say needs a run there. Checked on this tree: - native-memory main 67 of 67, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4; worker-memory main 67 of 67; worker-cf main 67 of 67 (both again after the replay assertion went in). - clippy `--workspace --all-targets -D warnings` and `cargo fmt --all --check` clean; every script of CI's `deps` job and its self-tests pass; `sh -n` of `contract.sh` and `stage2-contract.sh` under dash in Ubuntu 24.04, with a deliberately broken script that fails the check. Controls (temporary, restored and checked): - The OIDC pair back in `slice_auth_routes()`: `the_slice_routes_are_gone_from_the_reserved_v1_prefix` fails ("GET /api/_slice/auth/oidc/start: not mounted (404)"), so the routes are gone and the list would notice. - The three OIDC rows of `scripts/mutants.sh`, on native-memory main with the slice tests gone: `mutant_unverified_email` and `mutant_oidc_failure_redirect_no_code` fail `compat_oidc_every_refusal...` (exit 101); `mutant_oidc_state_reusable` passed 67 of 67 before the replay assertion, and fails `compat_oidc_every_refusal...` at "a fresh code for a state that is used" after it. Not run here: native-pg (CI runs it) and a deploy. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * fix(scripts): stage2's main pass counts 61 tests, not 59 `scripts/stage2-contract.sh main` ends with a guard: when `cargo test` exits 0 and the passed count is not `EXPECT`, it exits 5 ("exit 0 but passed count != expected"), so that a filter that selects nothing cannot report green. `EXPECT` for `main` was 59, set at #128. The set its filters select is 61: #151 added two tests (`compat_change_password_is_for_a_session_and_not_for_an_api_key` and `compat_change_password_refuses_in_planes_order_changes_nothing_then_swaps_it_and_ends_every_session`), and nothing in CI runs this script (it needs a deployed Worker, by hand), so nothing noticed. A correct run against a Worker would have failed at the guard. Found while finishing step 5d, which does not change this set (the script skips every `oidc_` test, before and after). Measured, not assumed: for each pass of the script, the number of tests its own filters select (`cargo test -p thrust-contract-tests --test <binary> -- --list --format terse`, the `: test` lines), next to the `EXPECT` it holds. Before: `main` 61 listed, 59 expected, flagged as differing. After: all thirteen passes agree (main 61, csrfoff 6, worker 1, bindings 3, cron 1, crontrigger 1, sweeper 3, panic 1, blast 1, email 1, engine 4, budget 1, ratelimit 1). Only `main` was wrong. The two extra tests were found by listing the test names of the suite at #128 and of today's `main` set: the change-password pair is new; `v1_requests_are_rate_limited_per_key` is also not in the old list but is the create-limit test renamed at stage 4 (#142), so it is not an addition. Changed: - `EXPECT` for `main`, 59 to 61, and the header's "59 tests", with a comment in the script that says how to derive the number again and what went wrong this time. - `docs/src/testing/techniques/contract-suite.md`: the two places that quote the count (59, and a 31 from the spike's time) say 61 and name what the pass skips. - G-26 in `docs/src/testing/status.md` records it. Checked: `sh -n` of the script under dash in Ubuntu 24.04, with a deliberately broken script that fails the check; the thirteen counts above. Not run: the script itself against a Worker (it needs a deployed one). The 61 ties out against the runs of this PR: `main` is 67 tests, the script skips three `oidc_` and three `operator_` tests, and all 67 passed on `worker-cf` and on `worker-memory`. A run against a deployed Worker is what shows that all 61 pass there, and what shows whether either change-password test needs something a deployed Worker lacks. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The two routes behind the stock sign-in screen's "Sign in with SSO" button, shipped dark:
GET /auth/oidc/andGET /auth/oidc/callback/(X10, D-040), over the core'soidc_startandoidc_callback, which the slice's own routes already used. This is WP4 of the locked-out-recovery plan, and the owner chose to ship it dark rather than pull Q-0050.9 forward from M6.Refs #46 (it does not close it).
Dark by default
/api/instances/saysis_oidc_enabled: trueonly while a provider is configured (Ports::oidc). No deployment has one: the Worker cannot reach the WARP-only issuer until the Workers VPC service to it exists (Q-0050.9, M6). So today the app draws no SSO button, and the two routes answerOIDC_NOT_CONFIGURED(5300) to anyone who types them in.crates/thrust-compat-plane/src/instance.rs(oidc_enabled) is the one place that ties the button to the routes.What the routes do
GET /auth/oidc/with a provider?next_path=is read by nobody/with the same two session cookies as a password sign-in,no-store/?error_code=5015&error_message=SIGNUP_DISABLED, no cookie (Thrust makes no account at a login, Q-0050.1)/?error_code=5301&error_message=OIDC_OAUTH_PROVIDER_ERROR, no cookie/?error_code=5300&error_message=OIDC_NOT_CONFIGURED, no cookieSIGNUP_DISABLEDis the pin's own code for a person with no account where none is made, and the only one of these the stock app has words for ("Sign up disabled. Please contact your administrator."). A fault of this server (the database) is meant to stay a 5xx and not a redirect that blames the person: that is howcode_foris written, and no test makes the database fail, so it is not exercised.D-040 (owner confirmed 2026-11-14) and what is deliberately different from the pin's fork
?next_path=is not carried: a person lands on/.SIGNUP_DISABLEDwhen it is off.THRUST_OIDC_REDIRECT_URI, which for this route must be<origin>/auth/oidc/callback/); the fork builds it from the request's host and scheme.authErrorHandlerreturns nothing for them, so a person whose login fails at the provider sees the sign-in page unchanged. A text for them is a web change (Q-R2) for the day SSO is switched on.spaces/oidc/pair is not built (Thrust has nospacesapp).This PR also records the owner's confirmation of D-039 (the six differences of change-password) in its own commit, and amends D-037, which said the core's OIDC login was not on the compat routes.
The
e2epass is dark tooscripts/contract.shexports the mock provider's settings to every pass. With the flag now following the provider, the e2e Worker would draw an SSO button and the sign-in journey would fail. Thee2epass nowunsets them, so its target runs as the deployment does. A negative control: with thatunsetdisabled for one run, the sign-in journey fails with "a sign-in method other than the password is on the sign-in page" and M1 passes.Tests and controls
crates/thrust-compat-plane/tests/oidc.rs: 12 hermetic tests with a scripted provider that counts what it is asked: the flag is true exactly when a provider is configured, in both worlds; a dark deployment answers 5300 to five addresses; starts read nothing of the caller's; a matrix of 7 things the provider can say by 7 shapes of callback (49 worlds) against an expected table, including how often the provider is asked; a login whose state is no good for another; and the matrix's own coverage control (49 cases, 2 sessions, 8SIGNUP_DISABLED, 39OIDC_OAUTH_PROVIDER_ERROR).compat_oidc_*), against the mock identity provider, on all four targets (EXPECT_MAIN73).mutant_oidc_flag_always_on(1 hermetic test; no contract target can show it, because each has a provider, so it has noscripts/mutants.shrow),mutant_oidc_failure_redirect_no_code(7 hermetic tests and the contract refusal test),mutant_oidc_state_reusable(2 hermetic tests, and the slice's replay test at contract level). The existingmutant_unverified_emailalso fails the matrix. Two newscripts/mutants.shrows, run by hand onnative-memory: exit 101, one test each.mutant_oidc_state_reusablefrom a replayed code. The hermetic tests and the slice's replay test do.Measured
scripts/contract.sh <target> main, all four (native-memory,native-pg,worker-memory,worker-cf)native-memoryagain after each rebasescripts/mutants.shrows onnative-memoryscripts/e2e.sh worker-memory controls(target with no provider)slow-pagepasses, the count guard holdscargo nextest run --profile ci --workspacewebskipped; theworker-cf e2ecell (a real Worker, target dark): 3 of 3 journeys, every control failed with its words,slow-pagepassed; themutantsjob: no row survived,unverified-emailkilled by 2 tests and both newoidc-*rows by 1 eachcargo test --doc,cargo fmt --check, clippy (native, and the wasm32 Worker), the acceptance list (57 rows, unchanged: OIDC has none, since a recording needs a provider),check-deps,check-web-diffNot measured
scripts/stage2-contract.shskips theoidc_tests, as it skips the slice's).mdbook build.scripts/mutants.shwas run in CI by this PR'smutantsjob (every row killed on attempt 2; attempt 1'sunverified-emailrow was the exit=4 flake, reproduced as killed locally on the same tree).Operating it
docs/src/architecture/infra.mdhas a new section, "Sign in with SSO (built, and dark)": what switching it on takes and why not to set the settings early (the button is drawn as soon as they are set, and a login that cannot reach the issuer ends at the sign-in page with no words).Files
crates/thrust-compat-plane/src/oidc.rs(new),src/instance.rs,src/lib.rs,src/error.rs,tests/oidc.rs(new),tests/common/mod.rs;crates/thrust-core/src/auth.rs(a mutant spot) and the threeCargo.tomlfeatures (andCargo.lockfor one dev-dependency,async-trait);crates/thrust-contract-tests/tests/compat/mod.rs;scripts/contract.sh,scripts/mutants.sh; and the docs:DEVIATIONS.md(D-040; D-037 and D-039 amended),docs/src/testing/status.md(G-35),TRACEABILITY.md,QUESTIONS.md(Q-0050.9),docs/src/architecture/infra.mdandapp.md,docs/src/testing/techniques/mutation.md.🤖 Generated with Claude Code