feat(auth): add Google and GitHub OAuth2 social login#786
Merged
Conversation
- Install passport-google-oauth20 and passport-github2 strategies - Add provider, providerId, providerAccessToken, providerRefreshToken nullable columns to User entity for social account storage - Make password column nullable to support password-less OAuth accounts - GoogleStrategy: uses GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET env vars, requests email + profile scopes, callback at /auth/google/callback - GitHubStrategy: uses GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET env vars, requests user:email scope, callback at /auth/github/callback - SocialAuthService.findOrCreateFromProvider: finds user by providerId, falls back to email match (links existing account), or creates new user - SocialAuthService.linkProvider / unlinkProvider: allows connecting and disconnecting social providers from an existing account - SocialAuthController: GET /auth/google, /auth/google/callback, /auth/github, /auth/github/callback endpoints with Swagger docs - GoogleOAuthGuard / GitHubOAuthGuard wrappers for Passport AuthGuard closes rinafcode#509
|
@Nimatstar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Google and GitHub OAuth2 social login to the existing Passport/Auth0 JWT authentication stack, including account linking and a user-facing callback controller.
What's changed
New packages
User entity
New files
Auth module updated to register new strategies, service, and controller.
Env vars required
Account linking behaviour
closes #509