Skip to content

docs(auth): define WebAuthn MFA enrollment and step-up verify - #319

Draft
grdsdev wants to merge 1 commit into
mainfrom
guilhermesouza/auth-mfa-webauthn-spec
Draft

grdsdev wants to merge 1 commit into
mainfrom
guilhermesouza/auth-mfa-webauthn-spec

Conversation

@grdsdev

@grdsdev grdsdev commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

What

  • specs/auth/mfa/enroll.md: adds the webauthn factor type. The enrollment ceremony is enroll → challenge → navigator.credentials.create → verify with type: create. It is the only flow that sends a create credential. When the ceremony or the verify fails, the SDK does not unenroll the factor. Its docs tell the app how to find the factor and remove it.
  • specs/auth/mfa/verify.md (new):
    • The webauthn body keeps the W3C keys unchanged.
    • type comes from the challenge response.
    • The step-up method runs only the authentication ceremony. On a create challenge, it raises the SDK's own error before it starts the authenticator.
  • capabilities/auth.yaml: the auth.mfa.enroll description now lists WebAuthn.

Why

  • The server picks the ceremony from the type that the client sends (verifyWebAuthnFactor). If a method that is meant to step up sends create, it can register a credential without warning. With the step-up rule, a step-up call never registers one.
  • The server keeps an unverified WebAuthn factor that has a challenge, and its name blocks a new enrollment with mfa_factor_name_conflict. Linear AUTH-2001 tracks the server fix. SDKs do not unenroll the factor on their own, because an automatic unenroll can remove a concurrent enrollment (Linear SDK-1716).

supabase/supabase-swift#1680 implements both rules.

Checks

bun run validate, bun run format-and-lint, and bun test pass.

MFA Enroll now covers the webauthn factor type: the enrollment
ceremony is the only flow that sends a create credential, and a failed
ceremony leaves the factor for the app to unenroll.

The new MFA Verify spec says how the webauthn body is built, and that
the step-up ceremony refuses a create challenge before it starts the
authenticator.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

grdsdev added a commit to supabase/supabase-swift that referenced this pull request Nov 3, 2026
When the challenge asks for a create ceremony, verifyWebAuthn throws
AuthError of kind mfaFactorNotVerified before it shows the passkey
sheet. Only enrollWebAuthn registers a credential. This follows
supabase/sdk#319.
grdsdev added a commit to supabase/supabase-swift that referenced this pull request Nov 3, 2026
…1680)

* feat(auth)!: regroup passkeys under client.passkeys and client.mfa

Move the experimental passkey API to `auth.passkeys` (signIn, register,
list, rename, delete, and the low-level options/verify calls) and the
admin calls to `auth.admin.passkeys`. MFA keeps `enrollWebAuthn` and
`verifyWebAuthn`. Challenge IDs are `UUID`, the anchor is optional and
defaults to the app's key window, a dismissed sheet throws
`CancellationError`, and other authenticator errors throw `AuthError`
of kind `passkeyCeremonyFailed`. All of it stays `@_spi(Experimental)`.

Fix the MFA WebAuthn flow against the auth server:
- read the options from the `credential_options.publicKey` wrapper
- send `webauthn: {type, credential_response}` on verify
- always send a JSON body on challenge
- run the ceremony the challenge asks for (`create` or `request`)
- unenroll the new factor when enrollment fails, so a retry is not
  blocked by a name conflict

BREAKING CHANGE: the experimental passkey and WebAuthn MFA methods moved
and were renamed. See docs/migrations/v3/Auth.md.

Fixes SDK-2073

* test(auth): keep the unenroll mock callback off the main actor

The `@MainActor` test's `requestCallback` closure inherited main-actor
isolation, and Mocker runs it on the URL loading thread, so xcodebuild's
isolation check trapped. Also register `MFAVerifyParams.encode` in
sdk-compliance.yaml and use the result of `verifyWebAuthn` in a test.

* fix(auth): stop unenrolling the WebAuthn factor after a failed enrollment

The leftover unverified factor is server behavior (AUTH-2001), so the
SDK no longer works around it. The docs tell apps how to find and
remove the factor.

* docs(auth): find a leftover WebAuthn factor through user(jwt:)

* feat(auth)!: verifyWebAuthn only steps up with a verified factor

When the challenge asks for a create ceremony, verifyWebAuthn throws
AuthError of kind mfaFactorNotVerified before it shows the passkey
sheet. Only enrollWebAuthn registers a credential. This follows
supabase/sdk#319.

* test(auth): call session() in the passkey registration integration test

This branch has not been deployed

No deployments
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