|
31 | 31 |
|
32 | 32 | auth_service = AuthService() |
33 | 33 |
|
34 | | -# Initialize OAuth services based on configuration |
35 | | -# If USE_DEX_OAUTH is True, use Keycloak for both GitHub and Google OAuth (development) |
36 | | -# Otherwise, use real GitHub and Google OAuth services (production) |
37 | | -if config_settings.USE_DEX_OAUTH: |
| 34 | +# Initialize OAuth services based on configuration and environment |
| 35 | +# In PRODUCTION, ALWAYS use real GitHub and Google OAuth regardless of USE_DEX_OAUTH |
| 36 | +# In DEVELOPMENT, use Keycloak only if explicitly enabled |
| 37 | +is_production = config_settings.ENV_TYPE == "production" |
| 38 | + |
| 39 | +if is_production: |
| 40 | + # PRODUCTION: Always use real OAuth services |
| 41 | + github_oauth_service = GitHubOAuthService() |
| 42 | + google_oauth_service = GoogleOAuthService() |
| 43 | + logger.info("PRODUCTION MODE: Using real GitHub and Google OAuth services") |
| 44 | +elif config_settings.USE_DEX_OAUTH: |
| 45 | + # DEVELOPMENT with Keycloak: Use mock OAuth |
38 | 46 | from ..services.keycloak_oauth_service import keycloak_oauth_service |
39 | 47 | github_oauth_service = keycloak_oauth_service |
40 | 48 | google_oauth_service = keycloak_oauth_service |
41 | | - logger.info("Using Keycloak OAuth service for development (USE_DEX_OAUTH=true)") |
| 49 | + logger.info("DEVELOPMENT MODE: Using Keycloak OAuth service (USE_DEX_OAUTH=true)") |
42 | 50 | else: |
| 51 | + # DEVELOPMENT without Keycloak: Use real OAuth |
43 | 52 | github_oauth_service = GitHubOAuthService() |
44 | 53 | google_oauth_service = GoogleOAuthService() |
45 | | - logger.info("Using real GitHub and Google OAuth services (USE_DEX_OAUTH=false)") |
| 54 | + logger.info("DEVELOPMENT MODE: Using real GitHub and Google OAuth services (USE_DEX_OAUTH=false)") |
46 | 55 |
|
47 | 56 | @router.get("/csrf-token", response_model=CsrfToken) |
48 | 57 | async def get_csrf_token(request: Request, response: Response): |
|
0 commit comments