feat(auth): add passkey support - #4957
Merged
Merged
Conversation
| session: { | ||
| expiresIn: 60 * 60 * 24 * 3, | ||
| updateAge: 60 * 60 * 24, | ||
| freshAge: 0, |
Contributor
There was a problem hiding this comment.
Global freshness boundary disabled
If an attacker holds an older but still-valid session, freshAge: 0 makes fresh-session middleware skip its age check, allowing that session to enroll an attacker-controlled passkey and establish durable account access; this global setting also removes freshness protection from other sensitive better-auth operations such as account unlinking.
How this was verified: Better-auth treats zero as disabling the age check, and passkey registration uses its fresh-session middleware.
Knowledge Base Used: Authentication, Organizations, and Permissions
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.
Summary
Adds WebAuthn passkeys via better-auth's
@better-auth/passkeyplugin (same scoped-package family as sso/scim/api-key, pinned to 1.6.23).passkey()plugin registered inauth.ts(mirrored inauth-cli.ts).rpID/originare derived from the request, so it works for both IP and custom-domain panels without config.passkeytable (+ indexes onuser_id/credential_id), migration0177_glossy_brother_voodoo.sql.freshAge: 0— otherwise sessions older than 24h get a 403 "Session is not fresh" when managing passkeys (Dokploy doesn't use any other better-auth endpoint gated by freshness; password changes still require the current password).Greptile Summary
Adds Better Auth passkey support across authentication, persistence, login, and profile management.
Confidence Score: 4/5
The PR does not appear safe to merge until the outstanding global session-freshness bypass is fixed.
The runtime auth configuration still sets
freshAge: 0while passkey enrollment remains directly reachable, leaving the previously reported path for an older stolen session to register a durable credential.Files Needing Attention: packages/server/src/lib/auth.ts
Reviews (3): Last reviewed commit: "fix(build): exclude CLI-only auth config..." | Re-trigger Greptile
Context used: