Repository navigation
feat(auth2): Implement Passkey authentication provider - #3829
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
✨ Finishing touches🧪 Generate unit tests
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.
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. Comment |
serverpod_auth_passkey_account8d07fc7 to
560785d
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
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 configConst 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 docsBeing 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-emptyWe currently delegate all challenge generation to
passkeys_server.createChallenge()and persist the rawByteDatawithout 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 theinsertRowcall in a helper that throws ifchallenge.lengthInBytes == 0.Optional — you can also extend the
.spy.yamlmodel with a custom validator to guard thechallengefield 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 fileMinor 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-proofingDepending 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 fileSatisfies 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 friendlinessProvide 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 conventionBased 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 barrelsWe’ve confirmed that
lib/providers/passkey.dartexists 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 oncreatedAtand return the deleted-rows countThe
passkey_challengemodel defines acreatedAtfield but has no index, which means the cleanup query will do a full table scan each time. You should add an index oncreatedAtand—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 oncreatedAt:# around line 9 createdAt: DateTime, defaultModel=now # add this block (adjust indentation to match file) indices: - fields: [createdAt]• In
passkey_accounts_admin.dart, updatedeleteExpiredChallengesto returnFuture<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_challengeby indexingcreatedAt.- 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 relocatingIf 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: ByteDataOptionally, consider a follow-up rename to
credentialIdacross 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 laterThis 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 bytesBeing 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: ByteDataAlso, confirm this field is not unintentionally logged, as it can be sizeable.
19-21: Doc: note CBOR and creation ceremony sourceSmall 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 redundantAuthenticator 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.dartbefore 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 fileSatisfies 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.
⛔ Files ignored due to path filters (20)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/protocol.dartis 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.dartis 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.dartis 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.dartis 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.dartis 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.dartis excluded by!**/lib/src/protocol/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/protocol.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_account.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_challenge.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_challenge_expired_exception.dartis 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.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_login_request.dartis 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.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/passkey/models/passkey_registration_request.dartis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition.jsonis excluded by!**/migrations/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition.sqlis excluded by!**/migrations/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/definition_project.jsonis excluded by!**/migrations/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/migration.jsonis excluded by!**/migrations/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20250826091553355-v3-0-0/migration.sqlis excluded by!**/migrations/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/migration_registry.txtis 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.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/pubspec.yamlmodules/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.yamltemplates/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 consistentlyThe 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 setGood 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 changeThe 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 fineNo 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 piecesThe 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.
marcelomendoncasoares
left a comment
There was a problem hiding this comment.
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.
|
@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! |
|
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
left a comment
There was a problem hiding this comment.
Awesome work, @tp!
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