Repository navigation
feat: Add GitHub identity provider support - #4546
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
93d48f0 to
31a2cfd
Compare
|
I have read the CLA Document and I hereby sign the CLA |
|
Hi @vfiruz97! Thank you for your contribution to add more IDP providers! We usually have CodeRabbit review community PRs before manual review. So I'll trigger it on this PR and ask you to please address its first comments. When done, ensure that the CI is passing and then ping me for a manual review. |
|
@coderabbitai Full review. |
🧩 Analysis chain@marcelomendoncasoares: I'll conduct a full review of this PR. Let me gather the necessary information about the changes. 🏁 Script executed: Length of output: 2597 🏁 Script executed: Length of output: 666 🏁 Script executed: Length of output: 434 🏁 Script executed: Length of output: 238 🏁 Script executed: Length of output: 202 🏁 Script executed: Length of output: 184 🏁 Script executed: Length of output: 166 🏁 Script executed: Length of output: 473 🏁 Script executed: Length of output: 3243 🏁 Script executed: Length of output: 1246 🏁 Script executed: Length of output: 1520 🏁 Script executed: Length of output: 2532 🏁 Script executed: Length of output: 4722 🏁 Script executed: Length of output: 6205 🏁 Script executed: Length of output: 5061 🏁 Script executed: Length of output: 6868 🏁 Script executed: Length of output: 1528 🏁 Script executed: Length of output: 4171 🏁 Script executed: Length of output: 9071 🏁 Script executed: Length of output: 8875 🏁 Script executed: Length of output: 20873 🏁 Script executed: Length of output: 160 🏁 Script executed: Length of output: 678 🏁 Script executed: Length of output: 31 🏁 Script executed: Length of output: 1659 🏁 Script executed: Length of output: 1255 🏁 Script executed: Length of output: 3641 🏁 Script executed: Length of output: 4970 🏁 Script executed: Length of output: 3410 🏁 Script executed: Length of output: 16532 🏁 Script executed: Length of output: 1429 🏁 Script executed: Length of output: 231 🏁 Script executed: Length of output: 1909 🏁 Script executed: Length of output: 215 🏁 Script executed: Length of output: 92 🏁 Script executed: Length of output: 287 🏁 Script executed: Length of output: 1321 🏁 Script executed: Length of output: 56 🏁 Script executed: Length of output: 44 🏁 Script executed: Length of output: 65 🏁 Script executed: Length of output: 326 🏁 Script executed: Length of output: 109 🏁 Script executed: Length of output: 1707 🏁 Script executed: Length of output: 677 🏁 Script executed: Length of output: 871 🏁 Script executed: Length of output: 1325 🏁 Script executed: Length of output: 190 🏁 Script executed: Length of output: 1348 🏁 Script executed: Length of output: 49 🏁 Script executed: Length of output: 36 🏁 Script executed: Length of output: 1972 🏁 Script executed: Length of output: 43 🏁 Script executed: Length of output: 334 🏁 Script executed: Length of output: 34 🏁 Script executed: Length of output: 232 🏁 Script executed: Length of output: 48 🏁 Script executed: Length of output: 4469 🏁 Script executed: Length of output: 3413 🏁 Script executed: Length of output: 42 🏁 Script executed: Length of output: 1205 🏁 Script executed: Length of output: 316 🏁 Script executed: Length of output: 272 🏁 Script executed: Length of output: 409 🏁 Script executed: Length of output: 219 🏁 Script executed: Length of output: 5644 🏁 Script executed: Length of output: 122 🏁 Script executed: Length of output: 315 🏁 Script executed: Length of output: 3307 🏁 Script executed: Length of output: 4381 🏁 Script executed: Length of output: 40 🏁 Script executed: Length of output: 176 🏁 Script executed: Length of output: 877 🏁 Script executed: Length of output: 110 @marcelomendoncasoares: I've completed a comprehensive review of this GitHub IDP implementation. This is a well-structured contribution that follows the existing patterns in the codebase. However, I've identified several issues that should be addressed before merging. Critical Issues1. Import Pattern Inconsistency ❌Location: The GitHub endpoint uses relative imports: import '../../../../../core.dart';However, according to the codebase pattern (Apple, Google endpoints), it should use package imports: import 'package:serverpod_auth_idp_server/core.dart';Apple endpoint for comparison: import 'package:serverpod/serverpod.dart';
import 'package:serverpod_auth_idp_server/core.dart';
import '../business/apple_idp.dart';This is consistent across all other IDP endpoints in the codebase. Security Concerns2. State Parameter Not Validated 🔒Location: The implementation generates a 'state': _generateState(),However, there's no validation of this state parameter when the OAuth callback returns. This defeats the purpose of CSRF protection. The state should be:
Recommendation: Either implement proper state validation or remove it entirely if relying on PKCE alone for security (which may be acceptable since PKCE provides protection). 3. No Redirect URI Validation 🔒The Test Coverage Issues4. Insufficient Test Coverage
|
📝 WalkthroughWalkthroughGitHub OAuth sign-in support is added across Serverpod modules. The implementation includes server-side identity provider logic with token exchange and account linking, Flutter client libraries for authentication state management and UI components, configuration support with password-based credentials, and supporting tests and storybook examples. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Flutter App
participant GitHubSignInService
participant FlutterWebAuth2
participant GitHub OAuth
participant Callback Handler
User->>Flutter App: Tap GitHub Sign In
Flutter App->>GitHubSignInService: signIn(scopes)
GitHubSignInService->>GitHubSignInService: Generate PKCE verifier & challenge
GitHubSignInService->>GitHubSignInService: Generate state
GitHubSignInService->>FlutterWebAuth2: startWebAuthenticationFlow(url, callbackUrlScheme)
FlutterWebAuth2->>GitHub OAuth: Open authorization URL
GitHub OAuth->>User: Show login & permission screen
User->>GitHub OAuth: Authorize
GitHub OAuth->>Callback Handler: Redirect with code & state
Callback Handler->>FlutterWebAuth2: Return authorization code
FlutterWebAuth2->>GitHubSignInService: Return authorization code
GitHubSignInService->>Flutter App: Return code
sequenceDiagram
participant GitHubAuthController
participant GitHubSignInService
participant Server
participant GitHubIdpBase
participant GitHubIdpUtils
participant Database
GitHubAuthController->>GitHubAuthController: setState(loading)
GitHubAuthController->>GitHubSignInService: signIn()
GitHubSignInService->>GitHubAuthController: Return authorization code
GitHubAuthController->>Server: _handleServerSideSignIn(code)
Server->>GitHubIdpBase: login(code, codeVerifier, redirectUri)
GitHubIdpBase->>GitHubIdpUtils: exchangeCodeForToken(code, codeVerifier, redirectUri)
GitHubIdpUtils->>GitHub API: POST /login/oauth/access_token
GitHub API->>GitHubIdpUtils: access_token
GitHubIdpUtils->>GitHubIdpUtils: authenticate(accessToken)
GitHubIdpUtils->>GitHub API: GET /user
GitHub API->>GitHubIdpUtils: account details
GitHubIdpUtils->>Database: Find or create GitHubAccount
Database->>GitHubIdpUtils: GitHubAccount
GitHubIdpUtils->>Database: Find or create AuthUser
Database->>GitHubIdpUtils: AuthUser
GitHubIdpUtils->>GitHubAuthController: AuthSuccess
GitHubAuthController->>GitHubAuthController: setState(authenticated)
GitHubAuthController->>GitHubAuthController: onAuthenticated()
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (2)
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 |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Fix all issues with AI agents
In
@modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart:
- Around line 114-171: The signIn method generates a state with _generateState()
but never validates it; store the generated state in an instance field (e.g.,
_state) before building the authorization URL and then, after receiving the
callback (inside signIn where you parse Uri.parse(result)), compare
uri.queryParameters['state'] to the stored _state and throw a
StateError/Exception if they don't match; ensure you clear or rotate _state
after validation to avoid reuse.
In
@modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dart:
- Around line 103-111: The constructor assertion currently allows both
controller and client to be null; change the condition to require exactly one of
them be provided (i.e., enforce that one is non-null and the other is null) and
update the assertion message accordingly so accesses like widget.client! are
safe; target the constructor in github_sign_in_widget.dart and replace the
existing `(controller == null || client == null)` check with a strict exclusive
check (one non-null, one null) and a clear error message stating that exactly
one of controller or client must be supplied.
- Around line 29-33: The doc comment for GitHubSignInWidget contains a malformed
code block for the second example; add the missing opening triple-backtick doc
marker before the "GitHubSignInWidget(" example so the block is well-formed
(i.e., insert a line with "/// ```" immediately before the example, and include
the suggested "Example with external controller:" comment), updating the
docstring surrounding the GitHubSignInWidget declaration to match the proposed
fix.
In
@modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart:
- Line 3: The import in github_idp_base_endpoint.dart uses a relative path
('../../../../../core.dart'); replace it with the package import style used
elsewhere: import 'package:serverpod_auth_idp_server/core.dart'; update the top
of the file where the import appears (in the github_idp_base_endpoint.dart
module) so the endpoint base class uses the package import convention consistent
with Apple, Email, and Google endpoints.
In
@modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart:
- Around line 127-149: The withServerpod test group is empty (no test() calls)
despite a setUp that creates an auth user and inserts a GitHubAccount via
GitHubAccount.db.insertRow after calling authUsers.create; either add concrete
test cases (e.g., use test() to assert unlinking, querying, or expected
behaviors against the created authUserId/GitHubAccount) within the withServerpod
block using the session built by sessionBuilder.build(), or remove the entire
withServerpod block and its setUp if it is unused scaffolding.
🧹 Nitpick comments (5)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart (1)
3-6: Consider using package import forcore.dart.The relative import
'../../../../../core.dart'traverses five directory levels, which can be fragile during refactoring. Based on learnings from this repo, using the package import pattern is preferred for core module access:-import '../../../../../core.dart'; +import 'package:serverpod_auth_idp_server/core.dart';The relative imports for sibling files (
github_idp_admin.dart, etc.) are fine since they're within the same provider directory.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart (1)
95-129: Consider consolidating duplicate extension methods.The six nearly-identical
asOptions()extension methods could be consolidated into a single generic extension:♻️ Optional: Generic extension to reduce duplication
extension EnumListToOptions<T extends Enum> on List<T> { List<Option<T>> asOptions() { return map((e) => Option(label: e.name, value: e)).toList(); } }This would replace all six extensions. However, since this is storybook code and the current approach is explicit and readable, this is a nice-to-have refinement.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart (2)
81-94: HTTP request lacks timeout configuration.The POST request to GitHub's token endpoint has no timeout, which could cause the request to hang indefinitely if GitHub is unresponsive. Consider adding a timeout.
♻️ Suggested improvement
- final response = await http.post( - Uri.https('github.com', '/login/oauth/access_token'), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - }, - body: jsonEncode({ - 'client_id': config.oauthCredentials.clientId, - 'client_secret': config.oauthCredentials.clientSecret, - 'code': code, - 'redirect_uri': redirectUri, - 'code_verifier': codeVerifier, - }), - ); + final response = await http + .post( + Uri.https('github.com', '/login/oauth/access_token'), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: jsonEncode({ + 'client_id': config.oauthCredentials.clientId, + 'client_secret': config.oauthCredentials.clientSecret, + 'code': code, + 'redirect_uri': redirectUri, + 'code_verifier': codeVerifier, + }), + ) + .timeout(const Duration(seconds: 30));
197-204: HTTP request lacks timeout configuration.Same as the token exchange endpoint, the GET request to GitHub's user API should have a timeout to prevent indefinite hangs.
♻️ Suggested improvement
- final response = await http.get( - Uri.https('api.github.com', '/user'), - headers: { - 'Authorization': 'Bearer $accessToken', - 'Accept': 'application/vnd.github+json', - 'X-GitHub-Api-Version': '2022-11-28', - }, - ); + final response = await http + .get( + Uri.https('api.github.com', '/user'), + headers: { + 'Authorization': 'Bearer $accessToken', + 'Accept': 'application/vnd.github+json', + 'X-GitHub-Api-Version': '2022-11-28', + }, + ) + .timeout(const Duration(seconds: 30));modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart (1)
64-71:read:userscope is redundant.According to GitHub's OAuth scopes documentation, the
userscope grants read/write access to profile information and implicitly includesuser:email. Theread:userscope only grants read-only access to profile data, making it redundant whenuseris already present.♻️ Suggested simplification
- static const List<String> defaultScopes = ['user', 'user:email', 'read:user']; + static const List<String> defaultScopes = ['user', 'user:email'];
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (17)
examples/auth/auth_client/lib/src/protocol/client.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.yamlis excluded by!**/generated/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/client.dartis excluded by!**/lib/src/protocol/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/protocol.dartis excluded by!**/lib/src/protocol/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/providers/github/models/github_access_token_verification_exception.dartis excluded by!**/lib/src/protocol/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/assets/images/github-mark-white.svgis excluded by!**/*.svgmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/assets/images/github-mark.svgis excluded by!**/*.svgmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/protocol.dartis excluded by!**/generated/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_access_token_verification_exception.dartis excluded by!**/generated/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_account.dartis excluded by!**/generated/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition.jsonis excluded by!**/migrations/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition.sqlis excluded by!**/migrations/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition_project.jsonis excluded by!**/migrations/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/migration.jsonis excluded by!**/migrations/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/migration.sqlis excluded by!**/migrations/**modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/migration_registry.txtis excluded by!**/migrations/**
📒 Files selected for processing (28)
examples/auth/auth_server/config/template.passwords.yamlexamples/auth/auth_server/lib/server.dartexamples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_access_token_verification_exception.spy.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartpubspec.yamltemplates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.dart: Follow Dart formatting conventions with dart format command
Run 'dart format .' to format all code before committing
Run 'melos lint_strict' or 'util/run_tests_analyze' to check code quality before committing, ensuring compliance with CI strict mode
Files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dartexamples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dartexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart
**/*test.dart
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*test.dart: When using group() with test(), ensure each statement ('Given', 'When', 'Then') appears only once in the combined description to avoid duplication
Place passing/success test cases at the top of test files before error test cases for the same functionality
Group related test cases using group() where appropriate
Files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
🧠 Learnings (26)
📓 Common learnings
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.
Learnt from: tp
Repo: serverpod/serverpod PR: 3777
File: modules/new_serverpod_auth/serverpod_auth_google_account/serverpod_auth_google_account_server/lib/src/business/google_accounts.dart:126-138
Timestamp: 2025-07-10T12:33:42.871Z
Learning: In Serverpod Google authentication, tp prefers a flexible field validation approach: only require user ID always, require email only on first-time sign-ups (and make this configurable), and make other profile fields optional. If apps don't want to collect emails, the system shouldn't rely on the verified_email attribute. This allows apps to have configurable data collection policies.
Learnt from: SandPod
Repo: serverpod/serverpod PR: 4144
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart:0-0
Timestamp: 2025-11-03T15:40:41.827Z
Learning: In Serverpod authentication IDP endpoint files (modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server), endpoint base classes should import `serverpod_auth_idp_server/core.dart` to access the Session type, rather than importing `package:serverpod_auth_core_server/session.dart` directly. This pattern is consistently used in Apple, Email, and Google endpoint files.
📚 Learning: 2025-11-03T15:40:41.827Z
Learnt from: SandPod
Repo: serverpod/serverpod PR: 4144
File: modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/passkey/endpoints/passkey_idp_base_endpoint.dart:0-0
Timestamp: 2025-11-03T15:40:41.827Z
Learning: In Serverpod authentication IDP endpoint files (modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server), endpoint base classes should import `serverpod_auth_idp_server/core.dart` to access the Session type, rather than importing `package:serverpod_auth_core_server/session.dart` directly. This pattern is consistently used in Apple, Email, and Google endpoint files.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.darttemplates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dartexamples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dartexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart
📚 Learning: 2025-07-24T13:46:05.689Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3824
File: packages/serverpod/lib/src/authentication/authentication_info.dart:21-34
Timestamp: 2025-07-24T13:46:05.689Z
Learning: In Serverpod's AuthenticationInfo class, the `userId` getter is being kept temporarily for legacy support with packages that use `int` user IDs, but will be removed in a future PR. The `userIdentifier` field now supports UUID strings for new auth modules, representing the planned migration from int-based to UUID-based user identification.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml
📚 Learning: 2025-07-10T12:33:42.871Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3777
File: modules/new_serverpod_auth/serverpod_auth_google_account/serverpod_auth_google_account_server/lib/src/business/google_accounts.dart:126-138
Timestamp: 2025-07-10T12:33:42.871Z
Learning: In Serverpod Google authentication, tp prefers a flexible field validation approach: only require user ID always, require email only on first-time sign-ups (and make this configurable), and make other profile fields optional. If apps don't want to collect emails, the system shouldn't rely on the verified_email attribute. This allows apps to have configurable data collection policies.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml
📚 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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Applies to **/*test.dart : Group related test cases using group() where appropriate
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.darttemplates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
📚 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:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.darttemplates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dartpubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
📚 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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
📚 Learning: 2025-06-19T11:00:17.085Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3651
File: tests/serverpod_new_auth_test/serverpod_new_auth_test_server/test/integration/email_account_endpoint_test.dart:1-1
Timestamp: 2025-06-19T11:00:17.085Z
Learning: In Serverpod applications, methods that rely on public asset storage (like setUserImage/removeUserImage) should be tested in E2E tests rather than withServerpod integration tests, as they require a full server environment with asset storage infrastructure to properly test image upload/download functionality.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
📚 Learning: 2025-11-04T12:09:52.649Z
Learnt from: marcelomendoncasoares
Repo: serverpod/serverpod PR: 4150
File: examples/auth/auth_flutter/lib/widgets/profile_info.dart:23-30
Timestamp: 2025-11-04T12:09:52.649Z
Learning: In Serverpod example and testing projects (e.g., examples/auth/auth_flutter), prefer letting errors bubble up naturally rather than handling them gracefully with catchError or try-catch blocks. This helps developers see what went wrong during development and testing.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Verify example projects still work before submitting PR by running example servers with 'dart bin/main.dart --apply-migrations'
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
📚 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:
templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dartexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart
📚 Learning: 2025-06-27T08:39:36.440Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: util/pub_get_all:0-0
Timestamp: 2025-06-27T08:39:36.440Z
Learning: In the Serverpod project, `dart pub get` commands work fine on Flutter packages both locally and in CI environments, even when the package has `flutter: sdk: flutter` dependencies in pubspec.yaml. The technical constraint of Flutter SDK dependencies causing `dart pub` failures may not apply in all environments or recent Dart versions.
Applied to files:
templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartpubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
📚 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:
templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dartexamples/auth/auth_server/lib/server.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dartpubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Activate serverpod_cli from source using 'dart pub global activate --source path tools/serverpod_cli' after installation for development
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.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:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartexamples/auth/auth_server/lib/server.dartpubspec.yamlmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dartmodules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dartexamples/auth/auth_server/lib/server.dart
📚 Learning: 2025-12-11T03:56:54.151Z
Learnt from: CR
Repo: serverpod/serverpod PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-11T03:56:54.151Z
Learning: Applies to **/*test.dart : When using group() with test(), ensure each statement ('Given', 'When', 'Then') appears only once in the combined description to avoid duplication
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
📚 Learning: 2025-06-27T07:44:09.048Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3721
File: modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_flutter/test/serverpod_auth_session_flutter_test.dart:1-7
Timestamp: 2025-06-27T07:44:09.048Z
Learning: In Serverpod packages, the `uuid` package is re-exported through a chain: `serverpod_auth_session_client` re-exports `serverpod_client`, which re-exports `serverpod_serialization`, which re-exports `uuid`. This means `Uuid` class is available in files that import `serverpod_auth_session_client` without needing a direct `uuid` package import.
Applied to files:
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.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.dartpubspec.yaml
📚 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/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
📚 Learning: 2025-06-17T11:44:37.288Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3666
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_client/CHANGELOG.md:1-7
Timestamp: 2025-06-17T11:44:37.288Z
Learning: The util/update_pubspecs script automatically copies the root CHANGELOG.md to all packages/modules and README_subpackage.md to all modules as README.md. These file changes should be ignored during code review as they are auto-generated distribution of shared content, not manual authoring that requires review.
Applied to files:
pubspec.yaml
📚 Learning: 2025-06-17T11:44:37.288Z
Learnt from: tp
Repo: serverpod/serverpod PR: 3666
File: modules/new_serverpod_auth/serverpod_auth_migration/serverpod_auth_migration_client/CHANGELOG.md:1-7
Timestamp: 2025-06-17T11:44:37.288Z
Learning: Changes to README.md and CHANGELOG.md files made by the util/update_pubspecs script can be safely ignored during code review, as these files are auto-generated by copying from a single source rather than being manually authored.
Applied to files:
pubspec.yaml
🪛 GitHub Actions: Serverpod CI
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_access_token_verification_exception.spy.yaml
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
[error] 157-157: Failed to connect to the database. SocketException: Connection refused (OS Error: Connection refused, errno = 111)
pubspec.yaml
[warning] 1-1: Package validation found 3 potential issues: dependencies on serverpod, serverpod_auth_server, and serverpod_serialization are too tightly constrained.
[warning] 1-1: Package validation found 2 potential issues: dependencies on serverpod_auth_client and serverpod_client should allow more than one version.
[warning] 1-1: Package validation found 4 potential issues: dependencies on serverpod_auth_client, serverpod_auth_shared_flutter, serverpod_chat_client, and an upper Flutter constraint with an upper bound. Also 2 hints present.
🪛 Gitleaks (8.30.0)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
[high] 234-234: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (41)
examples/auth/auth_server/lib/server.dart (2)
47-52: LGTM! GitHub IdP configuration follows established patterns.The configuration properly retrieves OAuth credentials from the password store and constructs the GitHubIdpConfig. The approach is consistent with other identity providers in this file.
81-81: LGTM! Provider registration is correct.The GitHub IdP config is properly registered in the identityProviderBuilders list, enabling the GitHub authentication flow.
examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart (1)
1-3: LGTM! Endpoint implementation follows established patterns.This endpoint correctly extends GitHubIdpBaseEndpoint and uses package imports, consistent with other identity provider endpoints in the Serverpod authentication system.
templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml (2)
15-15: Be aware the crypto package lacks professional security review.The constraint ^3.0.2 is appropriate and will allow automatic updates through patch versions (currently up to 3.0.7). However, the crypto package explicitly states it "has not been reviewed or vetted by security professionals." For an authentication library, this limitation should be documented and considered in your security model.
22-22: flutter_web_auth_2 is current and has no known security vulnerabilities.The package version 4.1.0 (latest, published 2024-11-29) matches the ^4.1.0 constraint. No publicly disclosed CVEs or security advisories exist for this package.
examples/auth/auth_server/config/template.passwords.yaml (1)
44-46: LGTM! GitHub credentials configuration follows established pattern.The GitHub OAuth credential placeholders are correctly structured and consistent with other identity providers in the configuration file.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart (1)
8-8: LGTM! Storybook integration correctly mirrors existing provider patterns.The GitHub sign-in initialization and story integration follow the same structure as Google and Apple providers, ensuring consistency across the storybook setup.
Also applies to: 21-21, 50-50
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_access_token_verification_exception.spy.yaml (1)
1-5: LGTM! Security-conscious exception design.The exception definition appropriately avoids exposing failure details to prevent information leakage to potential attackers. This follows security best practices for authentication systems.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart (2)
86-100: LGTM! Missing credential test follows established pattern.The test correctly verifies that
GitHubIdpConfigFromPasswordsthrowsPasswordNotFoundExceptionwhengithubClientIdis missing, consistent with other identity provider tests.
219-260: LGTM! Successful configuration test is well-structured.The test correctly verifies that
GitHubIdpConfigFromPasswordssucceeds when both required credentials are present, following the same pattern as other provider tests.Note: The static analysis warning on line 234 is a false positive—the value is clearly test fixture data in a test file.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart (1)
35-40: LGTM! GitHub widget disable story follows existing pattern.The new story and parameter for disabling the GitHub sign-in widget are correctly implemented and consistent with the existing Email, Google, and Apple provider stories.
Also applies to: 48-48, 63-63
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart (1)
27-28: LGTM!The
hasGitHubgetter follows the same pattern as other identity providers (hasEmail,hasGoogle,hasApple), and thecountgetter correctly includes the new provider.Also applies to: 38-40
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart (1)
18-22: LGTM!The GitHub provider exports are complete and follow the established pattern for other identity providers. The alphabetical ordering within the provider sections maintains consistency.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart (1)
151-165: LGTM!The mock
GitHubIdpEndpointfollows the same pattern asGoogleIdpEndpointandAppleIdpEndpoint, providing appropriate storybook/testing behavior. The endpoint is correctly wired into theClientclass and lookup map.Also applies to: 186-186, 196-196, 205-205
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart (1)
1-133: LGTM!The styling configuration is comprehensive and well-documented. The GitHub brand color (
0xFF24292F) is correctly applied, and the factory constructor cleanly maps configuration options to concrete style properties using switch expressions.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart (1)
69-148: LGTM!The
loginmethod has solid structure:
- Uses transactional context for atomic operations
- Logs errors with stack traces for non-critical failures (profile creation/image updates)
- Allows critical errors (token exchange, authentication) to propagate appropriately
The error handling strategy—catching profile-related failures while letting authentication errors bubble up—is a sensible design choice for maintaining login reliability.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart (1)
29-41: LGTM!The
loginmethod properly delegates to theGitHubIdpinstance with all required PKCE parameters. The documentation template ({@template}) enables consistent documentation across implementations.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart (3)
1-60: Well-structured button widget with proper validation.The constructor properly validates
minimumWidthbounds via assertion and provides sensible defaults. The required parameters (onPressed,isLoading,isDisabled) ensure the button state is always explicitly managed by the parent widget.
61-100: Button styling and state handling looks correct.The
buildmethod correctly:
- Derives style configuration from the shape/size/style/width parameters
- Disables the button when loading or disabled via
onPressed: isLoading || isDisabled ? null : onPressed- Applies conditional border side for white style buttons
- Uses
withValues(alpha: 0.6)for disabled state colors
102-176: Content and logo rendering implementation is clean.The helper methods properly handle:
- Loading state with appropriately sized
CircularProgressIndicator- Icon-only vs standard button layouts
- Left vs center logo alignment with proper spacing
- Correct SVG asset selection based on button style (dark logo for white background, white logo for black background)
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart (2)
6-55: Clean admin facade with appropriate delegation.The
GitHubIdpAdminclass provides a clean public API:
fetchAccountDetailsandlinkGitHubAuthenticationproperly delegate to the injectedutilsinstancefindUserByGitHubUserIdis correctly static since it only performs a DB lookup without needing utilsThe pipeline failure (
Failed to connect to the database) is a CI infrastructure issue, not a code defect.
1-4: > Likely an incorrect or invalid review comment.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml (1)
1-30: Well-designed model with appropriate constraints.The schema is well-structured:
- Uses UUID-based identification (
UuidValue?withrandom_v7) aligning with Serverpod's migration to UUID-based user IDs- Cascade delete on
authUserrelation ensures orphaned GitHub accounts are cleaned up- Unique index on
userIdentifierprevents duplicate GitHub account registrationsOne consideration: if reverse lookups by
authUserIdare common (e.g., "find GitHub account for this user"), an additional index onauthUserIdcould improve query performance. The cascade relation may handle this, but worth verifying the generated code.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart (1)
1-14: Appropriate public API surface for GitHub IdP provider.The exports correctly expose:
AuthSuccessfrom core for authentication result handlingGitHubAccountandGitHubAccessTokenVerificationExceptionfor consumer use- All necessary business logic and endpoint classes
This follows the established pattern where high-level packages re-export their dependencies so consumers only need a single import. Based on learnings, this aligns with Serverpod conventions.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart (2)
67-69: GitHub sign-in integration follows established patterns.The new fields and constructor parameters for GitHub sign-in (
disableGitHubSignInWidget,githubSignInWidget) mirror the existing Google and Apple patterns exactly, maintaining API consistency.Also applies to: 79-81, 90-90, 94-94
108-108: GitHub provider wiring is correctly implemented.The
hasGitHubgetter and the conditional rendering insocialProvidersfollow the same pattern used for Google sign-in. The widget correctly falls back to a defaultGitHubSignInWidgetwhen no custom widget is provided.Also applies to: 131-138
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart (1)
6-91: Comprehensive storybook coverage for GitHub button.The stories provide good visual testing for:
- Button Styles: All customization knobs (style, size, shape, text, logo alignment, type)
- Button States: Idle, Loading, and Disabled states
This enables visual regression testing and design review.
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart (4)
31-42: Singleton pattern with proper initialization tracking.The singleton implementation with
_initializedflag ensures idempotent configuration. The private fields for OAuth configuration are appropriately encapsulated.
210-222: PKCE implementation is correct.The code verifier generation uses
Random.secure()with 32 bytes (256 bits) of entropy, and the SHA-256 challenge is properly base64url-encoded with padding removed per RFC 7636.
174-208: Extension provides clean integration point.The extension on
FlutterAuthSessionManagerprovides a convenient way to initialize GitHub sign-in through the existing auth session manager, following the pattern likely used by other providers.
224-229: State generation helper is unused effectively.As noted above,
_generateState()generates a proper CSRF token but the returned state is never validated. This function should either be removed or its output should be stored and validated.⛔ Skipped due to learnings
Learnt from: marcelomendoncasoares Repo: serverpod/serverpod PR: 0 File: :0-0 Timestamp: 2026-01-08T14:55:06.450Z Learning: In GitHub OAuth implementations using PKCE, the state parameter for CSRF protection is optional since PKCE provides CSRF protection. According to OAuth 2.0 Security Best Current Practice (RFC 9700), clients that have ensured the authorization server supports PKCE may rely on PKCE for CSRF protection and use the state parameter for application state instead.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dart (1)
117-161: LGTM!The state class properly manages the controller lifecycle, correctly disposing only internally-created controllers and using the listener pattern appropriately for
ChangeNotifier.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart (3)
106-120: LGTM!The sign-in flow correctly initiates the OAuth process and delegates to server-side handling. Error handling properly catches and processes exceptions.
189-213: LGTM!The error conversion logic appropriately distinguishes between user-facing errors and internal errors that should only be logged. Suppressing
StateErrorfor end users while logging them for debugging is a sensible pattern.
93-97: LGTM!Proper disposal pattern with the
_disposedflag preventing notifications after disposal.Also applies to: 165-171
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart (3)
133-181: LGTM!The authentication flow correctly handles both new and existing users, properly using transactions and the switch expression for clarity.
243-267: LGTM!Proper handling of GitHub's user ID (which can be numeric) by converting to string, and appropriate validation callback invocation.
293-302: LGTM!The
logAndThrowextension provides a clean pattern for logging and throwing, and usingdebuglevel for token verification failures is appropriate to avoid log spam in production.modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart (3)
29-85: LGTM!Well-structured configuration class following the builder pattern. The default permissive validation is appropriately documented, noting GitHub's privacy-focused optional fields.
100-111: LGTM!Clean integration with Serverpod's password management, providing fail-fast behavior when credentials are missing.
117-175: LGTM!The
GitHubOAuthCredentialsclass follows good patterns with a private constructor, factory methods, and proper validation. The synchronous file read is acceptable for startup-time configuration loading.
Hi @marcelomendoncasoares, thanks for the clarification! I noticed a few failing tests that seem unrelated to this PR, they fail with SocketException: Connection refused (looks like integration tests requiring a running Serverpod instance). |
4e265ed to
b7302a7
Compare
@vfiruz97 These failures are actually due to missing migrations after your changes. Whenever new tables (or changes to existing tables) are introduced, a migration must be created on the affected projects: the server package under change and all test server projects that depend on it (like the Regarding the comment from CodeRabbit, just a few notes:
@coderabbitai, please learn this for next identity provider reviews. |
|
Tip For best results, initiate chat on the files or code changes. @marcelomendoncasoares: Thank you for the clarification! I've noted these important points about external identity providers and will apply them to future reviews. Based on your feedback, here's the updated priority list for this PR: Updated RecommendationsHIGH PRIORITY (Still Required):
MEDIUM PRIORITY: LOW/OPTIONAL: The migration creation is the critical blocker preventing CI from passing. Once migrations are added and the import pattern is fixed, this should be close to ready! ✏️ Learnings added
🧠 Learnings used |
b7302a7 to
ca28108
Compare
|
@marcelomendoncasoares Thank you for the quick reply and clear guidance! This helped me a lot. Addressed all the CodeRabbit review comments: ✅ State parameter validation implemented for CSRF protection Regarding migrations: Created for all affected projects. The repo is synced with no conflicts, and CI is passing. Ready for manual review. Feel free to ask if you need anything else! |
6ddcffb to
7dd9da6
Compare
|
Hi, @marcelomendoncasoares! Please review, It is ready. |
|
Great implementation for Github. I like to see OAuth2 PKCE implemented in Serverpod. Instead we could use config options to set authorization/token URL and/or define needed fields in the request body. |
This is a very good suggestion! We have built our IDP package with this vision of providing atoms that can be used to create other IDPs - either for the package or for private usage by Serverpod users. The We could improve this PR by moving the core implementation of the Oauth2 PKCE into a generic class under the What do you think, @vfiruz97? |
|
@89pleasure @marcelomendoncasoares Great suggestion! I completely agree - extracting the OAuth2 PKCE logic into a generic reusable class makes total sense. Looking at the existing common folder patterns (SecretChallengeUtil, IdTokenVerifier), this fits perfectly with the package's architecture. My plan: This refactoring will also benefit my planned contribution for Microsoft Sign-in support - I'll tackle this extraction first to make that implementation much cleaner and faster. I'll update the PR soon! |
|
That's cool! Thanks for taking over that approach. |
|
@89pleasure, glad this helps! |
5649fc3 to
6d48a38
Compare
|
@marcelomendoncasoares For the native Flutter setup, look at After this is merged, I can add proper documentation to the Serverpod docs covering native Flutter platform setup for Github provider. |
|
Tested on Android, Simulator, macOS, web(Chrome). |
|
Awesome! 🙌 As for the example it would be great to have it also inside the flutter implementation? I tried your old code and had issues with the callback endpoint. I have no clue how to make them work. Wouldn't it also be a good idea to create those endpoints automatically with a default pattern like: |
f96325c to
56cae7d
Compare
Great questions! Let me clarify: Regarding code Server side: Implement Client side: Implement Regarding callbacks/redirects: Native setup: Check flutter_web_auth_2 docs Regarding old code: |
|
@marcelomendoncasoares |
337e03d to
fcaa802
Compare
|
Sorry about the messy history. I rebased onto I will avoid force-pushing from here and continue addressing the review comments. |
|
@marcelomendoncasoares, Thanks for the great suggestions. |
marcelomendoncasoares
left a comment
There was a problem hiding this comment.
@marcelomendoncasoares, Thanks for the great suggestions. I initially planned to sync my branch before addressing the comments, but I ran into a conflict loop. I resolved it, though it required a force push, however resulted in a messy commit history - sorry about that. All comments have now been addressed. Looking forward to your review.
No problems. When it is possible to avoid, the benefit is that it's easy to catch the changes. Force-pushes reset GitHub "viewed" checks and require re-analyzing a lot of the already-reviewed code.
Thanks for looking carefully into each comment! Just a few more on the last changes.
|
@marcelomendoncasoares, thanks for suggestions! I've addressed them and now ready for review. |
marcelomendoncasoares
left a comment
There was a problem hiding this comment.
Last comments and I think we are good to go!
There was a problem hiding this comment.
Great work with this provider, @vfiruz97! Ready for merge 🚀
Next, could you open a PR to the serverpod_docs repo with the documentation for it? It should be added only under docs, since it will be available from the next version.
We should also include a doc for how to use the Oauth2 utilities added in the PR.
|
Thanks a lot, @marcelomendoncasoares! I'll open a PR to Is it okay if I use Add Firebase IDP docs as a reference and put under it in the menu section? Also, would you prefer GitHub and OAuth2 utilities to be documented as separate sections, or combined under For context, the same generic OAuth2 implementation will also be used by the upcoming Microsoft IDP. |
As a reference it is ok, but the documentation should be at its side, not under. All providers are documented on the path
They should be separate. For the user, whether we use or not this utility is more of an implementation detail that doesn't even need to be mentioned in the GitHub provider docs. For the Oauth2 docs, you can convert the |
This PR adds GitHub OAuth authentication support to the serverpod_auth module. It implements a complete GitHub identity provider (IDP) with PKCE (Proof Key for Code Exchange) flow for enhanced security across all platforms.
Key features:
Dependencies added:
This PR adds two dependencies to
serverpod_auth_idp_flutter:flutter_web_auth_2: ^4.1.0- Required for launching GitHub OAuth flow across all platforms. Well-maintained with permissive BSD-3-Clause license. It was difficult to find a Flutter package specifically for GitHub OAuth client implementation. This is a general-purpose OAuth package that works with any OAuth server supporting custom URL redirects, making it the best choice available. Other packages evaluated (github_signin_promax, github_oauth, github_sign_in_plus, oauth2_client) are either GitHub-specific but unmaintained, or lack proper cross-platform support.crypto: ^3.0.6- Official Dart SDK package required for PKCE implementation (SHA-256 hashing). Essential for secure OAuth 2.0 flow. Already used throughout Serverpod ecosystem.Fixes #3924.
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. This is a new feature that adds GitHub authentication support without modifying existing authentication methods or APIs.
Summary by CodeRabbit
Release Notes
New Features
Dependencies
cryptoandflutter_web_auth_2packages for OAuth authentication flowsTests
✏️ Tip: You can customize this high-level summary in your review settings.