From a0f9c3aad86d76ef3c3d1883c481f9fff6754556 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Thu, 30 Oct 2025 23:52:14 -0700 Subject: [PATCH] feat: add BACKEND_URL configuration for OAuth redirect - Introduced BACKEND_URL in the configuration to allow overriding the HTTP to HTTPS in the OAuth redirect URI. - Updated the Google OAuth router to conditionally use the BACKEND_URL for the redirect URI when specified. --- surfsense_backend/app/app.py | 8 ++++++++ surfsense_backend/app/config/__init__.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/surfsense_backend/app/app.py b/surfsense_backend/app/app.py index 8c7c53db7..d416ae62c 100644 --- a/surfsense_backend/app/app.py +++ b/surfsense_backend/app/app.py @@ -68,6 +68,14 @@ if config.AUTH_TYPE == "GOOGLE": app.include_router( fastapi_users.get_oauth_router( google_oauth_client, auth_backend, SECRET, is_verified_by_default=True + ) + if not config.BACKEND_URL + else fastapi_users.get_oauth_router( + google_oauth_client, + auth_backend, + SECRET, + is_verified_by_default=True, + redirect_url=f"{config.BACKEND_URL}/auth/google/callback", ), prefix="/auth/google", tags=["auth"], diff --git a/surfsense_backend/app/config/__init__.py b/surfsense_backend/app/config/__init__.py index 548a22031..b8c35d347 100644 --- a/surfsense_backend/app/config/__init__.py +++ b/surfsense_backend/app/config/__init__.py @@ -97,6 +97,8 @@ class Config: DATABASE_URL = os.getenv("DATABASE_URL") NEXT_FRONTEND_URL = os.getenv("NEXT_FRONTEND_URL") + # Backend URL to override the http to https in the OAuth redirect URI + BACKEND_URL = os.getenv("BACKEND_URL") # Auth AUTH_TYPE = os.getenv("AUTH_TYPE")