[JITERA] Fix Google SSO Login Functionality
Created by: tetsuto-morishima
Overview
This pull request addresses the issues identified in the Google SSO login functionality. It includes necessary backend and frontend changes to ensure that users can log in using their Google accounts seamlessly.
Changes Explained
Backend Changes
-
Added Google OAuth2 Authentication Endpoints:
-
/api/v1/login/google: This endpoint generates the Google authentication URL. -
/api/v1/login/google/callback: This endpoint handles the callback from Google after user authentication.
-
-
Added Random Password Generation Function:
- A function to generate a random password for users logging in for the first time via Google SSO has been added to enhance security.
Frontend Changes
-
Updated
useAuth.tsHook:- Added a function to fetch the Google authentication URL.
- Added a function to log in using the Google authentication code.
- Fixed the handling of the Google SSO token in the
loginMutationfunction.
-
Updated Login Screen:
- Added a Google login button to the UI.
- Implemented logic to retrieve the
codefrom the URL parameters and initiate the Google authentication process.
Configuration Notes
- Ensure the following environment variables are set correctly:
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URI
Testing Instructions
- Deploy the changes to both the backend and frontend.
- Set the required environment variables.
- Click the Google login button on the login screen.
- Log in through the Google authentication screen.
- Verify that the user is redirected and logged in successfully.
These changes will ensure that the Google SSO login functionality operates correctly.