Repository navigation
feat(auth2): Add support for Google account in backwards compatibility package - #3778
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 change introduces and refactors logic to support backwards compatibility for Google account authentication in the Serverpod auth modules. It adds new methods for importing and cleaning up legacy Google account identifiers, modularizes Google account verification and linking logic into a new admin class, updates exports, and adjusts dependencies and test endpoints to integrate the new Google authentication features. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BackwardsCompatEndpoint as BackwardsCompatiblityGoogleAccountEndpoint
participant AuthBackCompat as AuthBackwardsCompatibility
participant GoogleBaseEndpoint as GoogleAccountBaseEndpoint
participant GoogleAdmin as GoogleAccountsAdmin
Client->>BackwardsCompatEndpoint: authenticate(idToken)
BackwardsCompatEndpoint->>AuthBackCompat: importGoogleAccount(session, idToken)
AuthBackCompat->>GoogleAdmin: fetchAccountDetails(session, idToken)
GoogleAdmin-->>AuthBackCompat: GoogleAccountDetails
AuthBackCompat->>GoogleAdmin: findUserByGoogleUserId(...)
GoogleAdmin-->>AuthBackCompat: userId or null
AuthBackCompat->>GoogleAdmin: linkGoogleAuthentication(...) (if legacy found)
GoogleAdmin-->>AuthBackCompat: GoogleAccount
AuthBackCompat->>AuthBackCompat: clearLegacyExternalUserIdentifier(...) (if needed)
BackwardsCompatEndpoint->>GoogleBaseEndpoint: authenticate(session, idToken)
GoogleBaseEndpoint-->>Client: AuthSuccess
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
49567af to
be3267f
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
modules/new_serverpod_auth/serverpod_auth_google_account/serverpod_auth_google_account_server/lib/src/business/google_accounts_admin.dart (1)
128-128: Email normalization already implemented.The email is correctly normalized to lowercase as previously suggested.
🧹 Nitpick comments (5)
tests/serverpod_new_auth_test/serverpod_new_auth_test_flutter/pubspec.yaml (1)
25-25: Version range forflutter_lintsmay be too permissive
>=3.0.0 <7.0.0accepts yet-to-be-released major versions that could introduce breaking rules and make the analysis unstable. Consider capping at the latest tested major (<4.0.0or similar) unless you have automatic rule suppression in place.modules/new_serverpod_auth/serverpod_auth_google/serverpod_auth_google_server/lib/serverpod_auth_google_server.dart (1)
1-1: Publicly exporting the base endpoint widens API surface
Exportinggoogle_account_base_endpoint.dartis convenient but exposes low-level classes to end-users. If the intent is only subclassing inside test code, consider re-exporting withshow GoogleAccountBaseEndpoint(or placing it undersrc/internal) to keep the public API minimal.tests/serverpod_new_auth_test/serverpod_new_auth_test_server/lib/src/endpoints/google_account_endpoint.dart (1)
1-4: Endpoint stub is fine but add registration comment or remove if unusedThe endpoint simply subclasses
GoogleAccountBaseEndpointwithout additional logic, which is perfectly valid.
However, an empty endpoint typically exists only to be registered inServer.endpoints. Consider adding a comment that clarifies this intent or remove the class if registration is handled elsewhere to avoid dead code confusion.templates/pubspecs/tests/serverpod_new_auth_test/serverpod_new_auth_test_server/pubspec.yaml (1)
37-40: Duplicate Google overrides between server & clientBoth test server and test client override the same Google packages with local paths.
To avoid mismatch, extract these overrides into the rootdependency_overrides:of the mono-repo or a shared include, otherwise one file might drift.templates/pubspecs/tests/serverpod_new_auth_test/serverpod_new_auth_test_client/pubspec.yaml (1)
23-34: Keep override list minimalMany overrides added but not listed in
dependencies:(e.g.,serverpod_auth_google_account_client).
If they aren’t imported by tests, the override is redundant noise—consider pruning.
be3267f to
69a649d
Compare
Adds support for importing Google user identifiers from the legacy auth system, linking the external ID to an existing auth user upon their first Google-based login through the new endpoint.
Relates to #3661
Summary by CodeRabbit
New Features
Refactor
Documentation
Chores