Repository navigation
feat: offer a passkey after signing in - #4438
Merged
Merged
Conversation
|
Sandchest reviewed Sandchest reviews every change for vulnerabilities an attacker could use · 11 credits · Review details |
# Conflicts: # packages/database/package.json
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Member
Author
|
@greptileai review |
Member
Author
|
@greptileai review |
Member
Author
|
@greptileai review |
Sign-out now marks unused authorization codes as consumed in both the settings and agent API paths, and code issue, exchange and refresh take the account row lock first. Issuing a code also checks the session version under that lock, so a request racing sign-out can't mint one.
The session token now records how the person signed in. The no-code first-passkey route and the dashboard prompt refuse passkey sign-ins and sessions with no recorded method, so removing a sign-in-only passkey can't be followed by adding another from a passkey session.
Settings, the agent API and the mobile account deletion request now call revokeAllCredentials, which also voids pending CLI login codes and clears email change requests on the mobile path. CLI code issue and exchange take the account row lock, and issuing re-checks the session version, matching MCP.
Member
Author
|
@greptileai please re-review the latest head (521a712): MCP and CLI codes voided on sign-out, shared revokeAllCredentials, sign-in method recorded so passkey sign-ins can't use the no-code route. |
The list kept its first props, so a passkey added through the dashboard prompt on the Account page stayed hidden until a full reload. Take the server's list whenever router.refresh() delivers a new one.
Member
Author
|
@greptileai please re-review the latest head (1b26808). |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
After someone signs in without a passkey, the dashboard now asks once whether they want to add one.
users.preferences.passkeyPromptDismissedAt), so it doesn't follow them to every device.platformAuthenticatorIsAvailable).How
jwtcallback stampsauthTimewhen someone signs in (the callback runs withuser). Later refreshes keep it, and tokens from before this change have none. The time lives inside the encrypted session token, so a client can't set it.sessionexposes it to the server.isFreshSignIn(inpackages/database/auth/fresh-sign-in.ts) means the sign-in was within the last 10 minutes and is no more than 60 s in the future.getPasskeyRegistrationOptionsAfterSignInissues registration options only when the session belongs to the signed-in account, its sign-in is fresh, and the account has no passkeys. Otherwise it returnsverify. Completing registration goes through the existingcompletePasskeyRegistration, which keeps all of feat: sign in with passkeys #4435's checks: user verification, the session-version check under the user row lock, the 10-passkey cap, and the "passkey added" email.shouldOfferPasskeyruns in the dashboard layout, in parallel with the existing loads. It reads the session, skips snoozed accounts, and counts passkeys. Any error means "don't show the offer", so it can't break the dashboard.Security
The only new capability is: within 10 minutes of a real sign-in, an account with no passkeys can add its first one without a separate code. Being signed in for under 10 minutes counts as proof it's the account owner. A passkey added this way is sign-in only: it can never confirm identity.
user_passkeys.confirmsIdentity(migration0065, additive, defaults totrueso existing passkeys are unchanged).false.authMethod, stamped withauthTimeand never changed by refresh orupdate()). The no-code route and the prompt refuse passkey sign-ins and sessions with no recorded method. Otherwise someone holding a sign-in-only passkey could keep signing in with it, wait for the owner to remove it, and add another.authTimeis written only by thejwtcallback when NextAuth completes a sign-in; refreshes and clientupdate()calls leave it untouched (tested).passkey_first_registration). The insert re-checks that the account has no passkeys, under the user row lock, and any added passkey spends every outstanding setup.revokeAllCredentials, used by settings, the agent API and the mobile account deletion request, so the three can't drift apart. On top of sessions, keys and passkeys, it now also disconnects MCP apps and voids pending CLI login codes. The mobile path now also clears pending email changes.mcp_oauth_tokens (userId, revokedAt)andmcp_oauth_codes (userId, consumedAt)keep both updates off a full table scan (EXPLAIN shows a range scan on each).Testing
auth-options.test.ts):passkeys-database.test.ts):Not nowsnoozes it for 30 days, and other preferences are kept.next dev, 13/13:POST /api/v1/me/sign-out-allvoids pending MCP and CLI codes and revokes the MCP token. A late CLI code exchange gets 401, and a CLI key issued before sign-out gets 401.next dev, real MySQL), 12/12:Add passkeycreates one with no security code, the offer doesn't come back, and the new passkey signs in.Not nowis stored on the account, hides the offer after reload, and adds nothing.auth-options.test.tsalso coversauthMethod: stamped at sign-in, kept on refresh, not changeable throughupdate().tsc --noEmitforapps/weband Biome are clean.Migration
0065_passkey_confirms_identityadds one boolean column with a default and two secondary indexes on the small MCP tables. It ships through a PlanetScale deploy request before this merges.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was found.Summary
This PR offers eligible users their first passkey after signing in and strengthens account-wide sign-out.
Reviews (10) · Last reviewed commit: "fix(passkeys): show a passkey added from..." · Reviewed by Greptile