-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
π Overview
Implement Google OAuth authentication in LogiQuest to allow users to sign in with their Google accounts. This feature should leverage Passport.js and work seamlessly within the existing authentication flow.
π οΈ Tasks
-
Add Google OAuth Strategy
- Implement a Google OAuth strategy using Passport.js
- Create a GoogleStrategy provider
- Configure authentication using environment variables (ensure documentation is updated)
-
Create Authentication Controller Endpoints
- Add an endpoint to initiate Google authentication
- Create a callback endpoint to handle Google's response
- Implement user profile creation for new Google users
-
Update User Entity
- Add a
googleIdfield - Add a
providerfield (values: local/google) - Ensure proper updates to the database schema
- Add a
-
JWT Generation for Google Auth
- Generate JWT tokens after successful Google authentication
- Ensure proper user data is included in the tokens
-
HTTPyac Test Files
- Include HTTPyac test files to demonstrate the working implementation
### Initiate Google Auth (this will redirect to Google)
GET http://localhost:3000/auth/google
### Manually test the callback URL after authentication
GET http://localhost:3000/auth/google/callback?code=EXAMPLE_CODE
### Verify that the JWT token works by accessing a protected endpoint
GET http://localhost:3000/auth/profile
Authorization: Bearer {{google.response.body.access_token}}π¨ Technical & Setup Considerations
- Use
@nestjs/passportandpassport-google-oauth20packages - Use environment variables for Google OAuth credentials (Client ID/Secret)
- IMPORTANT: Use
npm ciinstead ofnpm installwhen setting up the project to avoid dependency issues
β Acceptance Criteria
- Users can initiate authentication with Google
- Google authentication flow completes successfully
- New users are created on first Google login
- Existing users are properly linked with Google accounts
- JWT tokens are issued after successful authentication
- Error handling for failed authentication attempts
- Environment variables are documented for Google OAuth credentials
π References
Let's ensure we follow the dependency guidelines and use the proper setup commands π