fix(auth): implement Google OAuth 2.0 login integration in backend and frontend#150
Open
Rajal-ui wants to merge 2 commits into
Open
fix(auth): implement Google OAuth 2.0 login integration in backend and frontend#150Rajal-ui wants to merge 2 commits into
Rajal-ui wants to merge 2 commits into
Conversation
…d frontend This PR integrates Google OAuth 2.0 authentication into both the Spring Boot backend and React/Vite frontend. Backend changes: - Created AuthController and GoogleAuthService to verify Google ID tokens. - Defined GoogleAuthRequest DTO for incoming credential payloads. - Added database sub mapping, authentication provider details, and user entity updates. - Added application properties and environment variable definitions for GOOGLE_OAUTH_CLIENT_ID and JWT signing. - Added GoogleAuthServiceTest to verify backend validation logic. Frontend changes: - Integrated @react-oauth/google provider and components. - Integrated Google login triggers on the public Login page. - Cleaned up environment variables and README setup instructions to help developers launch and run services seamlessly.
Author
|
@rdodiya I have fixed the Google OAuth bug now the |
Owner
|
Hi @Rajal-ui , |
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.
Issue Link
Closes #139
Changes Made
Frontend (React / Vite)
<App />component in the<GoogleOAuthProvider>inRestroHub-FrontEnd/src/main.jsx.clientIddynamically viaimport.meta.env.VITE_GOOGLE_CLIENT_ID.<GoogleLogin>component insideRestroHub-FrontEnd/src/pages/public/Login.jsxto render the Google Sign-In prompt.VITE_GOOGLE_CLIENT_IDtoRestroHub-FrontEnd/.env.examplewith instructions on how to obtain credentials.RestroHub-FrontEnd/README.mdto reflect proper local installation steps, Vite commands (npm run dev), environment variables, and the correct API path.Backend (Java / Spring Boot)
GoogleAuthServiceto securely verify Google ID tokens passed from the frontend.AuthControllerand theGoogleAuthRequestDTO at/api/v1/auth/googlefor processing auth flows.Userentity to mapgoogle_sub,auth_provider(e.g.,GOOGLE), and profilepicture_urlcolumns in PostgreSQL.RestroHub/.env.exampleandapplication-dev.properties.GoogleAuthServiceTestto comprehensively test authentication, claims verification, and token signature validation.Type of Change
Testing Performed
Backend Testing
GoogleAuthServiceTestcompletes successfully with mock tokens)POST http://localhost:8181/restroly/api/v1/auth/google)401 Unauthorizedresponse. (Pass)Frontend Testing
/loginroute renders the Google Authentication button cleanly. (Pass)Screenshots/Images
Uncaught Error: Google OAuth components must be used within GoogleOAuthProvider.Functionality Demo
Steps to Verify Locally
./gradlew bootRuninsideRestroHub).npm run devinsideRestroHub-FrontEnd).http://localhost:3000/loginin your browser.Additional Notes
.env.exampletemplates to both projects to make setting up the environment incredibly easy and safe for future contributors.README.mdas per repository guidelines.