chore: Set redirect_path default in function (#1833)

This commit is contained in:
Ruhul Alam 2025-09-15 17:33:44 -05:00 committed by GitHub
commit 2df8a0f915
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 13 additions and 12 deletions

View file

@ -240,7 +240,7 @@ class OAuthProxy(OAuthProvider):
token_verifier: TokenVerifier,
# FastMCP server configuration
base_url: AnyHttpUrl | str,
redirect_path: str = "/auth/callback",
redirect_path: str | None = None,
issuer_url: AnyHttpUrl | str | None = None,
service_documentation_url: AnyHttpUrl | str | None = None,
# Client redirect URI validation
@ -317,9 +317,12 @@ class OAuthProxy(OAuthProvider):
self._default_scope_str = " ".join(self.required_scopes or [])
# Store redirect configuration
self._redirect_path = (
redirect_path if redirect_path.startswith("/") else f"/{redirect_path}"
)
if not redirect_path:
self._redirect_path = "/auth/callback"
else:
self._redirect_path = (
redirect_path if redirect_path.startswith("/") else f"/{redirect_path}"
)
self._allowed_client_redirect_uris = allowed_client_redirect_uris
# PKCE configuration

View file

@ -211,7 +211,6 @@ class AzureProvider(OAuthProxy):
# Apply defaults
tenant_id_final = settings.tenant_id
redirect_path_final = settings.redirect_path or "/auth/callback"
timeout_seconds_final = settings.timeout_seconds or 10
# Default scopes for Azure - User.Read gives us access to user info via Graph API
scopes_final = settings.required_scopes or [
@ -249,7 +248,7 @@ class AzureProvider(OAuthProxy):
upstream_client_secret=client_secret_str,
token_verifier=token_verifier,
base_url=settings.base_url,
redirect_path=redirect_path_final,
redirect_path=settings.redirect_path,
issuer_url=settings.base_url,
allowed_client_redirect_uris=allowed_client_redirect_uris_final,
)

View file

@ -243,7 +243,6 @@ class GitHubProvider(OAuthProxy):
# Apply defaults
redirect_path_final = settings.redirect_path or "/auth/callback"
timeout_seconds_final = settings.timeout_seconds or 10
required_scopes_final = settings.required_scopes or ["user"]
allowed_client_redirect_uris_final = settings.allowed_client_redirect_uris
@ -267,7 +266,7 @@ class GitHubProvider(OAuthProxy):
upstream_client_secret=client_secret_str,
token_verifier=token_verifier,
base_url=settings.base_url,
redirect_path=redirect_path_final,
redirect_path=settings.redirect_path,
issuer_url=settings.base_url, # We act as the issuer for client registration
allowed_client_redirect_uris=allowed_client_redirect_uris_final,
)

View file

@ -261,7 +261,6 @@ class GoogleProvider(OAuthProxy):
)
# Apply defaults
redirect_path_final = settings.redirect_path or "/auth/callback"
timeout_seconds_final = settings.timeout_seconds or 10
# Google requires at least one scope - openid is the minimal OIDC scope
required_scopes_final = settings.required_scopes or ["openid"]
@ -286,7 +285,7 @@ class GoogleProvider(OAuthProxy):
upstream_client_secret=client_secret_str,
token_verifier=token_verifier,
base_url=settings.base_url,
redirect_path=redirect_path_final,
redirect_path=settings.redirect_path,
issuer_url=settings.base_url, # We act as the issuer for client registration
allowed_client_redirect_uris=allowed_client_redirect_uris_final,
)

View file

@ -220,7 +220,6 @@ class WorkOSProvider(OAuthProxy):
if not authkit_domain_str.startswith(("http://", "https://")):
authkit_domain_str = f"https://{authkit_domain_str}"
authkit_domain_final = authkit_domain_str.rstrip("/")
redirect_path_final = settings.redirect_path or "/auth/callback"
timeout_seconds_final = settings.timeout_seconds or 10
scopes_final = settings.required_scopes or []
allowed_client_redirect_uris_final = settings.allowed_client_redirect_uris
@ -245,7 +244,7 @@ class WorkOSProvider(OAuthProxy):
upstream_client_secret=client_secret_str,
token_verifier=token_verifier,
base_url=settings.base_url,
redirect_path=redirect_path_final,
redirect_path=settings.redirect_path,
issuer_url=settings.base_url,
allowed_client_redirect_uris=allowed_client_redirect_uris_final,
)

View file

@ -272,4 +272,6 @@ class TestAuth0Provider:
)
# Check defaults
assert str(provider.base_url) == TEST_BASE_URL
assert provider._redirect_path == "/auth/callback"
assert provider._token_validator.required_scopes == ["openid"]