Repository navigation
feat(auth): let the operator make an account and set a password - #149
Merged
Merged
Conversation
Nothing could change a password except sign-up and the test-only seed, so a person who forgot theirs had no way back in, and the sign-in screen now says "ask your admin" (D-037). Q-F7 decided the admin makes the user with a temporary password; this builds it. Two routes, POST /internal/operator/users and /internal/operator/users/password, behind a new OperatorAdmin extractor. It is a door of its own and not the test routes, which can wipe every row: its own switch (THRUST_OPERATOR_ROUTES, off unless set), its own header and token (x-operator-token, THRUST_OPERATOR_TOKEN, at least 32 characters or every call is refused, compared in constant time). The test routes' token opens nothing there and the operator's opens no test route. 204 with no body, 400/404/409 as the sign-up rules say, 404 for everything while the switch is off. A reset ends every session of the user, leaves an inactive account inactive and gives an account that has no password one. One audit line per success names the action and the user id, never the password or the email. Core: admin_create_user and admin_set_password, with the checks and the insert of sign-up factored into one private function so the two cannot drift. Port: Database::set_password_hash, in the memory and Postgres adapters. No rate limiter, on purpose (D-038): the Worker's limiter takes three key classes and the one that would fit, `signin:`, is a namespace an anonymous sign-in can write to, so it would let anyone use up the operator's allowance. The token's length is the control. Tests: generative first (core properties and a model sequence with a coverage control, a property over switch x token x header at the router, the generated adapter model with a new SetPassword op), three contract tests on all four targets (EXPECT_MAIN 65 -> 68). Planted bugs, each failing the tests aimed at it: no strength check, sessions left alive, the hash written to every user, the test routes' token accepted (four new rows in scripts/mutants.sh), the switch ignored, a prefix comparison and no minimum token length (the router test), and an UPDATE with no WHERE in the Postgres adapter (the model). scripts/stage2-contract.sh skips the three tests (a deployed Worker has no operator routes). scripts/contract.sh also honours THRUST_MOCK_IDP_PORT like its other port overrides, because pick_port's lsof stalled for minutes under load. Runbook: "Recover a locked-out user" in docs/src/architecture/infra.md, run as written against a local thrust-server. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
#148 rewrote the G-31 row of docs/src/testing/status.md, the row this branch's G-32 row follows, so the two edits conflicted. Resolved as main's G-31 row followed by this branch's G-32 row; nothing else conflicted. The resolved file differs from origin/main by the one G-32 line, and from this branch's previous tip by #148's change to the G-31 row. Refs: #46 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 13, 2026
Main gained #149 (the operator's routes) and #148. The one conflict was crates/thrust-api/src/lib.rs, in two places where #149 added the operator's handlers and routes beside the three this branch deletes: kept both operator routes and the operator block, dropped the slice's sign-in and sign-out routes, and kept this branch's comment on what is left of the identity routes. #149's contract tests sign in through Plane's `/auth/sign-in/`, so nothing there called the deleted routes. Checked on native-memory after the merge: main 68 of 68 (main's 65 and #149's three; this branch changes no count), sweeper 3 of 3, csrfoff 6 of 6, clippy clean on the workspace. Refs: #58 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
A person who forgot their password had no way back in: nothing changes a password except sign-up and the test-only seed, and the sign-in screen now says "ask your admin" (#145, D-037). Q-F7 decided "the admin makes the user with a temporary password" and nothing implemented it. This does (WP2 of the locked-out-recovery plan).
POST /internal/operator/usersmakes an account;POST /internal/operator/users/passwordsets a new password. JSON{email, password}, 204 with no body.OperatorAdmininthrust-api, not the test routes (those can wipe every row): its own switchTHRUST_OPERATOR_ROUTES(off unless set), its own header and token,x-operator-tokenandTHRUST_OPERATOR_TOKEN, at least 32 characters or every call is refused, compared in constant time. The test routes' token opens nothing there; the operator's opens no test route; a session is no way in. 404 for everything while the switch is off.operator set a password: user <id>): the action and the user id, never the password or the email.admin_create_user,admin_set_password; the checks and insert of sign-up are one private function both use. Port:Database::set_password_hash, in the memory and Postgres adapters.docs/src/architecture/infra.md. D-038, the Q-F7 note, G-32.Measured
cargo nextest run --profile ci --workspace3616 passed, 4 skipped; doctests;clippy(native, and the Worker for wasm32) andfmtclean;check-deps,check-acceptance-list,check-web-diff,check-topology.model_sequence against a reference of who has which password and which sessions are alive, with a coverage control, and the pinned edges); the router as the roots mount it (32 cases: a property over switch x configured token x carried header, with its own coverage control); the memory adapter (8, exhaustive); the generatedselfhostedmodel gets aSetPasswordop that reads all three seeded users back, run against a Postgres container.scripts/contract.sh <cell> main, 68 of 68 on all four cells (native-memory,native-pg,worker-memory,worker-cf;EXPECT_MAIN65 to 68, three new tests).scripts/mutants.sh, each run by hand onnative-memory: 1 or 2 operator tests failed, exit 101); the switch ignored, a prefix comparison of the token, no minimum token length (the router test); anUPDATEwith noWHEREin the Postgres adapter (the generated model, 1 of 2 failed, no socket error).thrust-server(19 checks): create, reset, the old password refused, the new one accepted, and neither the token nor either password on curl's command line (a wrapper wrote down its arguments; a control with the token in a normal-His caught) or in the server's log, nor the email. My first version of the "no token on the command line" check could not fail (its trace was never captured); this is the replacement.Not measured
/internal/operator/*to the Worker (scripts/worker-dev.shlists/internal/*inrun_worker_first; the production config is not in this repo).worker-cf e2ecell,deny(no lockfile change),mutantsas a whole (only the four new rows, by hand).mdbook-mermaidis not installed here. The new link isinfra.md#recover-a-locked-out-user.Differs from the plan
signin:, is a namespace an anonymous sign-in can write to, so it would let anyone use up the operator's allowance; a fourth class is an adapter and binding change. The token's minimum length is the control, and the route does no work before the token matches. D-038 says so.scripts/contract.shhonoursTHRUST_MOCK_IDP_PORTlike its other port overrides (pick_port'slsofstalled for minutes under a load average near 800);scripts/stage2-contract.shskips the three tests (a deployed Worker has no operator routes, so its count stays 59).Before you merge
THRUST_OPERATOR_ROUTES=1and aTHRUST_OPERATOR_TOKENsecret. The product hostname is public (Q-0090.3), so until the Access phase the token is the only gate: keep the switch off when nobody is using it.POST /auth/change-password/exists (WP3, next, after this merges).Refs: #46
🤖 Generated with Claude Code