front-door gate: a sign-in finished in an OLDER tab dead-ends on raw JSON (signin_state) — show a page with a way forward #1711

Closed
opened 2026-09-21 20:58:35 +00:00 by ben · 3 comments
Owner

What happened

Whakatōhea Demo, IDIP. Ben had two sign-in tabs (authRequestIDs c248c278… from 20:52Z and 8185229d… from 20:55Z). He typed his recovery phrase into the older one. The bridge VERIFIED it (POST /login/verify 302 → /authorize/callback 302), then the gate answered GET /authz/callback 400 with a bare JSON body:

code "signin_state"  message "the sign-in response did not match this attempt — try again"

The check is right (the gate holds one pending state; a response for a replaced attempt must be refused — internal/controlapi/signin.go:232). The dead end is the defect: the operator reads it as "my twelve words are wrong", there is no link, and "try again" in the same stale tab fails the same way.

Fix

  • On signin_state (and the sibling callback problems) the gate renders a small branded HTML page, not JSON, when the request accepts text/html: "This sign-in was started in another tab. Continue here →" linking to /authz/signin?rd=<original rd or /> — one click restarts a fresh attempt in THIS tab.
  • Better still, make it not happen: key the pending state by the state value (a small set of pending attempts per browser, short TTL, bounded) instead of one slot that the newest attempt overwrites — then either tab completes. Decide in the ticket; the page is needed either way (expired attempts).
  • Seam test: two attempts started, the older completes ⇒ HTML with the restart link (or success, under the multi-slot design); a forged state is still refused.

Sign-in trust surface: the multi-slot option changes gate behaviour — post the choice to Ben before landing (memory: sign-in trust changes go to Ben first). The HTML page alone is a two-way door.

Found on the hand re-founding of Whakatōhea Demo 2026-09-21, build source 5b910ef3.

## What happened Whakatōhea Demo, IDIP. Ben had two sign-in tabs (authRequestIDs `c248c278…` from 20:52Z and `8185229d…` from 20:55Z). He typed his recovery phrase into the older one. The bridge VERIFIED it (`POST /login/verify` 302 → `/authorize/callback` 302), then the gate answered `GET /authz/callback` **400** with a bare JSON body: ``` code "signin_state" message "the sign-in response did not match this attempt — try again" ``` The check is right (the gate holds one pending state; a response for a replaced attempt must be refused — `internal/controlapi/signin.go:232`). The dead end is the defect: the operator reads it as "my twelve words are wrong", there is no link, and "try again" in the same stale tab fails the same way. ## Fix - On `signin_state` (and the sibling callback problems) the gate renders a small branded HTML page, not JSON, when the request accepts `text/html`: "This sign-in was started in another tab. Continue here →" linking to `/authz/signin?rd=<original rd or />` — one click restarts a fresh attempt in THIS tab. - Better still, make it not happen: key the pending state by the `state` value (a small set of pending attempts per browser, short TTL, bounded) instead of one slot that the newest attempt overwrites — then either tab completes. Decide in the ticket; the page is needed either way (expired attempts). - Seam test: two attempts started, the older completes ⇒ HTML with the restart link (or success, under the multi-slot design); a forged state is still refused. Sign-in trust surface: the multi-slot option changes gate behaviour — post the choice to Ben before landing (memory: sign-in trust changes go to Ben first). The HTML page alone is a two-way door. Found on the hand re-founding of Whakatōhea Demo 2026-09-21, build source `5b910ef3`.

swarm-claim host=matou-dev-server-01 run=29518
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=29518 (automated multi-host claim — lowest live claim id works this ticket)

Ruled by agent under ADR 0174 — veto anytime.

Ruling: This iteration ships the branded HTML page (the ticket's first option, which the ticket itself calls "a two-way door" and "needed either way"). It does NOT ship the multi-slot pending-state redesign (the second, "better still" option) — that one changes gate behaviour on the sign-in trust surface, and both the ticket and standing memory say "sign-in trust changes go to Ben first". It is deferred, not adopted.

Why this is a two-way door: the page only replaces a raw-JSON 400 dead-end (signin_state and its sibling callback problems) with a small branded HTML page carrying a "Continue here →" restart link, when the client accepts text/html. Non-browser clients (probes, the seam tests) keep the byte-identical JSON Problem. It widens no auth, mints no session on a refused callback, and is revertible by a single commit.

What proves it: a seam test in internal/controlapi/signin_test.go — two attempts started, the older completes ⇒ HTML (Content-Type text/html) carrying the /authz/signin?rd=… restart link; a forged state is still refused (400, no session minted); a non-HTML client still gets JSON.

Deferred to Ben (multi-slot): keying pending state by the state value so either tab completes is a gate-behaviour change on the sign-in trust surface — left for Ben's call. The page closes the reported dead end without it (it is also the surface expired attempts need regardless).

**Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** This iteration ships the **branded HTML page** (the ticket's first option, which the ticket itself calls "a two-way door" and "needed either way"). It does NOT ship the **multi-slot pending-state redesign** (the second, "better still" option) — that one changes gate behaviour on the sign-in trust surface, and both the ticket and standing memory say "sign-in trust changes go to Ben first". It is deferred, not adopted. **Why this is a two-way door:** the page only replaces a raw-JSON 400 dead-end (`signin_state` and its sibling callback problems) with a small branded HTML page carrying a "Continue here →" restart link, *when the client accepts `text/html`*. Non-browser clients (probes, the seam tests) keep the byte-identical JSON Problem. It widens no auth, mints no session on a refused callback, and is revertible by a single commit. **What proves it:** a seam test in `internal/controlapi/signin_test.go` — two attempts started, the older completes ⇒ HTML (Content-Type `text/html`) carrying the `/authz/signin?rd=…` restart link; a forged state is still refused (400, no session minted); a non-HTML client still gets JSON. **Deferred to Ben (multi-slot):** keying pending state by the `state` value so either tab completes is a gate-behaviour change on the sign-in trust surface — left for Ben's call. The page closes the reported dead end without it (it is also the surface expired attempts need regardless).

close-report for #1711 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1711,
  "status": "success",
  "commits": [
    "92dc14e8"
  ],
  "changed_files": [
    "internal/controlapi/signin_restart.go",
    "internal/controlapi/signin.go",
    "internal/controlapi/signin_test.go",
    "control-plane/cmd/control-plane/main.go",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "go test ./internal/controlapi/",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/controlapi/... ./control-plane/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "On signin_state (and the sibling callback problems) the gate renders a small branded HTML page, not JSON, when the request accepts text/html": "signin_restart.go writeSigninCallbackProblem negotiates on wantsHTML(r): a browser gets renderSigninRestart (branded via SigninConfig.Brand / refusalStyle+refusalLogo); signinCallback routes signin_state, signin_expired, signin_refused, signin_no_code, signin_exchange through it. Test TestAuthzSignin_OlderTabCompletion_RendersBrandedRestartPage asserts Content-Type text/html + community name.",
    "The page says 'This sign-in was started in another tab. Continue here →' linking to /authz/signin?rd=<original rd or /> — one click restarts a fresh attempt in THIS tab": "signinProblemCopy(signin_state) => 'This sign-in was started in another tab.'; renderSigninRestart emits a single door data-action=restart-signin href=/authz/signin?rd=<flow.RD same-apex-validated, apex root fallback>. Test asserts href=\"/authz/signin and 'another tab' copy.",
    "Seam test: two attempts started, the older completes => HTML with the restart link": "TestAuthzSignin_OlderTabCompletion_RendersBrandedRestartPage — two /authz/signin attempts (distinct states), the older state completes => 400 text/html carrying the /authz/signin restart link, no raw JSON message.",
    "a forged state is still refused": "TestAuthzSignin_ForgedStateFromBrowser_StillRefused — a browser forged-state callback => 400, no session cookie minted; TestAuthzSignin_NonBrowserCallbackRefusal_StaysJSON keeps the machine-stable JSON Problem for non-browsers.",
    "multi-slot option (changes gate behaviour) posted to Ben before landing": "Not landed — ruled deferred to Ben on the issue (ADR 0174 ruling comment) as a sign-in trust-surface change; only the two-way-door HTML page shipped."
  },
  "summary": "The front-door gate answers a browser's failed /authz/callback with a branded restart page (one 'Continue here →' door to /authz/signin) instead of a raw-JSON dead end, while non-browsers keep the JSON Problem and a forged/replaced attempt still mints no session.",
  "blockers": []
}
**close-report** for #1711 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1711, "status": "success", "commits": [ "92dc14e8" ], "changed_files": [ "internal/controlapi/signin_restart.go", "internal/controlapi/signin.go", "internal/controlapi/signin_test.go", "control-plane/cmd/control-plane/main.go", "STATUS.md" ], "tests": [ { "command": "go test ./internal/controlapi/", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/controlapi/... ./control-plane/...", "exit_code": 0 } ], "criteria": { "On signin_state (and the sibling callback problems) the gate renders a small branded HTML page, not JSON, when the request accepts text/html": "signin_restart.go writeSigninCallbackProblem negotiates on wantsHTML(r): a browser gets renderSigninRestart (branded via SigninConfig.Brand / refusalStyle+refusalLogo); signinCallback routes signin_state, signin_expired, signin_refused, signin_no_code, signin_exchange through it. Test TestAuthzSignin_OlderTabCompletion_RendersBrandedRestartPage asserts Content-Type text/html + community name.", "The page says 'This sign-in was started in another tab. Continue here →' linking to /authz/signin?rd=<original rd or /> — one click restarts a fresh attempt in THIS tab": "signinProblemCopy(signin_state) => 'This sign-in was started in another tab.'; renderSigninRestart emits a single door data-action=restart-signin href=/authz/signin?rd=<flow.RD same-apex-validated, apex root fallback>. Test asserts href=\"/authz/signin and 'another tab' copy.", "Seam test: two attempts started, the older completes => HTML with the restart link": "TestAuthzSignin_OlderTabCompletion_RendersBrandedRestartPage — two /authz/signin attempts (distinct states), the older state completes => 400 text/html carrying the /authz/signin restart link, no raw JSON message.", "a forged state is still refused": "TestAuthzSignin_ForgedStateFromBrowser_StillRefused — a browser forged-state callback => 400, no session cookie minted; TestAuthzSignin_NonBrowserCallbackRefusal_StaysJSON keeps the machine-stable JSON Problem for non-browsers.", "multi-slot option (changes gate behaviour) posted to Ben before landing": "Not landed — ruled deferred to Ben on the issue (ADR 0174 ruling comment) as a sign-in trust-surface change; only the two-way-door HTML page shipped." }, "summary": "The front-door gate answers a browser's failed /authz/callback with a branded restart page (one 'Continue here →' door to /authz/signin) instead of a raw-JSON dead end, while non-browsers keep the JSON Problem and a forged/replaced attempt still mints no session.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1711
No description provided.