Skip to content

feat(platform): WebAuthn/passkeys — enroll, sign-in, revoke + 2FA enforcement (#1508) - #1822

Merged
yannickmonney merged 4 commits into
mainfrom
feat/webauthn-passkeys
Jun 2, 2026
Merged

yannickmonney merged 4 commits into
mainfrom
feat/webauthn-passkeys

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

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/origin from SITE_URL); passkeyClient() in auth-client.ts.
  • Better Auth schema + adapter codegen regenerated — the passkey table and model are first-class (no casts/shims).
  • Enforcement: a registered passkey satisfies an enforced two_factor_policy alongside TOTP — userHasPasskey is OR-ed into evaluateTwoFactorEnforcement, wired through both getStatus (client redirect) and the server sign-in hook, so a passkey-only user is never sent to the TOTP wall.
  • Audit logging: register/revoke emit passkey_added / passkey_removed security audit entries (same trail + after-hook path as TOTP), with action labels in en/de/fr.

UI

  • PasskeySection on account settings — register / list / revoke.
  • "Sign in with a passkey" on the login route.
  • i18n en/de/fr.

Tests / checks

  • bun run check green (format, lint, typecheck, 71k+ unit tests).
  • Enforcement unit test: a passkey satisfies an enforced policy even at grace=0.
  • Renovate: 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.

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).
@yannickmonney yannickmonney changed the title feat(platform): WebAuthn/passkeys foundation — plugin + schema (#1508) [DRAFT] feat(platform): WebAuthn/passkeys — enroll, sign-in, revoke + 2FA enforcement (#1508) [DRAFT] Jun 2, 2026
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.
@yannickmonney
yannickmonney marked this pull request as ready for review June 2, 2026 11:57
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@yannickmonney, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 27a837b0-3578-4628-a576-fc515d4f7eec

📥 Commits

Reviewing files that changed from the base of the PR and between 29963ce and 98fc9f3.

⛔ Files ignored due to path filters (2)
  • bun.lock is excluded by !**/*.lock
  • services/platform/convex/betterAuth/_generated/component.ts is excluded by !**/_generated/**
📒 Files selected for processing (17)
  • .github/renovate.json
  • services/platform/app/features/settings/account/components/account-form.tsx
  • services/platform/app/features/settings/account/components/passkey-section.tsx
  • services/platform/app/routes/_auth/log-in.tsx
  • services/platform/convex/auth.ts
  • services/platform/convex/betterAuth/generated_schema.ts
  • services/platform/convex/two_factor/auth_hooks.ts
  • services/platform/convex/two_factor/helpers.test.ts
  • services/platform/convex/two_factor/helpers.ts
  • services/platform/convex/two_factor/internal_mutations.ts
  • services/platform/convex/two_factor/internal_queries.ts
  • services/platform/convex/two_factor/queries.ts
  • services/platform/lib/auth-client.ts
  • services/platform/messages/de.json
  • services/platform/messages/en.json
  • services/platform/messages/fr.json
  • services/platform/package.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/webauthn-passkeys

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yannickmonney yannickmonney changed the title feat(platform): WebAuthn/passkeys — enroll, sign-in, revoke + 2FA enforcement (#1508) [DRAFT] feat(platform): WebAuthn/passkeys — enroll, sign-in, revoke + 2FA enforcement (#1508) Jun 2, 2026
@yannickmonney
yannickmonney merged commit 360ccb4 into main Jun 2, 2026
21 checks passed
@yannickmonney
yannickmonney deleted the feat/webauthn-passkeys branch June 2, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant