Repository navigation
feat(gotrue): add passkey (WebAuthn) support - #1392
Conversation
077c115 to
dda0ec5
Compare
|
Looks good! I'd like to see an e2e app implementing this so we can really make sure it works. As a follow up, write a complete guide on how to do the full native ceremony using an well known platform plugin, would be even better if we could offer that in the SDK so users don't need to implement it themselves. For Swift, I'm adding the |
I have that locally, I can post it in a temporary repo on Monday.
That's the plan!
Unfortunately there aren't conditional dependencies in Dart, but we do have full tree shaking, so might be worth adding a dependency anyways. The only potential problem is future dependency version resolution problems, but we should be able to handle those. |
## Summary Updates docs based on stable releases in `supabase/supabase-flutter`. ## Changes analyzed - **SDK**: dart - **Repo**: https://github.com/supabase/supabase-flutter - **Stable tag range**: `supabase_flutter-v2.14.1...supabase_flutter-v2.15.0` - **Commits**: `81c1590728a5e08bebdc152bd59a7c1e7644c8b2...9030650b74e253020f8c614b3bfb2c993b6061af` ## Documentation updates `apps/docs/spec/supabase_dart_v2.yml` — adds entries for the new passkey APIs landed in `supabase_flutter-v2.15.0` ([gotrue#1392](supabase/supabase-flutter#1392), [supabase_flutter#1408](supabase/supabase-flutter#1408)): - `signInWithPasskey()` / `registerPasskey()` — high-level helpers on `supabase_flutter` that drive the full WebAuthn ceremony. - `auth.passkey.*` — server side of the WebAuthn ceremony: `list`, `update`, `delete`, `startRegistration`, `verifyRegistration`, `startAuthentication`, `verifyAuthentication`. - `auth.admin.passkey.*` — admin endpoints: `listPasskeys`, `deletePasskey`. `apps/docs/content/guides/auth/passkeys.mdx` — adds Dart code examples to every passkey section (Enable in the client, Register, Sign in, Two-step API, Manage, Admin API) and points the reference links at both the JavaScript and Dart specs. Bumps the "Requires" admonition to include `supabase_flutter v2.15.0`. Other v2.14.2 / v2.15.0 changes that did not require doc updates: - `feat(realtime): protocol format 2.0.0` — protocol versions are already documented in `realtime/protocol.mdx`; the SDK now defaults to v2.0.0 but exposes a `version: RealtimeProtocolVersion.v1` opt-out, which is an SDK detail rather than a docs change. - `fix(gotrue): support asymmetric JWTs in getClaims` — bug fix to the existing `auth.getClaims` (no new API). - The rest are bug fixes and internal refactors (storage `createSignedUrls` null handling, postgrest stack traces, gotrue refresh-token races, PKCE email-change, realtime deaf-socket guards, lint/test/CI hygiene). `common-client-libs-sections.json` already contains entries for every new spec `id`, so the sidebar nav picks them up automatically. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added Dart language examples to passkey authentication guide covering client initialization, user registration, sign-in workflows, two-step ceremony flows, and passkey management operations * Updated Dart client specification to document new passkey authentication functions and admin-level passkey management capabilities <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary Updates docs based on stable releases in `supabase/supabase-flutter`. ## Changes analyzed - **SDK**: dart - **Repo**: https://github.com/supabase/supabase-flutter - **Stable tag range**: `supabase_flutter-v2.14.1...supabase_flutter-v2.15.0` - **Commits**: `81c1590728a5e08bebdc152bd59a7c1e7644c8b2...9030650b74e253020f8c614b3bfb2c993b6061af` ## Documentation updates `apps/docs/spec/supabase_dart_v2.yml` — adds entries for the new passkey APIs landed in `supabase_flutter-v2.15.0` ([gotrue#1392](supabase/supabase-flutter#1392), [supabase_flutter#1408](supabase/supabase-flutter#1408)): - `signInWithPasskey()` / `registerPasskey()` — high-level helpers on `supabase_flutter` that drive the full WebAuthn ceremony. - `auth.passkey.*` — server side of the WebAuthn ceremony: `list`, `update`, `delete`, `startRegistration`, `verifyRegistration`, `startAuthentication`, `verifyAuthentication`. - `auth.admin.passkey.*` — admin endpoints: `listPasskeys`, `deletePasskey`. `apps/docs/content/guides/auth/passkeys.mdx` — adds Dart code examples to every passkey section (Enable in the client, Register, Sign in, Two-step API, Manage, Admin API) and points the reference links at both the JavaScript and Dart specs. Bumps the "Requires" admonition to include `supabase_flutter v2.15.0`. Other v2.14.2 / v2.15.0 changes that did not require doc updates: - `feat(realtime): protocol format 2.0.0` — protocol versions are already documented in `realtime/protocol.mdx`; the SDK now defaults to v2.0.0 but exposes a `version: RealtimeProtocolVersion.v1` opt-out, which is an SDK detail rather than a docs change. - `fix(gotrue): support asymmetric JWTs in getClaims` — bug fix to the existing `auth.getClaims` (no new API). - The rest are bug fixes and internal refactors (storage `createSignedUrls` null handling, postgrest stack traces, gotrue refresh-token races, PKCE email-change, realtime deaf-socket guards, lint/test/CI hygiene). `common-client-libs-sections.json` already contains entries for every new spec `id`, so the sidebar nav picks them up automatically. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added Dart language examples to passkey authentication guide covering client initialization, user registration, sign-in workflows, two-step ceremony flows, and passkey management operations * Updated Dart client specification to document new passkey authentication functions and admin-level passkey management capabilities <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What kind of change does this PR introduce?
Feature. Closes #1369.
Adds support for the Supabase Auth Passkeys (BETA) API (
/passkeys/*endpoints), mirroring the two-stepauth.passkey.*API surface of auth-js.What is the new behavior?
New
supabase.auth.passkeynamespace (GoTruePasskeyApi):startRegistration()/verifyRegistration(challengeId:, credential:)to register a passkey for the signed-in userstartAuthentication(captchaToken:)/verifyAuthentication(challengeId:, credential:)to sign in with a passkey; persists the session and firesAuthChangeEvent.signedInlist(),update(passkeyId:, friendlyName:),delete(passkeyId:)for managementNew
supabase.auth.admin.passkeynamespace (GoTrueAdminPasskeyApi) withlistPasskeys(userId:)anddeletePasskey(userId:, passkeyId:).Supporting changes:
Passkey,PasskeyRegistrationOptionsResponse,PasskeyAuthenticationOptionsResponseGotrueFetch(used by the passkey rename endpoint)FactorType.webauthn, awebauthnbucket inmfa.listFactors(),AMRMethod.passkeyandAMRMethod.mfaWebauthnErrorCode(passkey_disabled,webauthn_*,mfa_webauthn_*,too_many_passkeys)Design notes
credential_manager, ornavigator.credentialson web). Options and credentials are exchanged asMap<String, dynamic>in the W3C WebAuthn L3 JSON format, which is what those plugins accept and produce. This matches the two-stepauth.passkey.start*/verify*API in auth-js; its one-callsignInWithPasskey()performs the ceremony in-browser, which a pure Dart package cannot do cross-platform. A high-level helper on top of a pluggable authenticator interface is a possible follow-up, as is the separate MFA WebAuthn factor flow.experimental: { passkey: true }with a call-time throw. Instead of plumbing a runtime flag through three packages, the API is annotated with@experimentalfrompackage:metaso consumers get analyzer warnings. The server independently rejects calls withpasskey_disabledwhen the dashboard toggle is off.Tests
31 unit tests against a mock server client covering all endpoints and wire format (snake_case bodies, JWT headers, 204 deletes, top-level array responses), session/event side effects, model parsing edge cases, and error mapping. End-to-end tests against the dockerized GoTrue server are not feasible since the server cryptographically verifies attestations/assertions, which would require a software authenticator; auth-js has the same limitation.
Additional context
Passkeys must be enabled per project in the Dashboard under Authentication > Configuration > Passkeys (BETA). Docs (Dart reference spec and the passkeys guide in supabase/supabase) will follow after release.