Skip to content
SprecherEast
Issue 1312

documentation: Decision record for passkey sign-in on our own layer

Back to our plan
Done
documentationauthpriority: lowready

Type

documentation

Problem

Before any passkey code is written, the design needs to be written down and reviewed once, so each later step follows it instead of re-deciding. The library choice is settled on #313; how we use it isn't recorded yet.

Proposed fix

Write the next free decision record in docs/architecture/decisions/ (0020 is free on main today; PR #505 still uses 0016, which is taken, so take whichever is free at merge) and add it to the README there. Status Accepted once reviewed. It decides, with sources:

  • Library and boundary. @simplewebauthn/server on the server, @simplewebauthn/browser in the browser. Every call goes through one adapter in data/; the domain never imports it. Cryptography, attestation and assertion checks stay in the library.
  • Relying party. The ID is the host of the configured site address, and the expected origin is that address exactly, never the request's Host (the same rule as email links). This gives the live domain in production, localhost in development, and a preview's own address in a preview, so a passkey never crosses between them.
  • Kind of passkey. Discoverable credentials, user verification required, no attestation. Sign-in offers a button and, where the browser supports it, the passkey in the email field's autofill; email and password stay on the same page.
  • Challenges. Random, from the library; stored on the server with a short expiry; tied to the browser by a signed cookie (reusing domain/signedValue.ts with its own purpose key); taken once by a conditional delete, so a replay or two tries at once fail. Expired rows are removed by the existing retention queue. Why not Payload's key-value store: no expiry and no atomic take.
  • Stored passkey. Credential ID (unique), public key, signature counter, transports, device type and backed-up flag, a label, when added and when last used. No biometric data ever reaches us. Server-only fields; a resident sees their own list through the module, never over REST.
  • Who may do what. Only the signed-in account adds or removes its own passkeys; the account always comes from the session. Adding needs a recent sign-in: the session must be only a few minutes old (a named constant), whether it began with a password or with Google, so accounts without a password are not forced to make one; an older session is asked to sign in again first. A cap on passkeys per account, as a named constant. Removing the last one is always allowed.
  • Sign-in. Locked (#140), unverified and agent (#336) accounts are refused, as in record 0016. A failed check never says whether an account exists. It starts Payload's own session through the code PR #505 adds, honoring "keep me signed in". It is a same-site request, so the continue page 0016 needs for providers isn't needed here.
  • Limits. Per-connection and site-wide limits on asking for a challenge, reusing guardPublicRequest and SlidingWindowCounter.
  • Recovery. Email and password, and forgot password, are never turned off by passkeys.
  • Switch. One server setting turns the feature on; off, nothing shows and the actions refuse.
  • Risks. One npm maintainer behind the library; how the adapter contains a swap.

Existing work compared

  • Searched: open and closed issues for passkey, WebAuthn, security key, lost device, recovery, lockout and SimpleWebAuthn; docs/architecture/decisions/; the accounts note.
  • Native: Payload 3.91 has no passkeys; Next.js ships no authentication. Payload's key-value store (payload.kv) was checked for challenges: get, set and delete only.
  • Official plugins: none (no @payloadcms/* passkey package).
  • Community plugins (numbers on #313, 2026-11-19): payload-passkey (418 weekly downloads, one maintainer, published 2026-08) fails the bar; payload-auth-plugin (about 4,500 weekly, last release 2026-05) brings its own password fields (#261); payload-authjs (about 2,700 weekly) has passkeys only in an unmerged pull request; better-auth with its passkey plugin is a second auth system with its own sessions.
  • Our code: chosen on #313: a thin layer on @simplewebauthn (about 12 million weekly downloads, latest release 2026-11-06, no advisory on it).
  • Record 0016 (PR #505) is the model for shape and session; this record references it and doesn't repeat it. No existing record covers passkeys, so this is new work.

Acceptance criteria

  • Not done: The record covers every point in the proposed fix, each with its reason and a source.
  • Not done: It names what must not change: Payload's login, /admin, the lockout, sign-out, the Secure cookie, email verification and forgot password.
  • Not done: The decisions README lists it, and its number is free on main at merge.
  • Not done: Behavior change: none is declared with its reason.
  • Not done: Reviewed at the top scrutiny level before merge.

Files likely touched

  • docs/architecture/decisions/00NN-passkey-sign-in.md (new)
  • docs/architecture/decisions/README.md

Must not touch

  • src/**, package.json, package-lock.json
  • PR #505's files and its record

Open questions

  • None. The owner decided (2026-11-19, on #313): a recent sign-in within a few minutes, as large providers do, with no forced password.

Area

auth

Priority

low


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab