Skip to content

feat(web): the auth client posts JSON, and POST /auth/sign-out/ answers it (X06) - #130

Merged
aRustyDev merged 5 commits into
mainfrom
feat/web-auth-client-json
Nov 12, 2026
Merged

aRustyDev merged 5 commits into
mainfrom
feat/web-auth-client-json

Conversation

@aRustyDev

@aRustyDev aRustyDev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Part of #44 (the auth-client JSON change, and the sign-out it needs). Does not close it: serving the build and the wrangler dev journey are the next PR, then the closing comment.

What changes

Server (thrust-compat-plane). POST /auth/sign-out/ (X06; the sidebar's user menu calls it; the 48-row table does not list it, so it joins the acceptance list, now 54 rows) answers 200 {"redirect_path": "/"}, ends the session the request names (cookie or bearer token), and clears both cookies on every answer. An API key ends nothing. While CSRF enforcement is on, a cookie request needs the token in X-CSRFTOKEN, and without it the answer is 403 and nothing is ended or cleared. thrust_api::cleared_cookies is now pub so the compat route spells the cookies the way the internal API does.

Client (web/, two files of the pin, Q-R2).

  • components/account/auth-forms/password.tsx: the native form.submit() becomes authService.passwordAuth(...), a JSON POST. On success it navigates to redirect_path; on a refusal it navigates to the same /?error_code=…&error_message=…&email=… the sign-in page already reads, so nothing downstream changes.
  • services/auth.service.ts: signOut fetches the CSRF token, posts JSON with the header, and navigates to redirect_path.
  • web/ALLOWED-CHANGES lists exactly those two files.

Left at the pin on purpose: unique-code.tsx, reset-password.tsx, the OAuth hook and packages/services/src/auth/auth.service.ts. Their server routes (magic code, password reset, social login) are not built, so changing the client would only move the failure. This app's sign-out does not use the @plane/services copy.

Record. X06 is recorded from the pin (a live session, the read after it with the old cookie, no session) and replayed through the D-022 projection. D-036 is new and pending your confirmation; D-022 is marked confirmed (2026-11-11). G-29 (the sign-out; main took G-28 for the acceptance list), PLAN.md and architecture/app.md are updated. After the first push, main moved (#127, #129): I merged it, took EXPECT_MAIN to 62, added X06 to acceptance.csv through gen-acceptance.py (the list is now held to the fixtures and the recorder, so the fixture needed a row), and gave tests/sign_out.rs the crate's test-code lint allowance.

D-036 in one paragraph (details in DEVIATIONS.md)

The pin answers 302 to the origin, deletes only session-id, leaves csrftoken alone, sets no cookie when there is no session, records last_logout_*, and answers a missing or wrong CSRF token with a 200 HTML page ("CSRF Verification Failed"). Thrust answers JSON, clears both its cookies every time, answers 403 for the token, and records no last logout. The cookie and CSRF facts were read from the pin's raw exchanges and a probe; the fixture format holds JSON bodies only, so the CSRF page is not recorded.

Verified

  • cargo fmt --check, clippy --workspace --all-targets -D warnings and the wasm32 Worker clippy: clean.
  • cargo nextest run --profile ci --workspace: 3539 passed after merging main (it includes the acceptance-list guard and the X06 row); cargo test --doc --workspace: passed; scripts/check-acceptance-list.sh, check-web-diff.sh, check-plane-500.sh, check-deps.sh and the recorder self-test: ok.
  • Contract suite: before the merge, 61 of 61 on native-memory, native-pg, worker-memory and worker-cf. After the merge, native-memory only: 62 passed, 62 expected (EXPECT_MAIN 60 on main, plus the two new tests). The other three cells have not been re-run since the merge; CI runs them.
  • Planted bugs, each caught: a sign-out that revokes nothing, one that clears no cookie, one that ends every session of the account (hermetic); the cookies stripped, and a sign-out that answers correctly but ends nothing (parity controls); the CSRF failure ignored (contract).
  • scripts/check-web-diff.sh: 3869 files, 2 differ, both allowed. pnpm -C web typecheck and oxfmt clean, and the build contains the new code.
  • A real browser, by hand: the built app in headless Chromium against the native server. Sign-up through the form posts JSON and lands on onboarding. A wrong password is a 400 and the app's own "Authentication failed" banner. A good sign-in works. The sign-out menu fetches the token, posts JSON with the header, and returns to the sign-in page with both cookies gone and GET /api/users/me/ answering 401. The __Host- Secure cookies work over http://127.0.0.1.

Not verified

  • The browser pass is not in CI. It was a scratch script outside the repo; the Playwright journey of the next PR is meant to replace it.
  • X06 was recorded once, on one oracle stack, not compared across two.
  • The pin's CSRF page and cookie behaviour are in D-036 but not in a fixture.
  • CI on this PR has not run yet; I will read the set of reported checks, not just the verdict.

Needs your decision

D-036 (above). D-023, D-025 to D-029 and D-035 are still pending from earlier.

🤖 Generated with Claude Code

aRustyDev and others added 5 commits November 11, 2026 19:40
…(X06)

The stock app's sign-out menu posts a form to /auth/sign-out/ and follows the pin's
302 to the origin. Thrust's copy of the client posts JSON (D-022, confirmed), so the
route is the one D-022's answer for it: 200 `{"redirect_path": "/"}`, the session the
request holds ended, and both cookies cleared (`__Host-thrust_session` and
`__Host-thrust_csrf`, empty and `Max-Age=0`, with the attributes they are set with).
The inventory does not list the route; it is X06, as the static route is X05.

The pin's view catches every failure and answers the same redirect, a request with no
session included, so this answers one way whatever the request holds: no credential, an
unknown session cookie, a live session, one that has ended. An API key ends nothing
(a leaked key must not end the user's sessions, as the shared router's sign_out says),
and a cookie request needs the CSRF token where the deployment enforces it (403, and
nothing ended or cleared). It ends the one session it names, not the account's others.

thrust_api::cleared_cookies is public, as set_cookie and add_cookies are, so that the
compat routes spell the cookies as the shared router does.

Tests: a matrix over what a request can hold (none, an unknown cookie, a live session,
an ended one), each required to give the same answer with both cookies cleared, the
session it names ended and another account's untouched; an account signed in twice
keeps the other session. Three bugs planted one at a time each turn them red: the
session not revoked, the cookies not cleared, and every session of the account ended.
The contract suite, on all four targets, runs the cookie journey (the CSRF token's
refusal first, which ends nothing, then the sign-out, then the same again for an ended
session), and a bearer session, an API key and no credential at all; with the CSRF
failure ignored the first goes red and the guard reports 60 of 61. EXPECT_MAIN is 61.

Not here: the oracle's fixture and parity row (X06), the client change and D-036.

Refs: plane-byd.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The password form submits a native form post that the pin answers with a 302, and the
sign-out menu builds a form and submits it. Thrust answers JSON (D-022, confirmed;
sign-out is D-036), so the client now posts JSON and goes where the 302 would have gone.
Both files are the auth client, which Q-R2 allows to change.

apps/web/services/auth.service.ts: `passwordAuth(mode, data)` is new, a JSON post to
/auth/sign-in/ or /auth/sign-up/ that resolves with `{ redirect_path }` and rejects with
the server's `{ error_code, error_message, email }`. `signOut` posts JSON, with the CSRF
token it already fetched as the X-CSRFTOKEN header the double-submit check reads, and
navigates to the `redirect_path` it is answered.

apps/web/components/account/auth-forms/password.tsx: where the form was submitted
(`formRef.current.submit()`) it calls `passwordAuth` with the email, the password and the
`next_path` it was given. A success navigates to `redirect_path`. A refusal navigates to
`/?next_path=..&error_code=..&error_message=..&email=..`, which is what the pin's 302
would have carried and what `auth-root.tsx` already reads (`error_code`, `email`), so
nothing downstream of the form changes. An answer that is not the server's (a network
failure) leaves the form as it was and enabled again.

Not changed, and still the pin's: unique-code.tsx, reset-password.tsx and the OAuth hook,
whose server routes are not built, so the form post they make has no JSON answer to read;
and packages/services/src/auth/auth.service.ts, the same form-post sign-out in a service
this app does not use (`store/user` imports `@/services/auth.service`). web/ALLOWED-CHANGES
lists the two files that change and says so.

Checked here: `pnpm check:types` (react-router typegen, tsc --noEmit) has no errors,
oxfmt --check is clean on both files, and oxlint finds only the two autoFocus warnings of
the pin's own lines. The Q-R2 gate and the build run in CI's `web` job. Not run in a
browser yet; the journey of the next stage does.

Refs: plane-byd.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…checks

The pin's POST /auth/sign-out/ is recorded as the last fixture of the journey: a live
session (302 to the origin), the read after it that sends the session cookie the account
held before (401), and a request with no session (302). The recorder checks first that
the hand-sent cookie reads 200, so the 401 can only be the end of the session, and it now
keeps a response header sent more than once (Set-Cookie) as a list in the raw exchange.
No normaliser rule was needed; the 66 older fixtures are byte-identical.

The replay projects the 302 onto Thrust's JSON as it does the sign-in's, and checks the
two cookies itself, because the fixtures drop Set-Cookie. Two controls show the check can
fail: a router that strips the sign-out's cookies, and one that answers a sign-out as it
should and ends nothing (the read after it must then diverge).

Refs: plane-byd.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…for both

D-036 records the four ways POST /auth/sign-out/ differs from the pin (JSON for the 302,
both cookies cleared on every answer, a 403 for a missing CSRF token where the pin renders
a 200 page, no last-logout fields), with the cookie and CSRF facts read from the pin.
It is pending owner confirmation. D-022 is marked confirmed by the owner on 2026-11-11.
G-28 says what is recorded, what is read from the source, and what was only checked by
hand in a real browser. PLAN.md and architecture/app.md no longer list the auth-client
change as left.

Refs: plane-byd.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
main moved by #127 and #129. Three conflicts, and three things the merge made necessary:

- scripts/contract.sh: EXPECT_MAIN is 62 (main's 60, and the two sign-out contract tests).
- status.md: main took G-28 (the acceptance list); the sign-out's row is G-29. PLAN.md keeps
  main's text and this branch's #44 sentence.
- X06 joins the acceptance list (tools/compat-record/gen-acceptance.py EXTRA, regenerated
  acceptance.csv: 54 rows), since the list is now held to the fixtures and the recorder.
  POST /auth/sign-out/ is a route of the pinned inventory, which the generator checks.
- tests/sign_out.rs carries the crate's test-code lint allowance, now that the panic lints
  apply to thrust-compat-plane (#129).

Refs: plane-byd.3
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 4ff6282 into main Nov 12, 2026
34 checks passed
@aRustyDev
aRustyDev deleted the feat/web-auth-client-json branch November 12, 2026 01:17
aRustyDev added a commit that referenced this pull request Nov 12, 2026
`EXPECT_MAIN` is 65: main's 62 (the compat tests of #124, #127 and #130) and this
branch's three. The deployed-Worker count of `stage2-contract.sh` is 59 (the six
`oidc_` tests are skipped there), and the docs say so. The one conflict was that
line of `scripts/contract.sh`, as at the last merge.

Measured on native-memory after the merge: the main pass 65 of 65, the sweeper
pass 3 of 3.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant