Skip to content

feature: add google.oauth.enabled flag and seed default roles for Google…#180

Open
abhigyan24-ops wants to merge 1 commit into
rdodiya:gssoc_developfrom
abhigyan24-ops:feature/google-auth-backend
Open

feature: add google.oauth.enabled flag and seed default roles for Google…#180
abhigyan24-ops wants to merge 1 commit into
rdodiya:gssoc_developfrom
abhigyan24-ops:feature/google-auth-backend

Conversation

@abhigyan24-ops
Copy link
Copy Markdown
Contributor

Summary

Closes #45

Changes

1. google.oauth.enabled property flag

  • Added google.oauth.enabled=${GOOGLE_OAUTH_ENABLED:true} to both
    application.properties and application-dev.properties
  • GoogleAuthService now checks this flag at runtime and throws a clear
    BusinessException if Google Auth is disabled, instead of failing silently

2. DataInitializer — seed default roles on startup

  • New DataInitializer component runs on startup via CommandLineRunner
  • Creates ADMIN, RESTAURANT_OWNER, and CUSTOMER roles if they don't exist
  • Prevents "CUSTOMER role not found" error during first Google OAuth login
  • Idempotent — safe to run multiple times

How to enable/disable Google Auth

Set in environment or properties file:

  • GOOGLE_OAUTH_ENABLED=true → Google login enabled (default)
  • GOOGLE_OAUTH_ENABLED=false → Google login disabled, returns 400 with clear message

How to test

  1. Set GOOGLE_OAUTH_ENABLED=falsePOST /api/v1/auth/google returns 400
  2. Set GOOGLE_OAUTH_ENABLED=true + valid GOOGLE_OAUTH_CLIENT_ID → Google login works
  3. On fresh DB, roles are auto-created on startup

@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 20, 2026

Hi @abhigyan24-ops ,
Please delete DataInitializer class as we are using DB authentication now, previously we were using in memory authenticaiton.

Also add a flag in frontend side in login, when the flag is disable the google authenticaiton button should not be shown in UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add Social Sign-Up Options

2 participants