bug: the app-door "new code" keeps a sign-in the gate already abandoned (10 min flowTTL): the member scans and approves, then lands on "This sign-in attempt has expired" #1907

Closed
opened 2026-09-27 03:13:48 +00:00 by ben · 2 comments
Owner

Symptom (whakatohea-demo, 2026-09-25)

A member left the app-door QR page open, and the first code expired (2 min). They pressed for a new code, scanned it, approved it in the app, and landed on the control plane's "This sign-in attempt has expired." restart page. "Continue here" then worked, because the bridge's silent hop completed.

Timeline (caddy):

time (Z) event
20:42:26 /authz/signin?rd=/ 302. The gate seals its flow cookie (flowTTL = 10 min, internal/controlapi/signin.go:64)
20:42:30 /login/app/challenge?authRequestID=6590af1b…, first code Uzuwda… (appChallengeTTL = 2 min, internal/idp/appdoor.go:65)
20:52:26 The gate's flow cookie expires
20:52:54 "New code": /login/app/challenge?authRequestID=6590af1b…, same auth request, new code 4JDzeS…
20:53:08 Presentation verified, /authorize/callback 302 → /authz/callback 400 signin_expired (no flow cookie)

Cause

The bridge's auth request has no lifetime. handleChallenge will mint a fresh code for an auth request of any age, but the relying party behind it (the gate, 10 min) has already given up. So the page offers a working-looking QR for a sign-in that is already dead, and the member only finds out after scanning and approving in the app.

Fix

A new code never outlives the sign-in it serves:

  • The bridge gives an auth request a lifetime no longer than the gate's flowTTL (10 min; one shared constant or a pinned equality test, so the two cannot drift).
  • When a code is asked for past that lifetime, the page does not show a QR. It sends the browser back to restart at the relying party. For gate-oidc that is /authz/signin?rd=<the validated login hint>; for another client, its own start, or a plain "start again" with that client's landing. The member gets a fresh flow on both sides with one click and never scans a dead code.
  • The same guard covers a code minted just before the lifetime ends: a code's own expiry is capped at the auth request's.

Acceptance criteria

  • An app-door QR page left open past 10 min, then asked for a new code, restarts the sign-in (fresh /authz/signin flow) instead of issuing a code. Scanning the new code then signs the member in with no "expired" page.
  • No code is ever issued with an expiry later than its auth request's.
  • The bridge's auth-request lifetime and the gate's flowTTL are the same value (pinned by a test).
  • The twelve-words door has the same guard (it sits on the same auth request).
  • The restart page stays on the community's apex (the same-apex rd validation as signinRestartURL).

References

  • Found on the live proof of #1887. DDR 0246 decision 6 (code life), internal/controlapi/signin_restart.go (the expired page; its branding is #1892)

🤖 Generated with Claude Code

## Symptom (whakatohea-demo, 2026-09-25) A member left the app-door QR page open, and the first code expired (2 min). They pressed for a new code, scanned it, approved it in the app, and landed on the control plane's **"This sign-in attempt has expired."** restart page. "Continue here" then worked, because the bridge's silent hop completed. Timeline (caddy): | time (Z) | event | |---|---| | 20:42:26 | `/authz/signin?rd=/` 302. The gate seals its flow cookie (`flowTTL` = **10 min**, `internal/controlapi/signin.go:64`) | | 20:42:30 | `/login/app/challenge?authRequestID=6590af1b…`, first code `Uzuwda…` (`appChallengeTTL` = 2 min, `internal/idp/appdoor.go:65`) | | 20:52:26 | The gate's flow cookie expires | | 20:52:54 | "New code": `/login/app/challenge?authRequestID=6590af1b…`, **same auth request**, new code `4JDzeS…` | | 20:53:08 | Presentation verified, `/authorize/callback` 302 → `/authz/callback` **400 `signin_expired`** (no flow cookie) | ## Cause The bridge's auth request has **no lifetime**. `handleChallenge` will mint a fresh code for an auth request of any age, but the relying party behind it (the gate, 10 min) has already given up. So the page offers a working-looking QR for a sign-in that is already dead, and the member only finds out **after** scanning and approving in the app. ## Fix A new code never outlives the sign-in it serves: - The bridge gives an auth request a lifetime no longer than the gate's `flowTTL` (10 min; one shared constant or a pinned equality test, so the two cannot drift). - When a code is asked for past that lifetime, the page does not show a QR. It sends the browser back to **restart at the relying party**. For `gate-oidc` that is `/authz/signin?rd=<the validated login hint>`; for another client, its own start, or a plain "start again" with that client's landing. The member gets a fresh flow on both sides with one click and never scans a dead code. - The same guard covers a code minted just before the lifetime ends: a code's own expiry is capped at the auth request's. ## Acceptance criteria - [ ] An app-door QR page left open past 10 min, then asked for a new code, restarts the sign-in (fresh `/authz/signin` flow) instead of issuing a code. Scanning the new code then signs the member in with no "expired" page. - [ ] No code is ever issued with an expiry later than its auth request's. - [ ] The bridge's auth-request lifetime and the gate's `flowTTL` are the same value (pinned by a test). - [ ] The twelve-words door has the same guard (it sits on the same auth request). - [ ] The restart page stays on the community's apex (the same-apex `rd` validation as `signinRestartURL`). ## References - Found on the live proof of #1887. DDR 0246 decision 6 (code life), `internal/controlapi/signin_restart.go` (the expired page; its branding is #1892) 🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

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

close-report for #1907 — status success

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

envelope
{
  "issue": 1907,
  "status": "success",
  "commits": [
    "0e525c3f"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/controlapi/signin_internal_test.go",
    "internal/idp/appdoor.go",
    "internal/idp/appdoor_seam_test.go",
    "internal/idp/appdoorpage.go",
    "internal/idp/provider.go",
    "internal/idp/requests.go",
    "internal/idp/signin.go",
    "internal/idp/storage.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci --command go test ./internal/idp/... ./internal/controlapi/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go vet ./internal/idp/... ./internal/controlapi/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command gofmt -l internal/idp internal/controlapi",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "An app-door QR page left open past 10 min, then asked for a new code, restarts the sign-in (fresh /authz/signin flow) instead of issuing a code": "internal/idp/appdoor.go handleChallenge returns a Restart descriptor (no code) when req.expired(now); the WS-S1 page (appdoorpage.go) navigates to d.restart. Proven by TestSeam_AppDoor_PastLifetimeRestartsInsteadOfIssuingACode (restart path=/authz/signin, no ChallengeID).",
    "No code is ever issued with an expiry later than its auth request's": "capExpiry() in appdoor.go caps ExpiresAt at creationDate+authRequestTTL. Proven by TestSeam_AppDoor_CodeExpiryCappedAtAuthRequest.",
    "The bridge's auth-request lifetime and the gate's flowTTL are the same value (pinned by a test)": "idp.authRequestTTL = 10m (requests.go) and controlapi.flowTTL = 10m; TestAuthRequestTTL_Pinned (idp) + TestFlowTTL_Pinned (controlapi) both pin the literal, per the gateClientID/GateOIDCClientID precedent.",
    "The twelve-words door has the same guard (it sits on the same auth request)": "signin.go handleVerify 302s to signinRestartURL when req.expired(now), before keriVerify. Proven by TestSeam_WordsDoor_PastLifetimeRestartsVerify.",
    "The restart page stays on the community's apex (the same-apex rd validation as signinRestartURL)": "store.signinRestartURL builds https://<apex>/authz/signin?rd=<sameApexRedirect(returnDest)>; sameApexRedirect mirrors controlapi's. Proven by TestSeam_AppDoor_RestartCarriesTheValidatedLoginHint (rd == the validated hint) and the apex-host assertions in the restart tests."
  },
  "summary": "The bridge caps an auth request at the gate's flowTTL (10 min); past it the app door and words door restart the sign-in instead of minting a code or verifying a presentation onto a dead flow, and a code's expiry is capped at its request's.",
  "blockers": []
}
**close-report** for #1907 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1907, "status": "success", "commits": [ "0e525c3f" ], "changed_files": [ "STATUS.md", "internal/controlapi/signin_internal_test.go", "internal/idp/appdoor.go", "internal/idp/appdoor_seam_test.go", "internal/idp/appdoorpage.go", "internal/idp/provider.go", "internal/idp/requests.go", "internal/idp/signin.go", "internal/idp/storage.go" ], "tests": [ { "command": "nix develop .#go-ci --command go test ./internal/idp/... ./internal/controlapi/...", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go vet ./internal/idp/... ./internal/controlapi/...", "exit_code": 0 }, { "command": "nix develop .#go-ci --command gofmt -l internal/idp internal/controlapi", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go build ./...", "exit_code": 0 } ], "criteria": { "An app-door QR page left open past 10 min, then asked for a new code, restarts the sign-in (fresh /authz/signin flow) instead of issuing a code": "internal/idp/appdoor.go handleChallenge returns a Restart descriptor (no code) when req.expired(now); the WS-S1 page (appdoorpage.go) navigates to d.restart. Proven by TestSeam_AppDoor_PastLifetimeRestartsInsteadOfIssuingACode (restart path=/authz/signin, no ChallengeID).", "No code is ever issued with an expiry later than its auth request's": "capExpiry() in appdoor.go caps ExpiresAt at creationDate+authRequestTTL. Proven by TestSeam_AppDoor_CodeExpiryCappedAtAuthRequest.", "The bridge's auth-request lifetime and the gate's flowTTL are the same value (pinned by a test)": "idp.authRequestTTL = 10m (requests.go) and controlapi.flowTTL = 10m; TestAuthRequestTTL_Pinned (idp) + TestFlowTTL_Pinned (controlapi) both pin the literal, per the gateClientID/GateOIDCClientID precedent.", "The twelve-words door has the same guard (it sits on the same auth request)": "signin.go handleVerify 302s to signinRestartURL when req.expired(now), before keriVerify. Proven by TestSeam_WordsDoor_PastLifetimeRestartsVerify.", "The restart page stays on the community's apex (the same-apex rd validation as signinRestartURL)": "store.signinRestartURL builds https://<apex>/authz/signin?rd=<sameApexRedirect(returnDest)>; sameApexRedirect mirrors controlapi's. Proven by TestSeam_AppDoor_RestartCarriesTheValidatedLoginHint (rd == the validated hint) and the apex-host assertions in the restart tests." }, "summary": "The bridge caps an auth request at the gate's flowTTL (10 min); past it the app door and words door restart the sign-in instead of minting a code or verifying a presentation onto a dead flow, and a code's expiry is capped at its request's.", "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#1907
No description provided.