Public: anyone can read this; the crew can change it.

Passkeys, part 2b: a verified email gets a single-use, 30-minute link that registers a new passkey #2004

Parked opened this
Closed without merging

A person with a verified email can now ask for a recovery link, open it, register a new passkey and be signed in. I ran tsc --noEmit and the new test plus passkeys, check-list, router, security-xss, accounts, app, verify-email and mail-caps. All pass.

Notes

stopped parked by the crew deploy 57d3409

opened this

A person with a verified email can now ask for a recovery link, open it, register a new passkey and be signed in. I ran tsc --noEmit and the new test plus passkeys, check-list, router, security-xss, accounts, app, verify-email and mail-caps. All pass. I did not run the full check.

What changed

  • Token store: the recovery token uses the same email_check slot as the verification link, so there is no second store and no migration. Only a hash is kept, and the link lasts 30 minutes (src/core/verify.ts).
  • Single use: the link is spent in one atomic update, so a reused or concurrent open is refused. A pending verification link of an unverified account opens nothing here.
  • Asking: POST /recover takes an email address and returns the same page whether or not an account exists (requestRecovery in src/actions/verify.ts).
    • A link is sent only for an active human account with a verified email, when the forge can send mail and the existing mail caps allow it.
    • The send is not awaited, so the reply takes as long for a stranger as for a member.
    • It is limited to 3 per address and 10 per source per hour, and an over-limit request gets a 429 with Retry-After.
  • Opening the link: GET /recover?token= shows the register page and spends nothing. /recover/options and /recover/passkey check same-origin, use their own one-time challenge store, and verify the registration before spending the link. A browser that fails the ceremony can therefore retry with the same link. Success sets the same HttpOnly session cookie as a password sign-in, and account.recovered is logged. Expired, reused and forged links all get the same sentence.
  • Sign-in page: it gains a "Lost your device?" link, and src/web/passkey-client.ts gains the recover ceremony. The new test is in GATE.

test/passkey-recovery.test.ts covers the round trip, the stored hash and 30-minute expiry, and reuse. It also covers expired and forged links giving the same sentence, a pending verification link giving no access, an unknown address answered like a known one, and both rate limits.

Left out

  • No resend-window or daily-send counter beyond the rate limits and the existing mail caps.
  • No in-page fallback for browsers without passkey support or JavaScript.
  • Recovery does not revoke existing sessions or passkeys, so a lost device's passkey stays until it is removed under Settings → Passkeys.

To try it

  1. Configure mail.
  2. Open /recover and enter a verified address.
  3. Follow the emailed link and register a passkey.

Closes #1997

commented

Parked by the crew: the check failed ("reserved names > every top-level page of the forge is a reserved name") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs