Repository navigation
feat: Add serverpod_auth_idp_flutter with Google Sign-In IDP implementation - #4150
marcelomendoncasoares merged 22 commits into
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 PR introduces a new Flutter package Changes
Sequence Diagram(s)sequenceDiagram
participant App as Flutter App
participant Ctrl as GoogleAuthController
participant GIS as GoogleSignInService
participant Endpoint as Google IDP Endpoint
participant Verifier as GoogleIdTokenVerifier
participant Server as Serverpod Server
App->>Ctrl: signIn()
Ctrl->>GIS: ensureInitialized()
GIS->>GIS: GoogleSignIn.initialize()
Ctrl->>Ctrl: _handleAuthenticationEvent()
Ctrl->>Endpoint: login(idToken, accessToken)
Endpoint->>Server: Call server endpoint
Server->>Verifier: verifyOAuth2Token(idToken)
Verifier->>Verifier: Fetch JWKS, verify signature
Verifier->>Server: Return token payload
Server->>Server: Fetch user info (via accessToken)
Server->>Server: Create/update user session
Server->>Endpoint: Return AuthSuccess
Endpoint->>Ctrl: onAuthenticated callback
Ctrl->>App: Update state to authenticated
sequenceDiagram
participant UI as UI Layer
participant SignInWidget as SignInWidget
participant AvailableIDPs as AvailableIDPs
participant Endpoint as Server Endpoint
UI->>SignInWidget: render(client)
SignInWidget->>AvailableIDPs: check provider availability
AvailableIDPs->>Endpoint: reflect() inspect endpoints
Endpoint->>AvailableIDPs: return endpoint metadata
AvailableIDPs->>SignInWidget: hasGoogle=true, hasEmail=false
SignInWidget->>UI: render GoogleSignInWidget only
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (4 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 |
|
@coderabbitai full review. |
|
@marcelomendoncasoares: I'll perform a full review of the PR changes for the new 🧠 Learnings used✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 9
🧹 Nitpick comments (8)
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google/business/google_idp_config.dart (1)
69-77: LGTM! Correct type safety fix for JSON deserialization.The change from
as List<String>?toas List<dynamic>?with a subsequent.cast<String>()correctly handles JSON deserialization in Dart, where arrays are decoded asList<dynamic>rather than typed lists. This fix ensures the code passes strict Dart analysis.Optional: Consider more explicit validation for consistency.
For consistency with other validation in this method that throws
FormatException, you could optionally add explicit element validation before casting:final webRedirectUris = web['redirect_uris'] as List<dynamic>?; if (webRedirectUris == null) { throw const FormatException('Missing "redirect_uris"'); } if (webRedirectUris.any((uri) => uri is! String)) { throw const FormatException('Invalid "redirect_uris": all elements must be strings'); } return GoogleClientSecret._( clientId: webClientId, clientSecret: webClientSecret, redirectUris: webRedirectUris.cast<String>(), );This would provide more consistent error messages, though the current approach is acceptable since
.cast<String>()will throw a clear error if non-string elements are present.modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/README.md (1)
1-9: Consider adding package-specific documentation.The README contains generic Serverpod boilerplate but doesn't describe what the
serverpod_auth_idp_flutterpackage provides (e.g., Flutter widgets for Google Sign-In and other identity providers). Package-specific documentation would help developers understand the purpose and usage of this package.modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/web/index.html (2)
23-25: Consider documenting the Google client ID setup requirement.The placeholder
GOOGLE_CLIENT_ID.apps.googleusercontent.comin the meta tag will likely cause Google Sign-In to fail at runtime if not replaced. While the comment instructs developers to replace this value, consider:
- Adding a more prominent warning or error handling when the placeholder is detected
- Documenting the setup steps in a README for the storybook app
- Potentially using an environment variable or configuration file approach
21-21: Consider updating the meta description.The generic description "A new Flutter project" could be more specific, such as "Serverpod Auth IDP Flutter Storybook - UI component examples for Google Sign-In integration."
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/web/manifest.json (1)
8-8: Consider a more descriptive description.The description "A new Flutter project." is generic. Consider something more specific like "Serverpod Auth IDP Storybook - Component showcase for authentication widgets."
modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/common/widgets/column.dart (1)
24-27: Clarify the assertion error message.The assertion checks
width > 0, which excludes 0, but the error message says "between 0 and 400" which could be interpreted as including 0. Consider making the message more explicit.Apply this diff to clarify the message:
}) : assert( width > 0 && width <= 400, - 'Invalid width. Must be between 0 and 400.', + 'Invalid width. Must be greater than 0 and at most 400.', );examples/auth/auth_flutter/lib/widgets/profile_picture.dart (1)
29-29: Consider increasing the default size.The default size of
20.0seems quite small for a profile picture. Typical profile pictures are usually at least 40-50 pixels to be clearly visible.- this.size = 20.0, + this.size = 40.0,modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart (1)
89-89: Separator condition is currently unreachable.The separator on line 89 will never render because:
- The email widget above it is commented out
- Without the email widget, the separator doesn't make sense visually
- The condition requires both
count > 1andhasEmail, but no email UI is presentThis is expected given the TODO comments, but consider removing this line until the email widget is implemented to avoid confusion.
- if (auth.idp.count > 1 && auth.idp.hasEmail) const _SignInSeparator(), + // TODO: Add separator when email widget is implemented + // if (auth.idp.count > 1 && auth.idp.hasEmail) const _SignInSeparator(),
0332c79 to
507268f
Compare
SandPod
left a comment
There was a problem hiding this comment.
Minor comments + last suggestions from our call.
…oogle-idp-flutter
Closes #3646.
Closes #3451.
This package introduces the
serverpod_auth_idp_flutterpackage, which provides Flutter widgets for integrating third-party identity providers (IdPs). The initial release includes only Google Sign-In support.To develop and test IDP widgets, the package contains a
storybookapp that demonstrates the available widgets and their configurations.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
None.
Summary by CodeRabbit
New Features
Documentation
Chores