Skip to content

feat(auth2): Implement Passkey authentication provider - #3829

Merged
marcelomendoncasoares merged 14 commits into
serverpod:mainfrom
tp:passkey-impl
Sep 30, 2025
Merged

marcelomendoncasoares merged 14 commits into
serverpod:mainfrom
tp:passkey-impl

Conversation

@tp

@tp tp commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Adds the server-side implementation to add Passkeys to an existing auth user.

I opted not to allow "fresh" registration for now, as developers probably appreciate having some information about their users, as this is what all current providers offer (e.g. at least a verified email). But, of course, it would be easy to change the "register" method to create a new auth user instead of adding the key to the current user.

Relates to #3540

Summary by CodeRabbit

  • New Features
    • Introduced passkey (WebAuthn) authentication: generate challenges, register passkeys to existing accounts, and sign in using passkeys.
    • Creates authenticated sessions via passkey and honors blocked-user restrictions.
  • Chores
    • Added dependency to enable passkey server capabilities.
    • Automatic cleanup of expired passkey challenges to maintain system health.
  • Tests
    • Added end-to-end tests covering passkey registration and login flows.

@coderabbitai

coderabbitai Bot commented Jul 25, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Adds a new Passkey authentication provider to the Serverpod IDP server: data models, business logic, admin utilities, and an abstract endpoint. Introduces challenge creation, passkey registration, and authentication flows, backed by new DB models and the passkeys_server dependency. Exposes a barrel export and provider entrypoint.

Changes

Cohort / File(s) Summary
Provider entrypoint
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dart
New library file exporting the passkey provider from src.
Passkey barrel exports
.../lib/src/providers/passkey/passkey.dart
Barrel file exporting business components: config, accounts, admin.
Business logic
.../business/passkey_account_config.dart, .../business/passkey_accounts.dart, .../business/passkey_accounts_admin.dart
Add config (hostname, challenge lifetime), core account operations (challenge/create, register, authenticate) using passkeys_server, and admin cleanup for expired challenges.
Endpoint
.../endpoints/passkey_account_base_endpoint.dart
Abstract endpoint with createChallenge, register, and authenticate; wraps DB transactions and creates AuthSessions on success.
Models (server-only and requests)
.../models/passkey_account.spy.yaml, .../models/passkey_challenge.spy.yaml, .../models/passkey_registration_request.spy.yaml, .../models/passkey_login_request.spy.yaml
Define DB models for PasskeyAccount and PasskeyChallenge; define request payloads for registration and login.
Exceptions (spy YAML)
.../models/passkey_challenge_expired_exception.spy.yaml, .../models/passkey_challenge_not_found_exception.spy.yaml, .../models/passkey_public_key_not_found_exception.spy.yaml
Declare exceptions used by business logic (expired challenge, not found, public key not found).
Dependencies
.../serverpod_auth_idp_server/pubspec.yaml, templates/pubspecs/.../serverpod_auth_idp_server/pubspec.yaml
Add dependency: passkeys_server: ^0.3.0.
Tests
.../test/passkey/passkey_accounts_test.dart
Add tests covering passkey registration and authentication with sample vectors and DB interactions.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Endpoint as PasskeyAccountBaseEndpoint
  participant Accounts as PasskeyAccounts
  participant DB as DB (PasskeyChallenge/PasskeyAccount)
  participant PKS as passkeys_server

  rect rgba(200,220,255,0.3)
  Note over Client,Endpoint: Create challenge
  Client->>Endpoint: createChallenge()
  Endpoint->>Accounts: createChallenge(session)
  Accounts->>DB: insert PasskeyChallenge(challenge, createdAt)
  Accounts-->>Endpoint: PasskeyChallenge
  Endpoint-->>Client: {id, challenge}
  end

  rect rgba(200,255,200,0.3)
  Note over Client,Endpoint: Register passkey
  Client->>Endpoint: register(registrationRequest)
  Endpoint->>Endpoint: transaction start
  Endpoint->>Accounts: registerPasskey(session, request, tx)
  Accounts->>DB: get PasskeyChallenge by id
  Accounts->>PKS: verifyRegistration(request, challenge, rpId=hostname)
  PKS-->>Accounts: ok (attestation details)
  Accounts->>DB: insert PasskeyAccount (user, key, attestation, ...)
  Endpoint->>Endpoint: transaction commit
  Endpoint-->>Client: 200 OK
  end

  rect rgba(255,240,200,0.3)
  Note over Client,Endpoint: Authenticate with passkey
  Client->>Endpoint: authenticate(loginRequest)
  Endpoint->>Endpoint: transaction start
  Endpoint->>Accounts: authenticate(session, request, tx)
  Accounts->>DB: get PasskeyChallenge by id (freshness check)
  Accounts->>DB: get PasskeyAccount by keyId
  Accounts->>PKS: verifyAuthentication(request, storedPublicKey, rpId)
  PKS-->>Accounts: ok (verified)
  Accounts-->>Endpoint: authUserId
  Endpoint->>DB: load AuthUser
  Endpoint->>DB: create AuthSession(method="passkey", scopes)
  Endpoint->>Endpoint: transaction commit
  Endpoint-->>Client: AuthSuccess
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@tp tp changed the title feat(auth2): Implement serverpod_auth_passkey_account feat(auth2): Implement Passkey authentication provider Aug 25, 2025
@tp
tp force-pushed the passkey-impl branch 4 times, most recently from 8d07fc7 to 560785d Compare August 26, 2025 12:00
@tp

tp commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 26, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (27)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_account_config.dart (2)

12-15: Make constructor const and add light invariants (asserts) for safer config

Const enables compile-time constants at call sites and avoids accidental reallocation. A couple of asserts help catch misconfigured hostnames and invalid lifetimes during development.

Apply:

-  PasskeyAccountConfig({
-    required this.hostname,
-    this.challengeLifetime = const Duration(minutes: 5),
-  });
+  const PasskeyAccountConfig({
+    required this.hostname,
+    this.challengeLifetime = const Duration(minutes: 5),
+  }) : assert(hostname.isNotEmpty, 'hostname must not be empty'),
+       assert(!hostname.contains('://'),
+           'hostname must not include a scheme (e.g., https://example.com)'),
+       assert(!hostname.contains('/'),
+           'hostname must not include a path (e.g., example.com/path)'),
+       assert(!hostname.contains(':'),
+           'hostname must not include a port (e.g., example.com:443)'),
+       assert(challengeLifetime > Duration.zero,
+           'challengeLifetime must be > 0');

3-10: Clarify rpId/hostname expectations in the docs

Being explicit avoids misconfigurations (scheme, port, path). Also mention common values (example.com, localhost) to align with WebAuthn/FIDO expectations.

Apply:

-  /// The hostname to be used on the web and associated with any apps.
-  ///
-  /// This is also known as the "relying party".
+  /// The relying-party identifier (rpId) used for Passkeys.
+  ///
+  /// Provide only the effective domain, without scheme, port, or path.
+  /// Examples: `example.com`, `auth.example.com`, `localhost`.
+  /// This value is used as the "relying party" identifier by the Passkeys
+  /// server and must match the origin constraints of your clients.
 
   final String hostname;
 
   /// Maximum time after which a challenge must have been solved.
   final Duration challengeLifetime;
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml (1)

11-12: Ensure Passkey challenges are ≥ 32 bytes and non-empty

We currently delegate all challenge generation to passkeys_server.createChallenge() and persist the raw ByteData without any size checks. To guard against weak or empty challenges, add explicit validation in your business logic:

• In PasskeyAccounts.createChallenge (modules/.../passkey/business/passkey_accounts.dart lines 39–43):

final challengeBytes = await _passkeys.createChallenge();
// Enforce cryptographic strength and minimum length
if (challengeBytes.lengthInBytes < 32) {
  throw StateError(
    'Passkey challenge too short (${challengeBytes.lengthInBytes} bytes); must be ≥ 32'
  );
}
final challenge = await PasskeyChallenge.db.insertRow(
  session,
  // …
);

• Reject empty challenges at persistence time (zero-length ByteData):
– Either add a pre-insert check in your partial model extension, or wrap the insertRow call in a helper that throws if challenge.lengthInBytes == 0.

Optional — you can also extend the .spy.yaml model with a custom validator to guard the challenge field at code-generation time.

By enforcing these checks you’ll ensure each challenge is cryptographically random, at least 32 bytes long, and never zero-length.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_login_request.spy.yaml (2)

1-17: Include newline at end of file

Minor formatting fix to satisfy linters.

   ### The signature of the client's key on the challenge.
   signature: ByteData
+

3-17: Consider capturing optional WebAuthn fields for completeness and future-proofing

Depending on your passkeys_server verifier, you may want to capture userHandle and extensions outputs to support username-less flows and auditing.

Possible additions:

 fields:
   ### The ID of the solved challenge.
   challengeId: UuidValue
   ### The ID of the key used.
   keyId: ByteData
   ### The client authenticator's response data.
   authenticatorData: ByteData
   ### The client authenticator's JSON data.
   clientDataJSON: ByteData
   ### The signature of the client's key on the challenge.
   signature: ByteData
+  ### Optional user handle (for discoverable credentials).
+  userHandle: ByteData?
+  ### Optional JSON with extension results.
+  clientExtensionsJSON: ByteData?

If you already derive these from the verifier and don’t need to persist them, feel free to ignore. I can align this with the actual verification flow on request.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_account.spy.yaml (2)

20-31: Reassess storing full attestationObject long-term (privacy/storage)

Attestation can include device-identifying cert chains. If you don’t need long-term attestation records, consider storing only AAGUID, format, and trust result and dropping the blob post-verification.


41-41: Include newline at end of file

Satisfies linter warning.

     unique: true
+
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dart (2)

1-3: Name the library for clarity and analyzer friendliness

Provide a library name to aid tooling and avoid unnamed-library edge cases.

-/// This library contains the Passkey authentication provider for the
-/// Serverpod IDP module.
-library;
+/// This library contains the Passkey authentication provider for the
+/// Serverpod IDP module.
+library serverpod_auth_idp_passkey;

5-5: Prefer package export over relative path to match team convention

Based on your past preference (learned from PR 3747), exporting via a package URI improves consistency within the workspace.

-export '../src/providers/passkey/passkey.dart';
+export 'package:serverpod_auth_idp_server/src/providers/passkey/passkey.dart';

Note: Adjust the package name if it differs in pubspec. I can update all barrels in this module for consistency if you want.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dart (1)

1-3: Use package-scoped exports for public API barrels

We’ve confirmed that lib/providers/passkey.dart exists and re-exports the src barrel, so these exports are part of the public surface and should use full package paths to avoid breakage when files are moved.

• lib/src/providers/passkey/passkey.dart
Replace relative exports with package-scoped URIs.
• lib/providers/passkey.dart
Replace the relative export of the src barrel with a package-scoped URI.

Updated diffs:

--- a/lib/src/providers/passkey/passkey.dart
@@
-export './business/passkey_account_config.dart';
-export './business/passkey_accounts.dart';
-export './business/passkey_accounts_admin.dart';
+export 'package:serverpod_auth_idp_server/src/providers/passkey/business/passkey_account_config.dart';
+export 'package:serverpod_auth_idp_server/src/providers/passkey/business/passkey_accounts.dart';
+export 'package:serverpod_auth_idp_server/src/providers/passkey/business/passkey_accounts_admin.dart';
--- a/lib/providers/passkey.dart
@@
-export '../src/providers/passkey/passkey.dart';
+export 'package:serverpod_auth_idp_server/src/providers/passkey/passkey.dart';

This aligns with tp’s preference for full-package imports and makes future refactors less brittle.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts_admin.dart (1)

11-16: Add an index on createdAt and return the deleted-rows count

The passkey_challenge model defines a createdAt field but has no index, which means the cleanup query will do a full table scan each time. You should add an index on createdAt and—optionally—change your cleanup method to return the number of rows deleted for better observability.

• In serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml, add an index on createdAt:

# around line 9
createdAt: DateTime, defaultModel=now

# add this block (adjust indentation to match file)
indices:
  - fields: [createdAt]

• In passkey_accounts_admin.dart, update deleteExpiredChallenges to return Future<int>:

-  Future<void> deleteExpiredChallenges(final Session session) async {
-    await PasskeyChallenge.db.deleteWhere(
+  Future<int> deleteExpiredChallenges(final Session session) async {
+    final deleted = await PasskeyChallenge.db.deleteWhere(
       session,
       where: (final t) =>
         t.createdAt <
         clock.now().subtract(PasskeyAccounts.config.challengeLifetime),
     );
+    return deleted;
   }

These changes will:

  • Prevent full scans on passkey_challenge by indexing createdAt.
  • Allow cron jobs or metrics systems to record how many challenges were purged without issuing a second query.
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_accounts_test.dart (3)

7-7: Avoid coupling tests to the email provider’s internal util.

The asByteData helper under src/providers/email is an implementation detail. Consider moving these Uint8List/ByteData utilities to a shared location (e.g., src/util/) and importing from there to reduce cross-provider coupling.

-import 'package:serverpod_auth_idp_server/src/providers/email/util/uint8list_extension.dart';
+import 'package:serverpod_auth_idp_server/src/util/uint8list_extension.dart'; // after relocating

If you want, I can prep the relocation diff across the repo.


12-68: Great end-to-end registration flow test; add negative-path coverage.

Add tests to harden behavior and prevent regressions:

  • Challenge not found (random UUID) → PasskeyChallengeNotFoundException.
  • Challenge expired (create with createdAt set in past > lifetime) → PasskeyChallengeExpiredException.
  • Duplicate keyId on registration → proper DB unique violation handling or domain error.
  • Verify challenge created by PasskeyAccounts.createChallenge() can be used to register (not only manually inserted challenges).

69-141: Authentication flow test looks good; consider replay and wrong-key scenarios.

Additional tests:

  • Replay login with the same challenge/signature should fail (once you enforce one-time challenges).
  • Login with unknown keyId → PasskeyPublicKeyNotFoundException.
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts.dart (3)

26-33: Validate config upfront.

Guard against empty or malformed hostnames to avoid misconfigured RP IDs at runtime.

   static set config(final PasskeyAccountConfig config) {
-    _config = config;
+    if (config.hostname.isEmpty) {
+      throw ArgumentError.value(config.hostname, 'hostname', 'must not be empty');
+    }
+    _config = config;

Also consider naming the field rpId in PasskeyAccountConfig to align with WebAuthn terminology.


68-81: Delete the consumed registration challenge after successful verification.

One-time challenge semantics reduce replay risk and DB bloat. Deleting after a successful verify keeps behavior clear. Wrap in the same transaction to ensure atomicity.

     await PasskeyAccount.db.insertRow(
       session,
       PasskeyAccount(
         authUserId: authUserId,
         keyId: request.keyId,
         keyIdBase64: base64Encode(request.keyId.asUint8List),
         clientDataJSON: request.clientDataJSON,
         publicKey: request.publicKey,
         publicKeyAlgorithm: request.publicKeyAlgorithm,
         attestationObject: request.attestationObject,
         authenticatorData: request.authenticatorData,
         originalChallenge: challenge.challenge,
       ),
     );
+    // Invalidate the used challenge
+    await PasskeyChallenge.db.deleteWhere(
+      session,
+      where: (t) => t.id.equals(request.challengeId),
+      transaction: transaction,
+    );

98-116: Consider invalidating login challenges after successful authentication.

If your verification library doesn’t already enforce single-use, remove the challenge so the same signed assertion can’t be replayed within the lifetime window. This can be done transactionally after verifyLogin succeeds.

     await _passkeys.verifyLogin(
       key: (
         algorithm: passkeyAccount.publicKeyAlgorithm,
         publicKey: passkeyAccount.publicKey.asUint8List,
       ),
       authenticatorData: request.authenticatorData.asUint8List,
       clientDataJSON: request.clientDataJSON.asUint8List,
       signature: request.signature.asUint8List,
       challenge: challenge.challenge.asUint8List,
     );
 
-    return passkeyAccount.authUserId;
+    // Invalidate the used challenge to enforce one-time usage
+    await PasskeyChallenge.db.deleteWhere(
+      session,
+      where: (t) => t.id.equals(request.challengeId),
+      transaction: transaction,
+    );
+    return passkeyAccount.authUserId;

If passkeys_server internally tracks and enforces sign counters, note that in docs; otherwise consider persisting and checking signCount to detect cloned credentials.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart (2)

21-33: Wrap register in a transaction — good. Consider explicit auth precondition error.

Transaction use is correct. Optionally, surface a clear domain error if session.authenticated is null inside the business layer (instead of a null bang) to improve DX.


55-79: Session creation helper is correct; consider telemetry/audit logging.

Optional: Emit an audit event for passkey login and include method/scopes for security analytics.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_registration_request.spy.yaml (8)

7-9: Prefer WebAuthn terminology: credentialId instead of keyId (or at least clarify docs)

“keyId” can be confused with a key pair identifier. In WebAuthn this is the credential ID (a.k.a. key handle, rawId). If renaming is costly now, minimally tighten the comment.

Apply this doc-only diff for clarity:

-  ### The ID of the public key.
-  keyId: ByteData
+  ### The credential ID (a.k.a. key handle / rawId) assigned by the authenticator.
+  keyId: ByteData

Optionally, consider a follow-up rename to credentialId across the provider for consistency with specs.


10-12: Clarify the publicKey encoding (COSE_Key vs. raw/DER)

State explicitly whether this is the COSE_Key bytes (as per WebAuthn) or a derived raw/DER key. This prevents mismatches with downstream verification logic.

Apply this doc tweak:

-  ### The contents of the public key.
+  ### The credential public key bytes (COSE_Key as produced by WebAuthn).
   publicKey: ByteData

13-15: Use COSE algorithm identifier wording; consider an enum later

This is the COSE alg (e.g., -7 ES256, -257 RS256). Document it now; later you can introduce a small enum to avoid magic numbers.

-  ### The algorithm of the public key.
-  publicKeyAlgorithm: int
+  ### COSE algorithm identifier for the public key (e.g., -7=ES256, -257=RS256).
+  publicKeyAlgorithm: int

16-18: Doc: spell out that this is the raw clientDataJSON bytes

Being explicit helps avoid accidental JSON parsing or logging of large blobs.

-  ### The authenticator's JSON data.
-  clientDataJSON: ByteData
+  ### The clientDataJSON bytes from WebAuthn (base64url-encoded over the wire).
+  clientDataJSON: ByteData

Also, confirm this field is not unintentionally logged, as it can be sizeable.


19-21: Doc: note CBOR and creation ceremony source

Small clarity bump; aligns with typical WebAuthn terminology.

-  ### The authenticator's attestation object.
-  attestationObject: ByteData
+  ### The attestationObject (CBOR) returned by navigator.credentials.create().
+  attestationObject: ByteData

22-23: Is authenticatorData needed in addition to attestationObject? Make nullable if redundant

Authenticator data is embedded in attestationObject. If the server extracts it, this field is redundant payload. If you do need it, consider marking it nullable to allow either source.

Possible tweak:

-  ### The authenticator's data.
-  authenticatorData: ByteData
+  ### The authenticatorData (raw bytes). Optional if derivable from attestationObject.
+  authenticatorData: ByteData?

Please verify usages in passkey_accounts.dart before making this change.


1-23: Consider size limits/validation on large ByteData fields (DoS hardening)

Fields like clientDataJSON and attestationObject can be large. Add server-side validation caps and reject payloads exceeding expected bounds to reduce memory/CPU pressure during CBOR/JSON parsing.

If helpful, I can draft validation helpers and tests targeting the endpoint that consumes this model.


23-23: Add newline at end of file

Satisfies YAML lint and avoids noisy diffs.

   authenticatorData: ByteData
+ 
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5afeafc and 560785d.

⛔ Files ignored due to path filters (20)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/protocol.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/passkey/models/passkey_challenge_expired_exception.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/passkey/models/passkey_challenge_not_found_exception.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/passkey/models/passkey_login_request.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/passkey/models/passkey_public_key_not_found_exception.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/passkey/models/passkey_registration_request.dart is excluded by !**/lib/src/protocol/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/protocol.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_account.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_challenge.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_challenge_expired_exception.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_challenge_not_found_exception.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_login_request.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_public_key_not_found_exception.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_registration_request.dart is excluded by !**/generated/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition.json is excluded by !**/migrations/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition.sql is excluded by !**/migrations/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition_project.json is excluded by !**/migrations/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/migration.json is excluded by !**/migrations/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/migration.sql is excluded by !**/migrations/**
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/migration_registry.txt is excluded by !**/migrations/**
📒 Files selected for processing (16)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_account_config.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts_admin.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_account.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge_expired_exception.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge_not_found_exception.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_login_request.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_public_key_not_found_exception.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_registration_request.spy.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dart (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml (1 hunks)
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_accounts_test.dart (1 hunks)
  • templates/pubspecs/modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-07-02T16:07:50.947Z
Learnt from: tp
PR: serverpod/serverpod#3747
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_server/lib/src/business/migrating_email_endpoint_base.dart:4-4
Timestamp: 2025-07-02T16:07:50.947Z
Learning: In Serverpod, tp prefers importing the full package (e.g., 'package:serverpod_auth_migration_server/serverpod_auth_migration_server.dart') as a baseline rather than using smaller local imports, even within the same package where it might be considered a "self-import".

Applied to files:

  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dart
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml
  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dart
📚 Learning: 2025-07-02T16:09:27.702Z
Learnt from: tp
PR: serverpod/serverpod#3747
File: tests/serverpod_new_auth_test/serverpod_new_auth_test_server/pubspec.yaml:37-38
Timestamp: 2025-07-02T16:09:27.702Z
Learning: In Serverpod migration testing, it's appropriate for test servers like serverpod_new_auth_test_server to include dependencies on both legacy packages (e.g., serverpod_auth_server) and new modular packages to enable comprehensive testing of migration paths from old to new authentication systems.

Applied to files:

  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml
  • templates/pubspecs/modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml
📚 Learning: 2025-06-18T14:49:11.263Z
Learnt from: tp
PR: serverpod/serverpod#3672
File: tests/serverpod_test_server/test_integration/test_tools/test_session_builder_test.dart:10-30
Timestamp: 2025-06-18T14:49:11.263Z
Learning: In Serverpod test files, tp prefers using nullable late variables for AuthenticationInfo in tests (e.g., `late AuthenticationInfo? authenticationInfo;`) rather than non-nullable ones to avoid using `!` operators and to get clearer error messages when authentication setup fails. This provides better diagnostics when `session.authenticated` returns null.

Applied to files:

  • modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_accounts_test.dart
🪛 YAMLlint (1.37.1)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_login_request.spy.yaml

[error] 17-17: no new line character at the end of file

(new-line-at-end-of-file)

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_registration_request.spy.yaml

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_account.spy.yaml

[error] 41-41: no new line character at the end of file

(new-line-at-end-of-file)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (38)
  • GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
  • GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
  • GitHub Check: Serverpod integration tests (server) (3.24.0)
  • GitHub Check: Serverpod integration tests (server) (3.32.1)
  • GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: Migration e2e tests (3.32.1)
  • GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
  • GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
  • GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
  • GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_core/serverpod_auth_core_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_core/serverpod_auth_core_server with Flutter 3.24.0
  • GitHub Check: Migration e2e tests (3.24.0)
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
  • GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_bridge/serverpod_auth_bridge_server with Flutter 3.24.0
  • GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
  • GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
  • GitHub Check: serverpod generate (3.24.0)
  • GitHub Check: serverpod generate (3.32.1)
  • GitHub Check: Serverpod E2E web tests (3.32.1)
  • GitHub Check: Unit tests IO (3.32.1, windows-latest)
  • GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.32.1, windows-latest)
  • GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
  • GitHub Check: Unit tests Web (3.24.0, windows-latest)
  • GitHub Check: Unit tests IO (3.24.0, windows-latest)
  • GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
  • GitHub Check: Serverpod E2E web tests (3.24.0)
  • GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
  • GitHub Check: dart analyze latest (3.32.1, windows-latest)
  • GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
  • GitHub Check: dart analyze (3.24.0, windows-latest)
  • GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
  • GitHub Check: Serverpod E2E IO tests (3.32.1)
  • GitHub Check: Serverpod E2E IO tests (3.24.0)
  • GitHub Check: dart analyze (3.24.0, ubuntu-latest)
🔇 Additional comments (12)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge_expired_exception.spy.yaml (1)

1-1: LGTM: exception spy defined and named consistently

The exception name matches the established naming pattern for Passkey-related errors and will be straightforward to generate and use in tests.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_public_key_not_found_exception.spy.yaml (1)

1-1: LGTM: complements the Passkey exception set

Good addition for covering the “public key missing” path in tests. Name and placement look consistent with the other spies.

templates/pubspecs/modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml (1)

18-18: passkeys_server version and SDK constraints verified

  • The dependency is pinned to ^0.3.0, which matches the latest passkeys_server release (0.3.0).
  • The package’s SDK requirement (^3.5.0 ⇒ ≥3.5.0 <4.0.0) is satisfied by our project SDK constraint (≥3.5.0 <4.0.0).

No changes needed.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yaml (1)

19-19: Generated pubspec reflects the template change

The dependency appears correctly propagated from the template. No concerns from my side.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge_not_found_exception.spy.yaml (1)

1-1: LGTM — minimal spy for exception is fine

No issues; simple declaration works for tests and error mapping.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts.dart (2)

118-139: LGTM: challenge retrieval with expiry check is clean and side-effect free.

The lifetime cutoff using clock.now and config.challengeLifetime is correct and testable.


141-157: LGTM: account lookup by base64-encoded keyId is pragmatic.

Querying via a normalized string avoids engine-specific binary comparison pitfalls. Ensure a unique index on keyIdBase64 in the model (the YAML mentions it).

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart (3)

12-19: Challenge creation endpoint is straightforward and minimal.

Returning a typed record with id and challenge keeps the client contract simple.


35-53: Authenticate flow is sound; preserves atomicity and returns AuthSuccess.

This composes well with PasskeyAccounts. Once one-time challenge invalidation is added, this remains unchanged.


82-86: Nice: using a typed record for PasskeyChallengeResponse.

Keeps the transport shape explicit without a dedicated class.

modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_registration_request.spy.yaml (2)

1-3: Good addition; model shape matches WebAuthn registration payload pieces

The class and overall field set make sense for a passkey registration flow.


4-6: Confirm challenge ID semantics

“Solved challenge” reads fine, but ensure this is the server-issued challenge ID tied to the creation ceremony used for replay protection and not any client-generated identifier.

@tp
tp marked this pull request as ready for review August 26, 2025 13:47

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this, @tp! Made only few suggestions to improve test coverage and minor details of user experience. To complete the feature, we will only need a first stable release of the passkeys_server package.

@tp

tp commented Sep 18, 2025

Copy link
Copy Markdown
Contributor Author

@marcelomendoncasoares just a quick update from my end: Windows support just landed (had to get a Surface machine to be able to continually test it 😉). I am currently building a Flutter web frontend using the popular client package “passkeys”. We’ll see whether that works out of the box like my “plain HTML” demo or if the APIs need to be adapted (which would then also need to be mirrored in the models here). Once the Flutter web example is live I can do the 1.0.0 release of the package and then will update the dependency here and work through your initial comments :)

I would say this should not be more than 2-3 days of work remaining (of what I see so far), but I may be busy next week and thus only finish this up the week after. Talk soon!

@tp

tp commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

Seems like 1 unrelated test case failed, but I can not re-run the CI jobs anymore to ensure that this truly is a fluke.

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, @tp!

@marcelomendoncasoares
marcelomendoncasoares merged commit 2161fc0 into serverpod:main Sep 30, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants