Issue 1315
feat: Sign in with a passkey
Back to our planDone
enhancementfrontendauthpriority: low
Problem
A resident who added a passkey still has to type their email and password to sign in.
Proposed fix
- Use case
use-cases/signInWithPasskey.ts: ask for sign-in options (limited per connection and site-wide), then verify the browser's answer: the challenge is taken once, the credential is found by its ID, the library checks the signature, origin, relying party ID and counter, and the account must be neither locked (#140), nor unverified, nor an agent (#336). Then update the counter and last used, and start Payload's own session. - Shared session code: move
startSessionForout ofdata/socialAccounts.tsintodata/session.ts, since this is its second use (guard rail 1), with its test. Honor "keep me signed in" throughdata/rememberedSession.ts, as password sign-in does. - Screen: on
/login, a "Sign in with a passkey" button beside the existing ways in, and the passkey offered in the email field's autofill where the browser supports it. Email and password stay. Shown only when the switch is on and the browser supports passkeys. - Messages (catalog, brand voice), drafts:
- Button: "Sign in with a passkey"
- Failure: "We couldn't sign you in with that passkey. Try again, or use your email and password."
- Cancelled: no message; the page stays as it was.
- Security guideline: one bullet describing the passkey sign-in rules, beside the bullets for the other sign-in paths. It is a policy change: it describes this feature only, as the other sign-in bullets do, and the reviewer checks it against the sign-off on #313.
Existing work compared
- Searched: issues for passkey, sign-in, lockout and session;
data/session.ts,data/socialAccounts.ts(#505),use-cases/signInWithPassword.ts,data/failures.ts. - Native: Payload's
local-jwtstrategy reads the session we start; no strategy is added. - Official and community plugins: none fit (#313's table).
- Our code: reuses #505's session code, the single wrong-credentials failure, the limits and "keep me signed in". No passkey sign-in exists, so this is new.
Acceptance criteria
Tests first.
- Not done: Use-case tests: an unknown credential, a wrong signature, a replayed challenge, a wrong origin, and locked, unverified and agent accounts are all refused with one fixed failure that doesn't say whether an account exists; a good answer signs in that account only.
- Not done: Against real Payload: the cookie set is accepted by
payload.authas that account; sign-out ends it;/adminworks for staff signed in this way. - Not done: The limits refuse past their count with a fixed message.
- Not done: The moved session code keeps #505's tests green.
- Not done: Component tests with axe for the button and its messages.
- Not done: A resident signs in with a passkey on a phone and on a desktop.
- Not done:
/loginat 320, 430, 768, 1024, 1280 and 1920 px, light and dark: the ways in line up, buttons 44 px tall, full width on a phone. - Not done:
/loginsendsframe-ancestors 'none', using the same route as/account(#1314); a sign-in answer marked cross-origin is refused. - Not done: The accounts note,
docs/guidelines/security.mdand the routes reference in the same PR.
Files likely touched
src/modules/accounts/use-cases/signInWithPasskey.ts(+ test)src/modules/accounts/data/session.ts(+ test),data/socialAccounts.ts(the move only),data/webauthn.tssrc/modules/accounts/actions.ts(+ test),server.tssrc/modules/accounts/ui/PasskeySignIn.client.tsx(+ test),ui/passkeyMessages.tssrc/platform/lib/messages/accounts.tssrc/app/(frontend)/login/page.tsx(+ test)src/modules/accounts/README.md,docs/guidelines/security.md,docs/reference/routes.md
Must not touch
src/app/(frontend)/account/**(issues 03 and 05)src/modules/accounts/data/oauthProviders.ts,src/app/(frontend)/auth/**- Payload's lockout and login settings on
users
Open questions
- None.
Area
auth, frontend
Priority
low
Generated by Claude Code, opens in a new tab