Repository navigation
refactor!: Make passkey IDP conform to IDP pattern. - #4144
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 📝 WalkthroughWalkthroughThis pull request introduces Passkey-based identity provider support by implementing PasskeyIDP and PasskeyIDPUtils, adding a PasskeyIdentityProviderFactory, and registering the provider with AuthServices in the example auth server. The implementation refactors existing static PasskeyAccounts utilities into an instance-based architecture supporting transaction-aware operations, token issuance, and admin functions. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Endpoint as PasskeyIDPEndpoint
participant BaseEP as PasskeyIDPBaseEndpoint
participant IDP as PasskeyIDP
participant Utils as PasskeyIDPUtils
participant DB as Database
participant TokenMgr as TokenManager
rect rgb(240, 248, 255)
Note over Client,TokenMgr: Challenge Creation Flow
Client->>Endpoint: createChallenge(session)
Endpoint->>BaseEP: createChallenge(session)
BaseEP->>IDP: createChallenge(session)
IDP->>Utils: createChallenge(session)
Utils->>DB: Create PasskeyChallenge record
DB-->>Utils: Challenge ID, Challenge data
Utils-->>IDP: PasskeyChallenge
IDP-->>BaseEP: PasskeyChallengeResponse (id, challenge)
BaseEP-->>Endpoint: PasskeyChallengeResponse
Endpoint-->>Client: PasskeyChallengeResponse
end
rect rgb(240, 255, 240)
Note over Client,TokenMgr: Registration Flow
Client->>Endpoint: register(session, request, challengeId)
Endpoint->>BaseEP: register(session, request)
BaseEP->>IDP: register(session, authUserId, request)
IDP->>Utils: registerPasskey(session, authUserId, request)
Utils->>Utils: _consumeChallenge(session, challengeId)
Utils->>DB: Delete/Validate PasskeyChallenge
Utils->>DB: Create PasskeyAccount record
DB-->>Utils: Success
Utils-->>IDP: Void
IDP-->>BaseEP: Void
BaseEP-->>Endpoint: Void
Endpoint-->>Client: Success
end
rect rgb(255, 240, 245)
Note over Client,TokenMgr: Login Flow
Client->>Endpoint: login(session, loginRequest)
Endpoint->>BaseEP: login(session, loginRequest)
BaseEP->>IDP: login(session, request)
IDP->>Utils: authenticate(session, request)
Utils->>Utils: _consumeChallenge(session, challengeId)
Utils->>DB: Verify against PasskeyAccount
DB-->>Utils: authUserId
Utils-->>IDP: authUserId
IDP->>DB: Load AuthUser
DB-->>IDP: AuthUser
alt User is blocked
IDP-->>BaseEP: AuthUserBlockedException
else User is active
IDP->>TokenMgr: issueToken(authUserId)
TokenMgr-->>IDP: AuthSuccess (token)
IDP-->>BaseEP: AuthSuccess
BaseEP-->>Endpoint: AuthSuccess
Endpoint-->>Client: AuthSuccess
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
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 |
28a864e to
895d4be
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dart (1)
35-43: Update test descriptions to reflect PasskeyIDP.These test titles still say
PasskeyAccounts..., but the setup now exercisesPasskeyIDP. Renaming the descriptions (and the similar one below) will keep the intent obvious when reading test output.modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart (1)
58-75: Refresh test names to the PasskeyIDP terminology.The description still mentions
PasskeyAccounts..., which no longer matches the system under test. Please update this (and the other occurrences in this file) to sayPasskeyIDPso the output mirrors the refactor.modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart (1)
22-34: Consider explicit error handling for unauthenticated sessions.The null assertion operator on line 31 will throw a generic null check error if the user is not authenticated. For better developer experience and clearer error messages, consider explicit validation:
Apply this diff to add explicit error handling:
Future<void> register( final Session session, { required final PasskeyRegistrationRequest registrationRequest, }) async { + final authInfo = await session.authenticated; + if (authInfo == null) { + throw UnauthorizedException( + 'User must be authenticated to register a passkey', + ); + } await passkeyIDP.register( session, - authUserId: (await session.authenticated)!.authUserId, + authUserId: authInfo.authUserId, request: registrationRequest, ); }Note: Verify that
UnauthorizedExceptionis available from the imported packages.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (6)
examples/auth/auth_client/lib/src/protocol/client.dartis excluded by!**/lib/src/protocol/**examples/auth/auth_client/lib/src/protocol/protocol.dartis excluded by!**/lib/src/protocol/**examples/auth/auth_server/lib/src/generated/endpoints.dartis excluded by!**/generated/**examples/auth/auth_server/lib/src/generated/protocol.dartis excluded by!**/generated/**examples/auth/auth_server/lib/src/generated/protocol.yamlis excluded by!**/generated/**modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/client.dartis excluded by!**/lib/src/protocol/**
📒 Files selected for processing (14)
examples/auth/auth_server/lib/server.dart(3 hunks)examples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dart(1 hunks)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/integrations/passkey_identity_provider_factory.dart(1 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts_admin.dart(0 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dart(1 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dart(1 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dart(2 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart(3 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart(0 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart(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/test/passkey/passkey_idp_admin_test.dart(2 hunks)modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart(11 hunks)
💤 Files with no reviewable changes (2)
- modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts_admin.dart
- modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart
🧰 Additional context used
📓 Path-based instructions (3)
**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.dart: Format all Dart code usingdart format .before committing
Code must pass Dart analyzer in strict mode (util/run_tests_analyze or melos lint_strict)
Use descriptive variable and function names
Files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/integrations/passkey_identity_provider_factory.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
**/lib/**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Remove unnecessary comments from production code
Files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/integrations/passkey_identity_provider_factory.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
**/*_test.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*_test.dart: Write test descriptions using the Given/When/Then pattern
Organize tests with passing/success cases first, group related cases using group(), then follow with error cases
Files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart
🧠 Learnings (17)
📓 Common learnings
Learnt from: tp
Repo: serverpod/serverpod PR: 3829
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts.dart:0-0
Timestamp: 2025-08-26T13:22:33.125Z
Learning: The passkeys_server Dart library evolved from version 0.3.0 to 0.4.0, adding required parameters to verifyRegistration and verifyLogin methods for complete WebAuthn security validation including challenge, clientDataJSON, and attestationObject verification.
Learnt from: tp
Repo: serverpod/serverpod PR: 3829
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml:1-12
Timestamp: 2025-08-26T12:25:49.153Z
Learning: The Passkey authentication provider in Serverpod deletes used challenges to prevent replay attacks and maintain database cleanliness.
📚 Learning: 2025-08-26T13:22:33.125Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3829
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_accounts.dart:0-0
Timestamp: 2025-08-26T13:22:33.125Z
Learning: The passkeys_server Dart library evolved from version 0.3.0 to 0.4.0, adding required parameters to verifyRegistration and verifyLogin methods for complete WebAuthn security validation including challenge, clientDataJSON, and attestationObject verification.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/integrations/passkey_identity_provider_factory.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
📚 Learning: 2025-08-26T12:25:49.153Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3829
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml:1-12
Timestamp: 2025-08-26T12:25:49.153Z
Learning: The Passkey authentication provider in Serverpod deletes used challenges to prevent replay attacks and maintain database cleanliness.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
📚 Learning: 2025-08-26T12:25:49.153Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3829
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/models/passkey_challenge.spy.yaml:1-12
Timestamp: 2025-08-26T12:25:49.153Z
Learning: In the Serverpod Passkey authentication implementation, challenge expiry is handled via the PasskeyAccountConfig's challengeLifetime setting rather than storing explicit expiresAt timestamps in the database.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
📚 Learning: 2025-09-17T16:09:20.868Z
Learnt from: nielsenko
Repo: serverpod/serverpod PR: 3980
File: packages/serverpod/lib/src/web_server/web_server.dart:102-115
Timestamp: 2025-09-17T16:09:20.868Z
Learning: In Serverpod's web server authentication handling (packages/serverpod/lib/src/web_server/web_server.dart), query parameter authentication fallback (`authenticationKey ??= queryParameters['auth']`) is intentionally maintained for legacy compatibility reasons, even though it has security implications regarding credential leakage.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_admin.dartexamples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_config.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/integrations/passkey_identity_provider_factory.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
📚 Learning: 2025-07-02T16:07:50.947Z
Learnt from: tp
Repo: serverpod/serverpod PR: 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:
examples/auth/auth_server/lib/src/endpoints/passkey_idp_endpoint.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/integrations/passkey_identity_provider_factory.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-06-18T14:49:11.263Z
Learnt from: tp
Repo: serverpod/serverpod PR: 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_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/business/passkey_idp_utils.dart
📚 Learning: 2025-07-02T16:09:27.702Z
Learnt from: tp
Repo: serverpod/serverpod PR: 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/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-08-25T19:46:58.073Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3917
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/analysis_options.yaml:3-6
Timestamp: 2025-08-25T19:46:58.073Z
Learning: In Serverpod, test tool paths like `test/integration/test_tools/serverpod_test_tools.dart` are configured per project in the "generator.yaml" file and managed by a generator system, so they don't need to be updated manually across all files at once.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_admin_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/passkey.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dartmodules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-10-30T10:11:34.781Z
Learnt from: SandPod
Repo: serverpod/serverpod PR: 4127
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_account_base_endpoint.dart:11-16
Timestamp: 2025-10-30T10:11:34.781Z
Learning: In Serverpod authentication endpoints, SandPod prefers eager initialization of AuthConfig-dependent fields (e.g., `final TokenManager tokenManager = AuthConfig.instance.tokenManager;`) rather than lazy getters, to detect misconfiguration at server startup rather than deferring errors until the first request to the endpoint.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart
📚 Learning: 2025-06-16T12:07:26.018Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3651
File: modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server/lib/src/business/email_accounts.dart:35-39
Timestamp: 2025-06-16T12:07:26.018Z
Learning: The `withServerpod` test helper runs tests within a transaction, which may require adapting database queries to accept transaction parameters for proper snapshot consistency during testing.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart
📚 Learning: 2025-08-20T13:29:38.181Z
Learnt from: SandPod
Repo: serverpod/serverpod PR: 3904
File: modules/new_serverpod_auth/serverpod_auth_core/serverpod_auth_core_server/test/jwt/integration/authentication_tokens_test.dart:141-143
Timestamp: 2025-08-20T13:29:38.181Z
Learning: In Serverpod test files, SandPod prefers to avoid redundant null-checks in tests when the preconditions guarantee non-null values. They consider such defensive assertions as "redundant bloat" when the test environment is controlled and the implementation guarantees the presence of values like refreshToken.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/passkey/passkey_idp_test.dart
📚 Learning: 2025-07-23T13:18:31.864Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3820
File: modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server/lib/src/endpoints/user_profile_base_endpoint.dart:8-8
Timestamp: 2025-07-23T13:18:31.864Z
Learning: Abstract Endpoint classes in Serverpod should end with the "BaseEndpoint" suffix in their name (e.g., UserProfileBaseEndpoint). This naming convention should be enforced consistently across the codebase.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart
📚 Learning: 2025-07-24T13:01:52.743Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3826
File: modules/new_serverpod_auth/serverpod_auth_apple/serverpod_auth_apple_client/lib/serverpod_auth_apple_client.dart:1-1
Timestamp: 2025-07-24T13:01:52.743Z
Learning: High-level serverpod_auth_* packages (like serverpod_auth_apple_client) should re-export their serverpod_auth_* dependencies so that consumers only need to import the high-level package and don't get warnings about importing from non-dependency packages. The re-exports should hide conflicting elements like 'Caller' and 'Protocol' to avoid naming conflicts. This pattern prevents users from needing to directly depend on multiple internal implementation packages.
Applied to files:
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/passkey.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-07-15T13:38:58.183Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3787
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/pubspec.yaml:18-18
Timestamp: 2025-07-15T13:38:58.183Z
Learning: For Sign in with Apple authentication, there are two distinct packages: `sign_in_with_apple` is the client-side package for mobile apps, while `sign_in_with_apple_server` is a server-side utility package for handling Sign in with Apple tokens and validation on Dart servers.
Applied to files:
examples/auth/auth_server/lib/server.dart
📚 Learning: 2025-07-01T13:01:27.054Z
Learnt from: exaby73
Repo: serverpod/serverpod PR: 3741
File: modules/serverpod_auth/serverpod_auth_server/analysis_options.yaml:14-16
Timestamp: 2025-07-01T13:01:27.054Z
Learning: In Serverpod, first-party packages like serverpod_auth_server can appropriately use blanket `invalid_use_of_internal_member: ignore` directives in their analysis_options.yaml since they use internal Database methods internally without exposing them in their public APIs to end users.
Applied to files:
examples/auth/auth_server/lib/server.dart
📚 Learning: 2025-08-06T06:58:47.019Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3855
File: modules/new_serverpod_auth/serverpod_auth_apple_account/serverpod_auth_apple_account_server/lib/src/business/apple_accounts.dart:143-159
Timestamp: 2025-08-06T06:58:47.019Z
Learning: In the sign_in_with_apple_server package, the `decodeAppleServerNotification` method performs complete JWT signature verification against Apple's published public keys. It fetches keys from https://appleid.apple.com/auth/keys, validates the audience and issuer, and cryptographically verifies the JWT signature. This means webhook handlers using this method already have proper security against spoofed notifications without needing additional signature verification code.
Applied to files:
examples/auth/auth_server/lib/server.dart
🔇 Additional comments (3)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart (3)
15-20: LGTM!The
createChallengemethod correctly delegates to the underlying IDP implementation. Not requiring authentication is appropriate since challenges are needed before authentication can occur.
36-42: LGTM!The
loginmethod correctly delegates to the underlying IDP implementation and returns the authentication result. The implementation is straightforward and secure.
9-13: The original review comment is based on incorrect assumptions about Dart semantics and the existing error handling.The
AuthServices.getIdentityProvider<T>()method already provides a descriptiveStateErrormessage that clearly explains what went wrong and how to fix it: "Provider for $T is not registered. To register this provider, add its IdentityProviderFactory to the identityProviders list when calling AuthServices.set(). Example: AuthServices.set(defaultTokenManager: ..., identityProviders: [YourProviderFactory()])"Regarding override semantics: In Dart,
late finalfields can be overridden in subclasses by implementing a getter override. The documentation comment stating "If you want to use a different instance, override this getter" is accurate and follows standard Dart patterns.Likely an incorrect or invalid review comment.
15cb9f3 to
2279eb2
Compare
|
@coderabbitai Could you open an issue to address the missing tests in this PR. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 742 🏁 Script executed: Length of output: 50 @SandPod, I've created issue #4147 to track the missing test coverage: #4147 The issue identifies three components that need tests:
The issue has been assigned to you and includes backlinks to this PR and comment. 🧠 Learnings used |
nielsenko
left a comment
There was a problem hiding this comment.
Question regarding late
nielsenko
left a comment
There was a problem hiding this comment.
I have a few comments regarding how to avoid late final members that are initialized in the ctor anyway, and perhaps using User instead of trafficking in UuidValue for user id.
However, feel free to ignore them, if you disagree.
2279eb2 to
5798127
Compare
Moves the Passkey Identity provider to conform to the IDP pattern.
This PR does not include tests for the new methods because it was difficult to create new secrets.
A follow-up test PR will be added to address this.
Closes: #3856
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes
This includes breaking changes but only affects a non-published package.
Summary by CodeRabbit
New Features
Refactor