expand coverage to all oauth routes

This commit is contained in:
Taylor Wilsdon
2025-08-07 11:37:08 -04:00
parent 7c09018144
commit dcdc90df4d
2 changed files with 33 additions and 14 deletions

View File

@@ -29,12 +29,28 @@ def get_transport_mode() -> str:
return _current_transport_mode
# OAuth Redirect URI Configuration
# This is determined once at startup and used throughout the application
# OAuth Configuration
# Determine base URL and redirect URI once at startup
_OAUTH_REDIRECT_URI = os.getenv("GOOGLE_OAUTH_REDIRECT_URI")
if not _OAUTH_REDIRECT_URI:
if _OAUTH_REDIRECT_URI:
# Extract base URL from the redirect URI (remove the /oauth2callback path)
if _OAUTH_REDIRECT_URI.endswith("/oauth2callback"):
_OAUTH_BASE_URL = _OAUTH_REDIRECT_URI[:-15] # Remove "/oauth2callback"
else:
# If it doesn't end with the expected path, use it as-is but warn
_OAUTH_BASE_URL = _OAUTH_REDIRECT_URI
else:
# Construct from base URI and port if not explicitly set
_OAUTH_REDIRECT_URI = f"{WORKSPACE_MCP_BASE_URI}:{WORKSPACE_MCP_PORT}/oauth2callback"
_OAUTH_BASE_URL = f"{WORKSPACE_MCP_BASE_URI}:{WORKSPACE_MCP_PORT}"
_OAUTH_REDIRECT_URI = f"{_OAUTH_BASE_URL}/oauth2callback"
def get_oauth_base_url() -> str:
"""Get OAuth base URL for constructing OAuth endpoints.
Returns the base URL (without paths) for OAuth endpoints,
respecting GOOGLE_OAUTH_REDIRECT_URI for reverse proxy scenarios.
"""
return _OAUTH_BASE_URL
def get_oauth_redirect_uri() -> str:
"""Get OAuth redirect URI based on current configuration.