mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 07:09:11 +02:00
* Remove 3.x-era compatibility shims * Require response_type in ctx.elicit() * Name the utilities path for the two non-re-exported auth helpers * Point sampling handler migration at its submodule
83 lines
2.2 KiB
Python
83 lines
2.2 KiB
Python
from typing import TYPE_CHECKING
|
|
|
|
from .auth import (
|
|
OAuthProvider,
|
|
TokenVerifier,
|
|
RemoteAuthProvider,
|
|
MultiAuth,
|
|
AccessToken,
|
|
AuthProvider,
|
|
)
|
|
from fastmcp.utilities.authorization import (
|
|
AuthCheck,
|
|
AuthContext,
|
|
require_roles,
|
|
require_scopes,
|
|
restrict_tag,
|
|
run_auth_checks,
|
|
)
|
|
|
|
if TYPE_CHECKING:
|
|
from .identity_assertion import IdentityAssertion as IdentityAssertion
|
|
from .oauth_proxy import OAuthProxy as OAuthProxy
|
|
from .oidc_proxy import OIDCProxy as OIDCProxy
|
|
from .providers.debug import DebugTokenVerifier as DebugTokenVerifier
|
|
from .providers.jwt import JWTVerifier as JWTVerifier
|
|
from .providers.jwt import StaticTokenVerifier as StaticTokenVerifier
|
|
|
|
|
|
# --- Lazy imports for performance (see #3292) ---
|
|
# These providers pull in heavy deps (authlib, cryptography, key_value.aio,
|
|
# beartype) that most users never need. Keeping them behind __getattr__
|
|
# avoids ~150ms+ of import overhead for the common server-only case.
|
|
# Do not convert these back to top-level imports.
|
|
|
|
|
|
def __getattr__(name: str) -> object:
|
|
if name == "DebugTokenVerifier":
|
|
from .providers.debug import DebugTokenVerifier
|
|
|
|
return DebugTokenVerifier
|
|
if name == "JWTVerifier":
|
|
from .providers.jwt import JWTVerifier
|
|
|
|
return JWTVerifier
|
|
if name == "StaticTokenVerifier":
|
|
from .providers.jwt import StaticTokenVerifier
|
|
|
|
return StaticTokenVerifier
|
|
if name == "IdentityAssertion":
|
|
from .identity_assertion import IdentityAssertion
|
|
|
|
return IdentityAssertion
|
|
if name == "OAuthProxy":
|
|
from .oauth_proxy import OAuthProxy
|
|
|
|
return OAuthProxy
|
|
if name == "OIDCProxy":
|
|
from .oidc_proxy import OIDCProxy
|
|
|
|
return OIDCProxy
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
|
|
|
|
__all__ = [
|
|
"AccessToken",
|
|
"AuthCheck",
|
|
"AuthContext",
|
|
"AuthProvider",
|
|
"DebugTokenVerifier",
|
|
"IdentityAssertion",
|
|
"JWTVerifier",
|
|
"MultiAuth",
|
|
"OAuthProvider",
|
|
"OAuthProxy",
|
|
"OIDCProxy",
|
|
"RemoteAuthProvider",
|
|
"StaticTokenVerifier",
|
|
"TokenVerifier",
|
|
"require_roles",
|
|
"require_scopes",
|
|
"restrict_tag",
|
|
"run_auth_checks",
|
|
]
|