Skip to content

feat: Add GitHub identity provider support - #4546

Merged
marcelomendoncasoares merged 28 commits into
serverpod:mainfrom
vfiruz97:feat/github-idp
Jan 26, 2026
Merged

marcelomendoncasoares merged 28 commits into
serverpod:mainfrom
vfiruz97:feat/github-idp

Conversation

@vfiruz97

@vfiruz97 vfiruz97 commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • OAuth 2.0 authorization code flow with PKCE for secure authentication without client secrets
  • Cross-platform support (iOS, Android, Web, macOS, Windows, Linux)
  • Customizable sign-in button widget with GitHub branding
  • Complete server-side token exchange, user authentication, and account management
  • Integration with existing Serverpod auth system
  • Comprehensive test coverage including integration tests

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

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

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

    • Added GitHub as a supported identity provider with full OAuth 2.0 support and PKCE security
    • New GitHub Sign-In button widget with customizable styling options (size, shape, style variants)
    • GitHub account linking and automatic user profile creation on first login
    • Added GitHub configuration support with OAuth credential management
  • Dependencies

    • Added crypto and flutter_web_auth_2 packages for OAuth authentication flows
  • Tests

    • Added comprehensive test coverage for GitHub authentication workflows

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions

github-actions Bot commented Jan 7, 2026 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@vfiruz97

vfiruz97 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

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.

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

@coderabbitai Full review.

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

@marcelomendoncasoares: I'll conduct a full review of this PR. Let me gather the necessary information about the changes.


🏁 Script executed:

#!/bin/bash

# Get list of all files changed in this PR
echo "=== Files changed in PR ===="
git diff --name-only origin/main...HEAD

echo -e "\n=== Detailed diff statistics ===="
git diff --stat origin/main...HEAD

echo -e "\n=== Check for existing GitHub IDP files ===="
fd -t f github -i

echo -e "\n=== Check existing IDP providers for comparison ===="
fd -t d -p "modules/new_serverpod_auth/serverpod_auth_idp" | head -20

Length of output: 2597


🏁 Script executed:

#!/bin/bash

# Examine the structure of existing IDP providers for comparison
echo "=== Apple IDP endpoint structure ===="
fd -e dart . modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple

echo -e "\n=== Google IDP endpoint structure ===="
fd -e dart . modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google

echo -e "\n=== Email IDP endpoint structure ===="
fd -e dart . modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/email

Length of output: 666


🏁 Script executed:

#!/bin/bash

# Check main server implementation files for GitHub
echo "=== GitHub server endpoint files ===="
fd -e dart . modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github | head -20

# Check Flutter client files
echo -e "\n=== GitHub Flutter client files ===="
fd -e dart . modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github | head -20

Length of output: 434


🏁 Script executed:

#!/bin/bash

# Check test coverage for GitHub IDP
echo "=== GitHub IDP test files ===="
fd -e dart github -i modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test

echo -e "\n=== GitHub IDP integration test files ===="
fd -e dart github -i tests/serverpod_test_server/test_integration

Length of output: 238


🏁 Script executed:

#!/bin/bash

# Examine key implementation files
echo "=== GitHub IDP base endpoint ===="
cat modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart

Length of output: 202


🏁 Script executed:

#!/bin/bash

# Check the sign-in button implementation
echo "=== GitHub sign-in button widget ===="
cat modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart

Length of output: 184


🏁 Script executed:

#!/bin/bash

# Check dependencies in pubspec files
echo "=== serverpod_auth_idp_flutter pubspec.yaml ===="
cat modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml | grep -A 50 "dependencies:"

Length of output: 166


🏁 Script executed:

#!/bin/bash

# Compare with existing Apple IDP endpoint for import patterns
echo "=== Apple IDP base endpoint imports ===="
head -20 modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple/endpoints/apple_idp_base_endpoint.dart

echo -e "\n=== Google IDP base endpoint imports ===="
head -20 modules/new_serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google/endpoints/google_idp_base_endpoint.dart

Length of output: 473


🏁 Script executed:

#!/bin/bash

# Correct path - use serverpod_auth not new_serverpod_auth
echo "=== Correct directory structure ===="
fd -t d -p "modules/serverpod_auth/serverpod_auth_idp" | head -20

echo -e "\n=== Apple IDP structure ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple

echo -e "\n=== Google IDP structure ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google

Length of output: 3243


🏁 Script executed:

#!/bin/bash

# Get the GitHub implementation files with correct path
echo "=== GitHub server files ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github

echo -e "\n=== GitHub Flutter client files ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github

Length of output: 1246


🏁 Script executed:

#!/bin/bash

# Check the GitHub IDP base endpoint
echo "=== GitHub IDP base endpoint ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart

Length of output: 1520


🏁 Script executed:

#!/bin/bash

# Compare with Apple IDP endpoint for consistency
echo "=== Apple IDP base endpoint imports ===="
head -30 modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple/endpoints/apple_idp_base_endpoint.dart

echo -e "\n=== Google IDP base endpoint imports ===="
head -30 modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google/endpoints/google_idp_base_endpoint.dart

Length of output: 2532


🏁 Script executed:

#!/bin/bash

# Check GitHub business logic files
echo "=== GitHub IDP business logic ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart

Length of output: 4722


🏁 Script executed:

#!/bin/bash

# Check GitHub IDP config
echo "=== GitHub IDP config ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart

Length of output: 6205


🏁 Script executed:

#!/bin/bash

# Check Flutter client implementation
echo "=== GitHub sign-in button ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart

Length of output: 5061


🏁 Script executed:

#!/bin/bash

# Check GitHub auth controller
echo "=== GitHub auth controller ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart

Length of output: 6868


🏁 Script executed:

#!/bin/bash

# Check pubspec dependencies
echo "=== serverpod_auth_idp_flutter pubspec ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml

Length of output: 1528


🏁 Script executed:

#!/bin/bash

# Check test files
echo "=== GitHub IDP tests ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart

Length of output: 4171


🏁 Script executed:

#!/bin/bash

# Check GitHub IDP utils for PKCE implementation
echo "=== GitHub IDP utils ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart

Length of output: 9071


🏁 Script executed:

#!/bin/bash

# Check GitHub sign-in service for client-side OAuth
echo "=== GitHub sign-in service ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart

Length of output: 8875


🏁 Script executed:

#!/bin/bash

# Check generated model files
echo "=== GitHub account model ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_account.dart

echo -e "\n=== GitHub access token verification exception model ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_access_token_verification_exception.dart

Length of output: 20873


🏁 Script executed:

#!/bin/bash

# Check the example endpoint implementation
echo "=== Example GitHub IDP endpoint ===="
cat examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart

Length of output: 160


🏁 Script executed:

#!/bin/bash

# Check public API exports
echo "=== GitHub provider exports (server) ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart

Length of output: 678


🏁 Script executed:

#!/bin/bash

# Check if there are integration tests
echo "=== Integration test files ===="
fd -e dart . tests/serverpod_test_server/test_integration | grep -i github

Length of output: 31


🏁 Script executed:

#!/bin/bash

# Check the admin implementation in detail
echo "=== GitHub IDP admin ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart

Length of output: 1659


🏁 Script executed:

#!/bin/bash

# Check if there are any YAML model definitions
echo "=== GitHub model YAML definitions ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml

echo -e "\n=== GitHub exception YAML definition ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_access_token_verification_exception.spy.yaml

Length of output: 1255


🏁 Script executed:

#!/bin/bash

# Check the storybook implementation (if exists)
echo "=== Storybook GitHub stories ===="
if [ -f "modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart" ]; then
  cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart
else
  echo "No storybook file found"
fi

Length of output: 3641


🏁 Script executed:

#!/bin/bash

# Check the sign-in widget
echo "=== GitHub sign-in widget ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dart

Length of output: 4970


🏁 Script executed:

#!/bin/bash

# Check the sign-in style
echo "=== GitHub sign-in style ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart

Length of output: 3410


🏁 Script executed:

#!/bin/bash

# Check for any documentation files
echo "=== Documentation or README for GitHub IDP ===="
fd -e md . modules/serverpod_auth/serverpod_auth_idp | xargs -I {} sh -c 'echo "=== {} ==="; grep -i github {} || true'

Length of output: 16532


🏁 Script executed:

#!/bin/bash

# Check the Flutter public exports
echo "=== Flutter public exports ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart 2>/dev/null || echo "Main export file not found, checking for it..."
fd serverpod_auth_idp_flutter.dart modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib

Length of output: 1429


🏁 Script executed:

#!/bin/bash

# Check if there's a main export file
echo "=== List all dart files in lib root ===="
fd -d 1 -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib

Length of output: 231


🏁 Script executed:

#!/bin/bash

# Compare import patterns between Apple and GitHub endpoints
echo "=== Apple endpoint full file ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple/endpoints/apple_idp_base_endpoint.dart

Length of output: 1909


🏁 Script executed:

#!/bin/bash

# Check server public exports structure
echo "=== Server lib root files ===="
fd -d 1 -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib

Length of output: 215


🏁 Script executed:

#!/bin/bash

# Check if GitHub exports are added to main library files
echo "=== Check core.dart for GitHub exports ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/core.dart 2>/dev/null | grep -i github || echo "No GitHub references found or file doesn't exist"

Length of output: 92


🏁 Script executed:

#!/bin/bash

# Look for the main library export file
echo "=== Server main export file ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/serverpod_auth_idp_server.dart

Length of output: 287


🏁 Script executed:

#!/bin/bash

# Check Flutter main export
echo "=== Flutter main export ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart

Length of output: 1321


🏁 Script executed:

#!/bin/bash

# Check for any TODO or FIXME comments
echo "=== Check for TODOs/FIXMEs in GitHub implementation ===="
rg -n 'TODO|FIXME' modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart
rg -n 'TODO|FIXME' modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github --type dart

Length of output: 56


🏁 Script executed:

#!/bin/bash

# Check database migration files
echo "=== Database migration files for GitHub ===="
fd -e sql github -i modules/serverpod_auth/serverpod_auth_idp

Length of output: 44


🏁 Script executed:

#!/bin/bash

# Check if assets are properly included
echo "=== Check pubspec.yaml assets ===="
grep -A 5 "assets:" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml

Length of output: 65


🏁 Script executed:

#!/bin/bash

# Verify SVG files exist
echo "=== GitHub SVG assets ===="
ls -la modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/assets/images/github*.svg 2>/dev/null || echo "SVG files not found at expected location"

Length of output: 326


🏁 Script executed:

#!/bin/bash

# Check for any hardcoded secrets or credentials
echo "=== Check for hardcoded credentials ===="
rg -n 'client.*secret|password|token.*=.*["\']' modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart | head -20

Length of output: 109


🏁 Script executed:

#!/bin/bash

# Check for hardcoded credentials properly escaped
echo "=== Check for hardcoded credentials ===="
rg -n "client.*secret|password|token.*=" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart | grep -v "final\|const\|required" | head -20

Length of output: 1707


🏁 Script executed:

#!/bin/bash

# Check core.dart content to understand import structure
echo "=== Core.dart full content ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/core.dart

Length of output: 677


🏁 Script executed:

#!/bin/bash

# Check generated endpoints to see if GitHub is included
echo "=== Generated endpoints ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/endpoints.dart | head -50

Length of output: 871


🏁 Script executed:

#!/bin/bash

# Check generated protocol for GitHub exports
echo "=== Generated protocol GitHub exports ===="
grep -n "GitHub" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/protocol.dart

Length of output: 1325


🏁 Script executed:

#!/bin/bash

# Look for database migrations
echo "=== Migration files ===="
fd -e sql . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations | head -20

Length of output: 190


🏁 Script executed:

#!/bin/bash

# Check if there are integration tests for other providers to compare
echo "=== Integration tests for auth ===="
fd -e dart . tests/serverpod_test_server/test_integration | grep -i "auth\|idp" | head -20

Length of output: 1348


🏁 Script executed:

#!/bin/bash

# Check the client endpoint interface
echo "=== Client endpoint interface ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/generated/providers/github/endpoints/github_idp_base_endpoint.dart 2>/dev/null || echo "File not found"

Length of output: 49


🏁 Script executed:

#!/bin/bash

# Find the client endpoint
echo "=== Find client GitHub endpoint ===="
fd github_idp modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client

Length of output: 36


🏁 Script executed:

#!/bin/bash

# Check providers export file  
echo "=== Providers export ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart

Length of output: 1972


🏁 Script executed:

#!/bin/bash

# Check if there are any linter warnings suppressed
echo "=== Linter suppressions in GitHub code ===="
rg "ignore:" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart
rg "ignore:" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github --type dart

Length of output: 43


🏁 Script executed:

#!/bin/bash

# Verify the PKCE implementation uses secure random
echo "=== Check crypto usage for PKCE ===="
grep -n "Random\|sha256\|base64" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart

Length of output: 334


🏁 Script executed:

#!/bin/bash

# Check client generated files
echo "=== Client generated protocol ===="
grep -n "GitHub" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/generated/protocol.dart 2>/dev/null | head -20 || echo "File not found or no GitHub references"

Length of output: 34


🏁 Script executed:

#!/bin/bash

# Check client lib structure
echo "=== Client library structure ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib | head -30

Length of output: 232


🏁 Script executed:

#!/bin/bash

# Check if there's a database migration or generated tables directory
echo "=== Look for generated tables or migrations ===="
fd generated modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated | grep -i github
fd migration modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server || echo "No migrations directory"

Length of output: 48


🏁 Script executed:

#!/bin/bash

# Compare with how other providers are tested
echo "=== Check Apple IDP tests ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/apple 2>/dev/null || echo "No Apple tests found"

echo -e "\n=== Check Google IDP tests ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/google 2>/dev/null || echo "No Google tests found"

echo -e "\n=== All test files ===="
fd -e dart . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test

Length of output: 4469


🏁 Script executed:

#!/bin/bash

# Check the example for how GitHub is configured
echo "=== Example auth main.dart ===="
cat examples/auth/auth_server/lib/server.dart 2>/dev/null | grep -A 30 -B 5 "GitHub\|github" || echo "File not found or no GitHub config"

Length of output: 3413


🏁 Script executed:

#!/bin/bash

# Verify error handling patterns
echo "=== Check exception handling patterns ===="
rg "catch.*Exception" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart -A 2

Length of output: 42


🏁 Script executed:

#!/bin/bash

# Check the consistency of documentation
echo "=== Compare documentation style with Apple ===="
head -30 modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple/business/apple_idp.dart

Length of output: 1205


🏁 Script executed:

#!/bin/bash

# Look for generated database models location
echo "=== Generated models location ===="
ls -la modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/

Length of output: 316


🏁 Script executed:

#!/bin/bash

# Check the client exports
echo "=== Client main export ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/serverpod_auth_idp_client.dart

Length of output: 272


🏁 Script executed:

#!/bin/bash

# Verify withValues usage for Colors (potential deprecation issue)
echo "=== Check Color.withValues usage ===="
rg "withValues" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github --type dart

Length of output: 409


🏁 Script executed:

#!/bin/bash

# Check if state parameter is validated in the OAuth flow
echo "=== Check state parameter handling ===="
rg -n "state" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart

Length of output: 219


🏁 Script executed:

#!/bin/bash

# Check redirect URI validation
echo "=== Check redirect URI validation ===="
rg -n "redirectUri" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart -B 2 -A 2

Length of output: 5644


🏁 Script executed:

#!/bin/bash

# Compare test coverage - count test methods
echo "=== GitHub test method count ===="
rg -n "test\(" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart | wc -l

echo -e "\n=== Apple test method count ===="
rg -n "test\(" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/apple/apple_account_admin_test.dart | wc -l

echo -e "\n=== Email test method count (sample file) ===="
rg -n "test\(" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/email/email_idp_admin_test.dart | wc -l

Length of output: 122


🏁 Script executed:

#!/bin/bash

# Check for SQL migration files or schema definitions
echo "=== Search for SQL or schema files ===="
fd -e sql . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server
fd -e yaml . modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github

Length of output: 315


🏁 Script executed:

#!/bin/bash

# Check how Apple validates redirectUri
echo "=== Apple redirectUri validation ===="
rg -n "redirectUri" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/apple --type dart -B 2 -A 2 | head -30

Length of output: 3307


🏁 Script executed:

#!/bin/bash

# Check how Google validates parameters
echo "=== Google parameter validation ===="
rg -n "validate|Validation" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/google --type dart

Length of output: 4381


🏁 Script executed:

#!/bin/bash

# Check if there are any rate limiting or security measures
echo "=== Security measures in GitHub IDP ===="
rg -n "rate.*limit|throttle|attempt" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github --type dart -i

Length of output: 40


🏁 Script executed:

#!/bin/bash

# Check client protocol file for endpoint definitions
echo "=== Client protocol endpoint definitions ===="
cat modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/protocol.dart | head -100

Length of output: 176


🏁 Script executed:

#!/bin/bash

# Compare with how email handles errors
echo "=== Email error handling patterns ===="
rg -n "Exception|throw" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/email/business/email_idp.dart | head -20

Length of output: 877


🏁 Script executed:

#!/bin/bash

# Check GitHub error handling
echo "=== GitHub error handling ===="
rg -n "Exception|throw|catch" modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart

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 Issues

1. Import Pattern Inconsistency ❌

Location: modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart

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 Concerns

2. State Parameter Not Validated 🔒

Location: modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart

The implementation generates a state parameter for CSRF protection (line 130):

'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:

  1. Stored before redirect
  2. Validated when callback is received
  3. Rejected if mismatch

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 redirectUri parameter is passed through without any validation. Consider adding validation to ensure it matches expected/whitelisted URIs to prevent potential redirect attacks.

Test Coverage Issues

4. Insufficient Test Coverage ⚠️

Current state:

  • GitHub: 3 test methods
  • Apple: 2 test methods
  • Email: 21 test methods (in just one file)

Missing test scenarios:

  • Token exchange failures
  • Invalid authorization codes
  • Network errors
  • Account details validation
  • Integration tests for the full OAuth flow
  • Error handling paths
  • PKCE code verifier mismatches
  • User profile creation failures

Files to add:

test/github/
  ├── github_idp_test.dart (main flow tests)
  ├── github_idp_utils_test.dart (utility function tests)
  ├── github_token_exchange_test.dart
  └── github_error_scenarios_test.dart

5. Limited Error Handling ⚠️

Location: github_idp.dart

The implementation only catches exceptions for user profile operations:

} catch (e, stackTrace) {
  session.log('Failed to create user profile...');
}

Compare this to the email provider which has extensive custom exception types and error handling. Consider adding:

  • Custom exceptions for different failure scenarios
  • Proper error propagation
  • User-friendly error messages

6. No Rate Limiting ⚠️

Other auth operations in the codebase use rate limiting utilities (available in src/common/rate_limited_request_attempt/), but GitHub IDP doesn't implement any. Consider adding rate limiting for:

  • Token exchange attempts
  • Account creation attempts

Code Quality Issues

7. Inconsistent Documentation 📝

Some methods lack the {@template} documentation pattern used elsewhere. For example, GitHubIdpAdmin.linkGitHubAuthentication could benefit from template documentation like other methods.

8. No Migration Documentation 📝

While the YAML model definitions exist, there's no SQL migration file or documentation about database schema changes. Other developers need guidance on how to apply these changes.

RecommendationsBased on the OAuth 2.0 security research, clients that have ensured the authorization server supports PKCE may rely on the CSRF protection provided by PKCE, and when using PKCE, the state parameter can be used for application state instead of CSRF protection. GitHub supports PKCE, so the current implementation approach is acceptable from a security standpoint. However, since the state is generated but never validated or used, it should either be properly validated or removed.

Priority Actions Required:

HIGH PRIORITY:

  1. Fix import pattern in github_idp_base_endpoint.dart (Line 3)
  2. Remove unused state parameter or implement proper validation
  3. Add comprehensive tests - minimum 10+ test scenarios

MEDIUM PRIORITY:
4. Enhance error handling with custom exceptions
5. Add redirect URI validation/whitelisting capability
6. Consider adding rate limiting

LOW PRIORITY:
7. Add database migration documentation
8. Expand inline documentation

Would you like me to provide specific code examples for any of these fixes? The import pattern fix and state parameter handling should be addressed before merging.


✏️ Learnings added
Learnt from: marcelomendoncasoares
URL: https://github.com/serverpod/serverpod/pull/4546

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.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
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.
✅ Actions performed

Full review triggered.

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

GitHub 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

Cohort / File(s) Summary
Server-side GitHub IdP configuration
examples/auth/auth_server/config/template.passwords.yaml, modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
Added GitHub OAuth credentials fields (clientId, clientSecret) to template config; implemented GitHubIdpConfig with credential validation, and GitHubOAuthCredentials value class with JSON factory constructors for credential loading.
Server-side GitHub IdP business logic
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart, github_idp_admin.dart, github_idp_utils.dart
Implemented GitHubIdp login coordinator with token exchange and user authentication; added GitHubIdpAdmin for account linking and user lookup; introduced GitHubIdpUtils for OAuth token verification, account details fetching, and error handling.
Server-side GitHub IdP endpoints and models
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart, lib/src/providers/github/models/github_account.spy.yaml, github_access_token_verification_exception.spy.yaml, lib/providers/github.dart
Created GitHubIdpBaseEndpoint abstract base for endpoint implementations; defined GitHubAccount database model with authUser relation and userIdentifier index; added GitHubAccessTokenVerificationException; exposed public provider API.
Server-side GitHub IdP integration
examples/auth/auth_server/lib/server.dart
Registered GitHubIdpConfig in identity provider builders using credentials from password store; imported GitHub provider modules.
Server-side GitHub IdP example endpoint
examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart
Implemented GitHubIdpEndpoint extending GitHubIdpBaseEndpoint for example server.
Flutter GitHub authentication controller
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart
Added GitHubAuthController managing OAuth state (idle, loading, error, authenticated), sign-in flow delegation to GitHubSignInService, server-side token exchange, and callbacks for onAuthenticated and onError.
Flutter GitHub OAuth service
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart
Implemented GitHubSignInService singleton for PKCE-based OAuth authorization flow using FlutterWebAuth2; added extension on FlutterAuthSessionManager for initialization; exposed codeVerifier and callbackUrlScheme getters.
Flutter GitHub sign-in styling system
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart
Introduced six enums for button configuration (GitHubButtonType, Style, Size, Text, Shape, LogoAlignment); created GitHubSignInStyle class with size, colors, and border radius; added factory constructor deriving styling from configuration parameters.
Flutter GitHub sign-in UI components
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart, github_sign_in_widget.dart
Implemented GitHubSignInButton reusable widget with customizable appearance, loading state, and SVG logo rendering; created GitHubSignInWidget composing GitHubAuthController and GitHubSignInButton with state subscription and lifecycle management.
Flutter GitHub authentication exports
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart, lib/src/providers.dart
Exported five GitHub authentication components from public API surface; added hasGitHub getter to AvailableIdps and updated provider count calculation.
Flutter GitHub integration into sign-in widget
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
Added disableGitHubSignInWidget flag and githubSignInWidget field to SignInWidget; integrated GitHub sign-in option alongside Google and Apple in social providers section; wired hasGitHub availability check.
Flutter dependencies
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml, templates/pubspecs/.../pubspec.yaml
Added crypto (^3.0.2) for PKCE challenge generation and flutter_web_auth_2 (^4.1.0) for OAuth authorization flow.
Storybook and testing
modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart, lib/stories/github.dart, lib/stories/signin.dart, lib/utils/client.dart, modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart, test/github/github_idp_admin_test.dart
Added GitHub storybook stories with button style and state variations; created mock GitHubIdpEndpoint for storybook client; extended config tests for password-based GitHub credentials; added admin tests for user lookup and GitHub account linking.
Root configuration
pubspec.yaml
Added flutter_web_auth_2 to serverpod_cli analyze_pubspecs ignore list.

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
Loading
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()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main feature being added: GitHub identity provider support.
Description check ✅ Passed The PR description is comprehensive, covering key features, dependencies, testing, and follows the template with all checklist items marked as completed.
Linked Issues check ✅ Passed The changeset implements GitHub authentication across all specified platforms (iOS, Android, Web, macOS, Windows) with PKCE-based OAuth 2.0, addressing all requirements in issue #3924.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing GitHub identity provider support as defined in the linked issue; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • BSD-3: Entity not found: Issue - Could not find referenced Issue.
  • SHA-256: Entity not found: Issue - Could not find referenced Issue.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 for core.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:user scope is redundant.

According to GitHub's OAuth scopes documentation, the user scope grants read/write access to profile information and implicitly includes user:email. The read:user scope only grants read-only access to profile data, making it redundant when user is 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 92ad877 and 4e265ed.

⛔ Files ignored due to path filters (17)
  • examples/auth/auth_client/lib/src/protocol/client.dart is excluded by !**/lib/src/protocol/**
  • examples/auth/auth_server/lib/src/generated/endpoints.dart is excluded by !**/generated/**
  • examples/auth/auth_server/lib/src/generated/protocol.yaml is excluded by !**/generated/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/client.dart is excluded by !**/lib/src/protocol/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_client/lib/src/protocol/protocol.dart is 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.dart is excluded by !**/lib/src/protocol/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/assets/images/github-mark-white.svg is excluded by !**/*.svg
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/assets/images/github-mark.svg is excluded by !**/*.svg
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/protocol.dart is excluded by !**/generated/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_access_token_verification_exception.dart is excluded by !**/generated/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/generated/providers/github/models/github_account.dart is excluded by !**/generated/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition.json is excluded by !**/migrations/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition.sql is excluded by !**/migrations/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/definition_project.json is excluded by !**/migrations/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/migration.json is excluded by !**/migrations/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/20260107154918295/migration.sql is excluded by !**/migrations/**
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/migrations/migration_registry.txt is excluded by !**/migrations/**
📒 Files selected for processing (28)
  • examples/auth/auth_server/config/template.passwords.yaml
  • examples/auth/auth_server/lib/server.dart
  • examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_service.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_access_token_verification_exception.spy.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/models/github_account.spy.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
  • pubspec.yaml
  • templates/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.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart
  • examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/github.dart
  • examples/auth/auth_server/lib/server.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
  • modules/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.dart
  • modules/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.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_button.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/github/github_idp_admin_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_sign_in_style.dart
  • templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_admin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/github/github_auth_controller.dart
  • examples/auth/auth_server/lib/src/endpoints/github_idp_endpoint.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_utils.dart
  • examples/auth/auth_server/lib/server.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • modules/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.dart
  • examples/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.dart
  • modules/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.dart
  • templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • examples/auth/auth_server/lib/server.dart
  • modules/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.dart
  • templates/pubspecs/modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • examples/auth/auth_server/lib/server.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
  • pubspec.yaml
  • modules/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.dart
  • modules/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.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
  • examples/auth/auth_server/lib/server.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/pubspec.yaml
  • modules/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.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/stories/signin.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • pubspec.yaml
  • modules/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.yaml
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/providers/github.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/utils/client.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/business/github_idp_config.dart
  • examples/auth/auth_server/lib/server.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/lib/src/providers/github/endpoints/github_idp_base_endpoint.dart
  • pubspec.yaml
  • modules/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.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • examples/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.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/serverpod_auth_idp_flutter.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/storybook/lib/main.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/sign_in_widget.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • examples/auth/auth_server/lib/server.dart
  • pubspec.yaml
  • modules/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.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_server/test/config/from_passwords_config_test.dart
  • modules/serverpod_auth/serverpod_auth_idp/serverpod_auth_idp_flutter/lib/src/providers.dart
  • examples/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.dart
  • pubspec.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 GitHubIdpConfigFromPasswords throws PasswordNotFoundException when githubClientId is missing, consistent with other identity provider tests.


219-260: LGTM! Successful configuration test is well-structured.

The test correctly verifies that GitHubIdpConfigFromPasswords succeeds 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 hasGitHub getter follows the same pattern as other identity providers (hasEmail, hasGoogle, hasApple), and the count getter 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 GitHubIdpEndpoint follows the same pattern as GoogleIdpEndpoint and AppleIdpEndpoint, providing appropriate storybook/testing behavior. The endpoint is correctly wired into the Client class 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 login method 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 login method properly delegates to the GitHubIdp instance 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 minimumWidth bounds 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 build method 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 GitHubIdpAdmin class provides a clean public API:

  • fetchAccountDetails and linkGitHubAuthentication properly delegate to the injected utils instance
  • findUserByGitHubUserId is correctly static since it only performs a DB lookup without needing utils

The 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? with random_v7) aligning with Serverpod's migration to UUID-based user IDs
  • Cascade delete on authUser relation ensures orphaned GitHub accounts are cleaned up
  • email is optional, which aligns with the flexible validation approach where email is only required on first-time sign-ups
  • Unique index on userIdentifier prevents duplicate GitHub account registrations

One consideration: if reverse lookups by authUserId are common (e.g., "find GitHub account for this user"), an additional index on authUserId could 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:

  • AuthSuccess from core for authentication result handling
  • GitHubAccount and GitHubAccessTokenVerificationException for 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 hasGitHub getter and the conditional rendering in socialProviders follow the same pattern used for Google sign-in. The widget correctly falls back to a default GitHubSignInWidget when 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 _initialized flag 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 FlutterAuthSessionManager provides 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 StateError for end users while logging them for debugging is a sensible pattern.


93-97: LGTM!

Proper disposal pattern with the _disposed flag 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 logAndThrow extension provides a clean pattern for logging and throwing, and using debug level 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 GitHubOAuthCredentials class follows good patterns with a private constructor, factory methods, and proper validation. The synchronous file read is acceptable for startup-time configuration loading.

@vfiruz97

vfiruz97 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

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.

Hi @marcelomendoncasoares, thanks for the clarification!
This is my first time working with CodeRabbit, so I'll address all its comments and push the fixes.

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).
Should all checks be green for this PR, or can these failures be ignored for now?

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

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). Should all checks be green for this PR, or can these failures be ignored for now?

@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 serverpod_test_server, serverpod_auth_idp_server and examples/auth/auth_server). It should be all green, except for a few flaky tests that are occurring sometimes on Windows.

Regarding the comment from CodeRabbit, just a few notes:

  • We know that creating tests for external providers might be very hard due to external dependencies. You can see that Google and Apple lack a lot of tests as well and it's ok if we can't find a way to add tests for GitHub - although we should try.
  • External providers - such as Google, Apple and this one - may not need rate limiting, since we can rely on the provider's own security guardrails. So it is best to keep these provider implementations lean instead of bloating with duplicate protections.

@coderabbitai, please learn this for next identity provider reviews.

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

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 Recommendations

HIGH PRIORITY (Still Required):

  1. ✅ Fix import pattern in github_idp_base_endpoint.dart - Use package imports instead of relative imports
  2. ✅ Remove unused state parameter or implement proper validation (since it's generated but never used)
  3. ✅ Create migrations for the new GitHubAccount table in:
    • serverpod_auth_idp_server
    • serverpod_test_server
    • examples/auth/auth_server

MEDIUM PRIORITY:
4. Add redirect URI validation/whitelisting capability (security best practice)
5. Enhance error handling with custom exceptions where appropriate

LOW/OPTIONAL:
6. Add rate limiting (Not needed - can rely on GitHub's security)
7. Add comprehensive tests (Acceptable to have limited tests due to external dependency challenges)
8. Add database migration documentation
9. Expand inline documentation

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
Learnt from: marcelomendoncasoares
URL: https://github.com/serverpod/serverpod/pull/4546

Timestamp: 2026-01-08T20:41:36.591Z
Learning: For external OAuth identity providers (Google, Apple, GitHub) in Serverpod, extensive test coverage may not be feasible due to external service dependencies. It's acceptable to have limited test coverage for these providers, as comprehensive testing is difficult without mocking complex OAuth flows.

Learnt from: marcelomendoncasoares
URL: https://github.com/serverpod/serverpod/pull/4546

Timestamp: 2026-01-08T20:41:36.592Z
Learning: External OAuth identity providers (Google, Apple, GitHub) in Serverpod don't require rate limiting implementation, since these providers have their own security guardrails. Keep external provider implementations lean rather than adding duplicate security protections.

Learnt from: marcelomendoncasoares
URL: https://github.com/serverpod/serverpod/pull/4546

Timestamp: 2026-01-08T20:41:36.592Z
Learning: When new tables or table changes are introduced in Serverpod, migrations must be created for the affected server package and all test server projects that depend on it, including: serverpod_test_server, serverpod_auth_idp_server, and examples/auth/auth_server.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
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.

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.

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.

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.

@vfiruz97

vfiruz97 commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@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
✅ Empty test group removed from github_idp_admin_test.dart
✅ Package import used instead of relative import in github_idp_base_endpoint.dart
✅ Widget constructor assertion fixed to require exactly one of controller or client
✅ Documentation code block formatting corrected

Regarding migrations: Created for all affected projects.
Regarding testing: Understand that comprehensive testing for external OAuth providers like GitHub is challenging due to external dependencies require complex mocking infrastructure. I implemented basic admin functionality tests.

The repo is synced with no conflicts, and CI is passing. Ready for manual review. Feel free to ask if you need anything else!

@vfiruz97
vfiruz97 force-pushed the feat/github-idp branch 2 times, most recently from 6ddcffb to 7dd9da6 Compare January 9, 2026 18:40
@vfiruz97

Copy link
Copy Markdown
Contributor Author

Hi, @marcelomendoncasoares! Please review, It is ready.

@89pleasure

89pleasure commented Jan 12, 2026 •

Copy link
Copy Markdown

Great implementation for Github. I like to see OAuth2 PKCE implemented in Serverpod.
But don't you think a generic OAuth2 provider does make more sense instead of creating a provider for each website/service? OAuth2 PKCE is well defined and is standardized.

Instead we could use config options to set authorization/token URL and/or define needed fields in the request body.
I think it would save a lot of time adding more providers and save a lot duplicated code.

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

Great implementation for Github. I like to see OAuth2 PKCE implemented in Serverpod. But don't you think a generic OAuth2 provider does make more sense instead of creating a provider for each website/service? OAuth2 PKCE is well defined and is standardized.

Instead we could use config options to set authorization/token URL and/or define needed fields in the request body. I think it would save a lot of time adding more providers and save a lot duplicated code.

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 common folder inside the package already contains two of these generic atoms: one for issuing verification challanges and other for rate limiting.

We could improve this PR by moving the core implementation of the Oauth2 PKCE into a generic class under the common folder, as @89pleasure suggested, and have the GitHubIdp as a shell that uses this class with all required configuration that is specific this provider.

What do you think, @vfiruz97?

@vfiruz97

Copy link
Copy Markdown
Contributor Author

@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:
Create common/oauth2_pkce/ with generic OAuth2PkceUtil (server) and OAuth2PkceService (Flutter)
Refactor GitHubIdp to be a thin shell that configures the generic classes

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!

@89pleasure

Copy link
Copy Markdown

That's cool! Thanks for taking over that approach.
Since I'm planning to implement Twitch Sign-In support - which almost works the same way the GitHub implementation works. This will save a lot of time and code lines :)

@vfiruz97

Copy link
Copy Markdown
Contributor Author

@89pleasure, glad this helps!
Having a shared PKCE/OAuth2 foundation should make adding providers like Twitch more straightforward and help keep the implementations consistent.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

@marcelomendoncasoares
I've refactored the implementation and moved the OAuth2 PKCE core logic into a generic class under common for both server and flutter sides, with GitHubIdp now acting as a thin shell providing provider-specific configuration, as discussed.

For the native Flutter setup, look at flutter_web_auth_2 documentation.

After this is merged, I can add proper documentation to the Serverpod docs covering native Flutter platform setup for Github provider.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

Tested on Android, Simulator, macOS, web(Chrome).

@89pleasure

Copy link
Copy Markdown

Awesome! 🙌
I commented on the code challenge and verifier.

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: https//localhost:8080/auth/{service}/callback?

@vfiruz97

Copy link
Copy Markdown
Contributor Author

Awesome! 🙌 I commented on the code challenge and verifier.

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: https//localhost:8080/auth/{service}/callback?

Great questions! Let me clarify:

Regarding code verifier/challenge: I've made codeVerifier and related variables optional in the generic classes to support OAuth2 providers that don't use PKCE. However, GitHub fully supports both state and PKCE, so they remain enabled by default.

Server side:

Implement OAuth2PkceConfig for your provider (see GitHubIdpConfig example)
Use OAuth2PkceUtil for token exchange (see GitHubIdpUtils example)
Serverpod auth handles the code exchange and profile retrieval

Client side:

Implement OAuth2PkceProviderConfig for your provider (see GitHubOAuth2ProviderConfig example)
Override enableState and enablePKCE if needed
Use OAuth2PkceUtil for authorization (see GitHubSignInService example)
Generic OAuth2PkceUtil handles state/PKCE automatically unless explicitly disabled in config

Regarding callbacks/redirects:
We don't restrict users here. You need to configure redirects based on your platform:

Native setup: Check flutter_web_auth_2 docs
Web: Add auth.html in web folder with the required script from docs
Mobile: Register deep linking with your custom scheme (e.g., myapp://) to catch OAuth callbacks
Since you're building a custom provider (not part of the core IDP package), you'll create your own endpoints and helpers in your Serverpod project. The generic classes are designed to keep your implementation thin and focused.

Regarding old code:
Previous code was tested by me almost on all platform. Now I recorded short fasted video of current code on some platforms. See: https://youtu.be/-S15eQkjd70
No issue.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

@marcelomendoncasoares
I have been using flutter_facebook_auth for Facebook IDP, but let me know if I should use a generic OAuth approach like GitHub instead.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

Sorry about the messy history.

I rebased onto origin/main, then tried pulling to avoid force-push, which caused conflicts again. To resolve the loop, I rebased and force-pushed once.

I will avoid force-pushing from here and continue addressing the review comments.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

@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.

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread pubspec.yaml Resolved
@vfiruz97

Copy link
Copy Markdown
Contributor Author

@marcelomendoncasoares, thanks for suggestions! I've addressed them and now ready for review.

@marcelomendoncasoares marcelomendoncasoares left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last comments and I think we are good to go!

Comment thread pubspec.yaml Resolved

@marcelomendoncasoares marcelomendoncasoares left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vfiruz97

Copy link
Copy Markdown
Contributor Author

Thanks a lot, @marcelomendoncasoares!

I'll open a PR to serverpod_docs and add the documentation under docs, including a section explaining how to use the OAuth2 utilities introduced in this PR.

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 GitHub section?

For context, the same generic OAuth2 implementation will also be used by the upcoming Microsoft IDP.

@marcelomendoncasoares

Copy link
Copy Markdown
Collaborator

Is it okay if I use Add Firebase IDP docs as a reference and put under it in the menu section?

As a reference it is ok, but the documentation should be at its side, not under. All providers are documented on the path docs/06-concepts/11-authentication/04-providers.

Also, would you prefer GitHub and OAuth2 utilities to be documented as separate sections, or combined under GitHub section?

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 docs/06-concepts/11-authentication/04-providers/10-custom-providers.md section into a menu, with the current page being a overview and your Oauth2 docs going into a common utilities subpage. On this docs, you can mention that the GitHub provider is implemented using this utility for a reference to future developers.

@marcelomendoncasoares
marcelomendoncasoares merged commit 5affa49 into serverpod:main Jan 26, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sign in with Github

4 participants