Repository navigation
feat(platform): WebAuthn/passkeys — enroll, sign-in, revoke + 2FA enforcement (#1508) - #1822
Conversation
Foundation for passkeys as a phishing-resistant second factor. This is the verifiable slice; the enforcement integration, enrollment/sign-in/revoke UI, and device testing require a running Convex backend + a WebAuthn authenticator (see the PR description — NOT mergeable as-is). - Add @better-auth/[email protected] (pulls @simplewebauthn/* transitively), pinned to match better-auth core. - Enable the passkey() plugin in convex/auth.ts (rpID/rpName/origin from SITE_URL) and passkeyClient() in lib/auth-client.ts. - Regenerate the Better Auth schema: adds the `passkey` table. - Renovate: group better-auth / @better-auth/* / @simplewebauthn/* so the passkey deps move in lockstep with better-auth core (90-day age waived). Pre-merge requirement: run `convex dev` to regenerate convex/betterAuth/_generated/component.ts so the adapter knows the `passkey` model — otherwise better-auth init fails at boot. `bun run check` cannot catch this (codegen is skipped without a deployment).
#1508) Builds on the plugin/schema foundation: the user-facing passkey UX and the "passkey satisfies org 2FA" enforcement. - Enforcement: `userHasPasskey` + a `hasPasskey` input to `evaluateTwoFactorEnforcement`, OR-ed into the satisfied condition. Wired through `getStatus` (client redirect) and `evaluateEnforcement` (server sign-in hook), so a passkey-only user under an enforced policy is never routed to the TOTP wall. Helper test added. - UI: `PasskeySection` (list / register / revoke via authClient.passkey.*), mounted in the account settings page beside TwoFactorSection. - Sign-in: "Sign in with a passkey" button on the login route (authClient.signIn.passkey). - i18n: passkey strings in en/de/fr (twoFactor.passkeys.* + auth.login.*). Transitional: `userHasPasskey` reads the better-auth `passkey` model via the component adapter, whose committed codegen lists it only after `convex dev` regenerates — a localized cast + lint suppression bridge that until then. Still DRAFT: regenerate codegen before merge and device-test the ceremonies (see PR description).
Make the passkey feature production-ready: - Regenerate the better-auth adapter codegen (betterAuth/_generated/component.ts) against the current schema so the `passkey` model is in the adapter union. This removes the transitional cast + lint suppression in `userHasPasskey` (now a plain `model: 'passkey'`) and means the passkey plugin initializes correctly at boot. The regen also picks up the `twoFactor.verified` field already present in the better-auth 1.6.11 schema (the committed file predated that bump). - Audit logging: passkey register/revoke now emit `passkey_added` / `passkey_removed` security audit entries via the existing 2FA after-hook + logEnrollmentEvent path, with action labels in en/de/fr — credential lifecycle events land in the same audit trail as TOTP (SOC 2). Full `bun run check` green. Remaining: device QA of the WebAuthn ceremonies (register / authenticate / revoke) on a real authenticator.
|
Warning Review limit reached
More reviews will be available in 19 minutes and 50 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (17)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adds WebAuthn / passkeys as a phishing-resistant second factor, closing #1508.
What's included
Auth / backend
@better-auth/[email protected](pulls@simplewebauthn/*), pinned to better-auth core;passkey()plugin in auth.ts (rpID/rpName/originfromSITE_URL);passkeyClient()in auth-client.ts.passkeytable and model are first-class (no casts/shims).two_factor_policyalongside TOTP —userHasPasskeyis OR-ed intoevaluateTwoFactorEnforcement, wired through bothgetStatus(client redirect) and the server sign-in hook, so a passkey-only user is never sent to the TOTP wall.passkey_added/passkey_removedsecurity audit entries (same trail + after-hook path as TOTP), with action labels in en/de/fr.UI
PasskeySectionon account settings — register / list / revoke.Tests / checks
bun run checkgreen (format, lint, typecheck, 71k+ unit tests).better-auth/@better-auth/*/@simplewebauthn/*grouped, 90-day age waived (move in lockstep with better-auth core).Before merge — device QA
WebAuthn ceremonies can't be exercised in CI/agent automation, so please verify on a real authenticator: register a platform + a roaming passkey, sign in with one, revoke one, and confirm a passkey-only user satisfies an enforced org 2FA policy. Everything else (boot, types, enforcement logic, audit emission wiring) is verified.
Part of the #1803 security/compliance epic.