mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-20 12:34:17 +02:00
chore: Set redirect_path default in function (#1833)
This commit is contained in:
parent
f4f1905c89
commit
2df8a0f915
6 changed files with 13 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue