[Authlib] Add integrations dirs (#15147)

This commit is contained in:
Semyon Moroz
2025-12-19 17:22:19 +00:00
committed by GitHub
parent 0483be6983
commit 1f696b82bd
48 changed files with 918 additions and 22 deletions
+12 -11
View File
@@ -47,14 +47,15 @@ authlib.oidc.core.OpenIDImplicitGrant.validate_consent_request
authlib.oidc.core.grants.OpenIDImplicitGrant.validate_consent_request
authlib.oidc.core.grants.implicit.OpenIDImplicitGrant.validate_consent_request
# Exclude integrations dirs:
authlib.integrations.django_client
authlib.integrations.django_oauth1
authlib.integrations.django_oauth2
authlib.integrations.flask_client
authlib.integrations.flask_oauth1
authlib.integrations.flask_oauth2
authlib.integrations.httpx_client
authlib.integrations.requests_client
authlib.integrations.sqla_oauth2
authlib.integrations.starlette_client
# Exclude integrations dirs
# Failed to import, getting ModuleNotFoundError for third-party libs:
authlib.integrations.django_client.*
authlib.integrations.django_oauth1.*
authlib.integrations.django_oauth2.*
authlib.integrations.flask_client.*
authlib.integrations.flask_oauth1.*
authlib.integrations.flask_oauth2.*
authlib.integrations.httpx_client.*
authlib.integrations.requests_client.*
authlib.integrations.sqla_oauth2.*
authlib.integrations.starlette_client.*
-1
View File
@@ -1,4 +1,3 @@
version = "1.6.6"
upstream_repository = "https://github.com/lepture/authlib"
requires = ["cryptography"]
partial_stub = true
@@ -10,4 +10,4 @@ class FrameworkIntegration:
def clear_state_data(self, session, state): ...
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
@staticmethod
def load_config(oauth, name, params) -> None: ...
def load_config(oauth, name, params): ...
@@ -0,0 +1,10 @@
from ..base_client import BaseOAuth, OAuthError as OAuthError
from .apps import DjangoOAuth1App as DjangoOAuth1App, DjangoOAuth2App as DjangoOAuth2App
from .integration import DjangoIntegration as DjangoIntegration, token_update as token_update
class OAuth(BaseOAuth):
oauth1_client_cls = DjangoOAuth1App
oauth2_client_cls = DjangoOAuth2App
framework_integration_cls = DjangoIntegration
__all__ = ["OAuth", "DjangoOAuth1App", "DjangoOAuth2App", "DjangoIntegration", "token_update", "OAuthError"]
@@ -0,0 +1,14 @@
from ..base_client import BaseApp, OAuth1Mixin, OAuth2Mixin, OpenIDMixin
from ..requests_client import OAuth1Session, OAuth2Session
class DjangoAppMixin:
def save_authorize_data(self, request, **kwargs) -> None: ...
def authorize_redirect(self, request, redirect_uri=None, **kwargs): ...
class DjangoOAuth1App(DjangoAppMixin, OAuth1Mixin, BaseApp):
client_cls = OAuth1Session
def authorize_access_token(self, request, **kwargs): ...
class DjangoOAuth2App(DjangoAppMixin, OAuth2Mixin, OpenIDMixin, BaseApp):
client_cls = OAuth2Session
def authorize_access_token(self, request, **kwargs): ...
@@ -0,0 +1,11 @@
from _typeshed import Incomplete
from ..base_client import FrameworkIntegration
# actual type is django.dispatch.Signal
token_update: Incomplete
class DjangoIntegration(FrameworkIntegration):
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
@staticmethod
def load_config(oauth, name, params): ...
@@ -0,0 +1,4 @@
from .authorization_server import BaseServer as BaseServer, CacheAuthorizationServer as CacheAuthorizationServer
from .resource_protector import ResourceProtector as ResourceProtector
__all__ = ["BaseServer", "CacheAuthorizationServer", "ResourceProtector"]
@@ -0,0 +1,26 @@
import logging
from _typeshed import Incomplete
from authlib.oauth1 import AuthorizationServer as _AuthorizationServer, OAuth1Request, TemporaryCredential
log: logging.Logger
class BaseServer(_AuthorizationServer):
token_generator: Incomplete
client_model: Incomplete
token_model: Incomplete
SUPPORTED_SIGNATURE_METHODS: Incomplete
def __init__(self, client_model, token_model, token_generator=None) -> None: ...
def get_client_by_id(self, client_id): ...
def exists_nonce(self, nonce, request) -> bool: ...
def create_token_credential(self, request): ...
def check_authorization_request(self, request) -> OAuth1Request: ...
def create_oauth1_request(self, request) -> OAuth1Request: ...
def handle_response(self, status_code, payload, headers): ...
class CacheAuthorizationServer(BaseServer):
def __init__(self, client_model, token_model, token_generator=None) -> None: ...
def create_temporary_credential(self, request) -> TemporaryCredential: ...
def get_temporary_credential(self, request) -> TemporaryCredential | None: ...
def delete_temporary_credential(self, request) -> None: ...
def create_authorization_verifier(self, request) -> str: ...
@@ -0,0 +1 @@
def exists_nonce_in_cache(nonce, request, timeout) -> bool: ...
@@ -0,0 +1,14 @@
from _typeshed import Incomplete
from authlib.oauth1 import ResourceProtector as _ResourceProtector
class ResourceProtector(_ResourceProtector):
client_model: Incomplete
token_model: Incomplete
SUPPORTED_SIGNATURE_METHODS: Incomplete
def __init__(self, client_model, token_model) -> None: ...
def get_client_by_id(self, client_id): ...
def get_token_credential(self, request): ...
def exists_nonce(self, nonce, request) -> bool: ...
def acquire_credential(self, request): ...
def __call__(self, realm=None): ...
@@ -0,0 +1,8 @@
from .authorization_server import AuthorizationServer as AuthorizationServer
from .endpoints import RevocationEndpoint as RevocationEndpoint
from .resource_protector import BearerTokenValidator as BearerTokenValidator, ResourceProtector as ResourceProtector
from .signals import (
client_authenticated as client_authenticated,
token_authenticated as token_authenticated,
token_revoked as token_revoked,
)
@@ -0,0 +1,24 @@
from _typeshed import Incomplete
from authlib.oauth2 import AuthorizationServer as _AuthorizationServer
from authlib.oauth2.rfc6750 import BearerTokenGenerator
from .requests import DjangoJsonRequest, DjangoOAuth2Request
class AuthorizationServer(_AuthorizationServer):
client_model: Incomplete
token_model: Incomplete
def __init__(self, client_model, token_model) -> None: ...
config: Incomplete
scopes_supported: Incomplete
def load_config(self, config) -> None: ...
def query_client(self, client_id): ...
def save_token(self, token, request): ...
def create_oauth2_request(self, request) -> DjangoOAuth2Request: ...
def create_json_request(self, request) -> DjangoJsonRequest: ...
def handle_response(self, status_code, payload, headers): ...
def send_signal(self, name, *args, **kwargs) -> None: ...
def create_bearer_token_generator(self) -> BearerTokenGenerator: ...
def create_token_generator(token_generator_conf, length: int = 42): ...
def create_token_expires_in_generator(expires_in_conf=None): ...
@@ -0,0 +1,5 @@
from authlib.oauth2.rfc7009 import RevocationEndpoint as _RevocationEndpoint
class RevocationEndpoint(_RevocationEndpoint):
def query_token(self, token, token_type_hint): ...
def revoke_token(self, token, request) -> None: ...
@@ -0,0 +1,20 @@
from authlib.oauth2.rfc6749 import JsonPayload, JsonRequest, OAuth2Payload, OAuth2Request
class DjangoOAuth2Payload(OAuth2Payload):
def __init__(self, request) -> None: ...
class DjangoOAuth2Request(OAuth2Request):
payload: DjangoOAuth2Payload
def __init__(self, request) -> None: ...
@property
def args(self): ...
@property
def form(self): ...
class DjangoJsonPayload(JsonPayload):
def __init__(self, request) -> None: ...
def data(self): ...
class DjangoJsonRequest(JsonRequest):
payload: DjangoJsonPayload
def __init__(self, request) -> None: ...
@@ -0,0 +1,15 @@
from _typeshed import Incomplete
from authlib.oauth2 import ResourceProtector as _ResourceProtector
from authlib.oauth2.rfc6750 import BearerTokenValidator as _BearerTokenValidator
class ResourceProtector(_ResourceProtector):
def acquire_token(self, request, scopes=None, **kwargs): ...
def __call__(self, scopes=None, optional=False, **kwargs): ...
class BearerTokenValidator(_BearerTokenValidator):
token_model: Incomplete
def __init__(self, token_model, realm=None, **extra_attributes): ...
def authenticate_token(self, token_string): ...
def return_error_response(error): ...
@@ -0,0 +1,6 @@
from _typeshed import Incomplete
# actual types is django.dispatch.Signal
client_authenticated: Incomplete
token_revoked: Incomplete
token_authenticated: Incomplete
@@ -0,0 +1,20 @@
from _typeshed import Incomplete
from ..base_client import BaseOAuth, OAuthError as OAuthError
from .apps import FlaskOAuth1App as FlaskOAuth1App, FlaskOAuth2App as FlaskOAuth2App
from .integration import FlaskIntegration as FlaskIntegration, token_update as token_update
class OAuth(BaseOAuth):
oauth1_client_cls = FlaskOAuth1App
oauth2_client_cls = FlaskOAuth2App
framework_integration_cls = FlaskIntegration
app: Incomplete
def __init__(self, app=None, cache=None, fetch_token=None, update_token=None): ...
cache: Incomplete
fetch_token: Incomplete
update_token: Incomplete
def init_app(self, app, cache=None, fetch_token=None, update_token=None): ...
def create_client(self, name): ...
def register(self, name, overwrite=False, **kwargs): ...
__all__ = ["OAuth", "FlaskIntegration", "FlaskOAuth1App", "FlaskOAuth2App", "token_update", "OAuthError"]
@@ -0,0 +1,18 @@
from ..base_client import BaseApp, OAuth1Mixin, OAuth2Mixin, OpenIDMixin
from ..requests_client import OAuth1Session, OAuth2Session
class FlaskAppMixin:
@property
def token(self): ...
@token.setter
def token(self, token): ...
def save_authorize_data(self, **kwargs) -> None: ...
def authorize_redirect(self, redirect_uri=None, **kwargs): ...
class FlaskOAuth1App(FlaskAppMixin, OAuth1Mixin, BaseApp):
client_cls = OAuth1Session
def authorize_access_token(self, **kwargs): ...
class FlaskOAuth2App(FlaskAppMixin, OAuth2Mixin, OpenIDMixin, BaseApp):
client_cls = OAuth2Session
def authorize_access_token(self, **kwargs): ...
@@ -0,0 +1,10 @@
from _typeshed import Incomplete
from ..base_client import FrameworkIntegration
token_update: Incomplete
class FlaskIntegration(FrameworkIntegration):
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
@staticmethod
def load_config(oauth, name, params) -> dict[Incomplete, Incomplete]: ...
@@ -0,0 +1,7 @@
from .authorization_server import AuthorizationServer as AuthorizationServer
from .cache import (
create_exists_nonce_func as create_exists_nonce_func,
register_nonce_hooks as register_nonce_hooks,
register_temporary_credential_hooks as register_temporary_credential_hooks,
)
from .resource_protector import ResourceProtector as ResourceProtector, current_credential as current_credential
@@ -0,0 +1,29 @@
import logging
from _typeshed import Incomplete
from collections.abc import Callable
from authlib.oauth1 import AuthorizationServer as _AuthorizationServer, OAuth1Request
log: logging.Logger
class AuthorizationServer(_AuthorizationServer):
app: Incomplete
query_client: Incomplete
token_generator: Incomplete
def __init__(self, app=None, query_client=None, token_generator=None): ...
SUPPORTED_SIGNATURE_METHODS: Incomplete
def init_app(self, app, query_client=None, token_generator=None): ...
def register_hook(self, name, func) -> None: ...
def create_token_generator(self, app) -> Callable[[], dict[str, str]]: ...
def get_client_by_id(self, client_id): ...
def exists_nonce(self, nonce, request): ...
def create_temporary_credential(self, request): ...
def get_temporary_credential(self, request): ...
def delete_temporary_credential(self, request): ...
def create_authorization_verifier(self, request): ...
def create_token_credential(self, request): ...
def check_authorization_request(self) -> OAuth1Request: ...
def create_authorization_response(self, request=None, grant_user=None): ...
def create_token_response(self, request=None): ...
def create_oauth1_request(self, request) -> OAuth1Request: ...
def handle_response(self, status_code, payload, headers): ...
@@ -0,0 +1,8 @@
from _typeshed import Incomplete
from collections.abc import Callable
def register_temporary_credential_hooks(authorization_server, cache, key_prefix: str = "temporary_credential:") -> None: ...
def create_exists_nonce_func(
cache, key_prefix="nonce:", expires=86400
) -> Callable[[Incomplete, Incomplete, Incomplete, Incomplete], Incomplete]: ...
def register_nonce_hooks(authorization_server, cache, key_prefix: str = "nonce:", expires=86400) -> None: ...
@@ -0,0 +1,18 @@
from _typeshed import Incomplete
from authlib.oauth1 import ResourceProtector as _ResourceProtector
class ResourceProtector(_ResourceProtector):
app: Incomplete
query_client: Incomplete
query_token: Incomplete
def __init__(self, app=None, query_client=None, query_token=None, exists_nonce=None) -> None: ...
SUPPORTED_SIGNATURE_METHODS: Incomplete
def init_app(self, app, query_client=None, query_token=None, exists_nonce=None): ...
def get_client_by_id(self, client_id): ...
def get_token_credential(self, request): ...
def exists_nonce(self, nonce, request): ...
def acquire_credential(self): ...
def __call__(self, scope=None): ...
current_credential: Incomplete
@@ -0,0 +1,7 @@
from .authorization_server import AuthorizationServer as AuthorizationServer
from .resource_protector import ResourceProtector as ResourceProtector, current_token as current_token
from .signals import (
client_authenticated as client_authenticated,
token_authenticated as token_authenticated,
token_revoked as token_revoked,
)
@@ -0,0 +1,23 @@
from _typeshed import Incomplete
from authlib.oauth2 import AuthorizationServer as _AuthorizationServer
from authlib.oauth2.rfc6750 import BearerTokenGenerator
from .requests import FlaskJsonRequest, FlaskOAuth2Request
class AuthorizationServer(_AuthorizationServer):
def __init__(self, app=None, query_client=None, save_token=None) -> None: ...
def init_app(self, app, query_client=None, save_token=None) -> None: ...
scopes_supported: Incomplete
def load_config(self, config) -> None: ...
def query_client(self, client_id): ...
def save_token(self, token, request): ...
def get_error_uri(self, request, error): ...
def create_oauth2_request(self, request) -> FlaskOAuth2Request: ...
def create_json_request(self, request) -> FlaskJsonRequest: ...
def handle_response(self, status_code, payload, headers): ...
def send_signal(self, name, *args, **kwargs) -> None: ...
def create_bearer_token_generator(self, config) -> BearerTokenGenerator: ...
def create_token_expires_in_generator(expires_in_conf=None): ...
def create_token_generator(token_generator_conf, length: int = 42): ...
@@ -0,0 +1,14 @@
from _typeshed import Incomplete
from typing import NoReturn
# Inherits from werkzeug.exceptions.HTTPException
class _HTTPException:
code: Incomplete
body: Incomplete
headers: Incomplete
def __init__(self, code, body, headers, response=None) -> None: ...
# Params depends on `werkzeug` package version
def get_body(self, environ=None, scope=None): ...
def get_headers(self, environ=None, scope=None): ...
def raise_http_exception(status, body, headers) -> NoReturn: ...
@@ -0,0 +1,27 @@
from functools import cached_property
from authlib.oauth2.rfc6749 import JsonPayload, JsonRequest, OAuth2Payload, OAuth2Request
class FlaskOAuth2Payload(OAuth2Payload):
def __init__(self, request) -> None: ...
@property
def data(self): ...
@cached_property
def datalist(self): ...
class FlaskOAuth2Request(OAuth2Request):
payload: FlaskOAuth2Payload
def __init__(self, request) -> None: ...
@property
def args(self): ...
@property
def form(self): ...
class FlaskJsonPayload(JsonPayload):
def __init__(self, request) -> None: ...
@property
def data(self): ...
class FlaskJsonRequest(JsonRequest):
payload: FlaskJsonPayload
def __init__(self, request) -> None: ...
@@ -0,0 +1,15 @@
from _typeshed import Incomplete
from collections.abc import Generator
from contextlib import contextmanager
from typing import NoReturn
from authlib.oauth2 import ResourceProtector as _ResourceProtector
class ResourceProtector(_ResourceProtector):
def raise_error_response(self, error) -> NoReturn: ...
def acquire_token(self, scopes=None, **kwargs): ...
@contextmanager
def acquire(self, scopes=None) -> Generator[Incomplete]: ...
def __call__(self, scopes=None, optional=False, **kwargs): ...
current_token: Incomplete
@@ -0,0 +1,5 @@
from _typeshed import Incomplete
client_authenticated: Incomplete
token_revoked: Incomplete
token_authenticated: Incomplete
@@ -0,0 +1,37 @@
from authlib.oauth1 import (
SIGNATURE_HMAC_SHA1 as SIGNATURE_HMAC_SHA1,
SIGNATURE_PLAINTEXT as SIGNATURE_PLAINTEXT,
SIGNATURE_RSA_SHA1 as SIGNATURE_RSA_SHA1,
SIGNATURE_TYPE_BODY as SIGNATURE_TYPE_BODY,
SIGNATURE_TYPE_HEADER as SIGNATURE_TYPE_HEADER,
SIGNATURE_TYPE_QUERY as SIGNATURE_TYPE_QUERY,
)
from ..base_client import OAuthError as OAuthError
from .assertion_client import AssertionClient as AssertionClient, AsyncAssertionClient as AsyncAssertionClient
from .oauth1_client import AsyncOAuth1Client as AsyncOAuth1Client, OAuth1Auth as OAuth1Auth, OAuth1Client as OAuth1Client
from .oauth2_client import (
AsyncOAuth2Client as AsyncOAuth2Client,
OAuth2Auth as OAuth2Auth,
OAuth2Client as OAuth2Client,
OAuth2ClientAuth as OAuth2ClientAuth,
)
__all__ = [
"OAuthError",
"OAuth1Auth",
"AsyncOAuth1Client",
"OAuth1Client",
"SIGNATURE_HMAC_SHA1",
"SIGNATURE_RSA_SHA1",
"SIGNATURE_PLAINTEXT",
"SIGNATURE_TYPE_HEADER",
"SIGNATURE_TYPE_QUERY",
"SIGNATURE_TYPE_BODY",
"OAuth2Auth",
"OAuth2ClientAuth",
"OAuth2Client",
"AsyncOAuth2Client",
"AssertionClient",
"AsyncAssertionClient",
]
@@ -0,0 +1,50 @@
from _typeshed import Incomplete
from authlib.oauth2.rfc7521 import AssertionClient as _AssertionClient
from ..base_client import OAuthError
from .oauth2_client import OAuth2Auth
__all__ = ["AsyncAssertionClient"]
# Inherits from httpx.AsyncClient
class AsyncAssertionClient(_AssertionClient):
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
JWT_BEARER_GRANT_TYPE: Incomplete
ASSERTION_METHODS: Incomplete
DEFAULT_GRANT_TYPE: Incomplete
def __init__(
self,
token_endpoint,
issuer,
subject,
audience=None,
grant_type=None,
claims=None,
token_placement="header",
scope=None,
**kwargs,
) -> None: ...
async def request(self, method, url, withhold_token=False, auth=..., **kwargs): ...
# Inherits from httpx.Client
class AssertionClient(_AssertionClient):
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
JWT_BEARER_GRANT_TYPE: Incomplete
ASSERTION_METHODS: Incomplete
DEFAULT_GRANT_TYPE: Incomplete
def __init__(
self,
token_endpoint,
issuer,
subject,
audience=None,
grant_type=None,
claims=None,
token_placement="header",
scope=None,
**kwargs,
) -> None: ...
def request(self, method, url, withhold_token=False, auth=..., **kwargs): ...
@@ -0,0 +1,56 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import NoReturn
from typing_extensions import TypeAlias
from authlib.oauth1 import ClientAuth
from authlib.oauth1.client import OAuth1Client as _OAuth1Client
_Response: TypeAlias = Incomplete # actual type is httpx.Response
_Request: TypeAlias = Incomplete # actual type is httpx.Request
# Inherits from httpx.Auth
class OAuth1Auth(ClientAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response, None]: ...
# Inherits from httpx.AsyncClient
class AsyncOAuth1Client(_OAuth1Client):
auth_class = OAuth1Auth
def __init__(
self,
client_id,
client_secret=None,
token=None,
token_secret=None,
redirect_uri=None,
rsa_key=None,
verifier=None,
signature_method=...,
signature_type=...,
force_include_body=False,
**kwargs,
) -> None: ...
async def fetch_access_token(self, url, verifier=None, **kwargs): ...
@staticmethod
def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ...
# Inherits from httpx.Client
class OAuth1Client(_OAuth1Client):
auth_class = OAuth1Auth
def __init__(
self,
client_id,
client_secret=None,
token=None,
token_secret=None,
redirect_uri=None,
rsa_key=None,
verifier=None,
signature_method=...,
signature_type=...,
force_include_body=False,
**kwargs,
) -> None: ...
@staticmethod
def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ...
@@ -0,0 +1,72 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import NoReturn
from typing_extensions import TypeAlias
from authlib.oauth2.auth import ClientAuth, TokenAuth
from authlib.oauth2.client import OAuth2Client as _OAuth2Client
from ..base_client import OAuthError
__all__ = ["OAuth2Auth", "OAuth2ClientAuth", "AsyncOAuth2Client", "OAuth2Client"]
_Response: TypeAlias = Incomplete # actual type is httpx.Response
_Request: TypeAlias = Incomplete # actual type is httpx.Request
# Inherits from httpx.Auth
class OAuth2Auth(TokenAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response, None]: ...
# Inherits from httpx.Auth
class OAuth2ClientAuth(ClientAuth):
requires_request_body: bool
def auth_flow(self, request: _Request) -> Generator[_Request, _Response, None]: ...
# Inherits from httpx.AsyncClient
class AsyncOAuth2Client(_OAuth2Client):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
def __init__(
self,
client_id=None,
client_secret=None,
token_endpoint_auth_method=None,
revocation_endpoint_auth_method=None,
scope=None,
redirect_uri=None,
token=None,
token_placement="header",
update_token=None,
leeway=60,
**kwargs,
) -> None: ...
async def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
async def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs) -> Generator[Incomplete]: ...
async def ensure_active_token(self, token): ... # type: ignore[override]
# Inherits from httpx.Client
class OAuth2Client(_OAuth2Client):
SESSION_REQUEST_PARAMS: list[str]
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
def __init__(
self,
client_id=None,
client_secret=None,
token_endpoint_auth_method=None,
revocation_endpoint_auth_method=None,
scope=None,
redirect_uri=None,
token=None,
token_placement="header",
update_token=None,
**kwargs,
) -> None: ...
@staticmethod
def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ...
def request(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
def stream(self, method, url, withhold_token: bool = False, auth=..., **kwargs): ...
@@ -0,0 +1,7 @@
from _typeshed import Incomplete
from typing import Final
HTTPX_CLIENT_KWARGS: Final[list[str]]
def extract_client_kwargs(kwargs) -> dict[str, Incomplete]: ...
def build_request(url, headers, body, initial_request): ...
@@ -0,0 +1,28 @@
from authlib.oauth1 import (
SIGNATURE_HMAC_SHA1 as SIGNATURE_HMAC_SHA1,
SIGNATURE_PLAINTEXT as SIGNATURE_PLAINTEXT,
SIGNATURE_RSA_SHA1 as SIGNATURE_RSA_SHA1,
SIGNATURE_TYPE_BODY as SIGNATURE_TYPE_BODY,
SIGNATURE_TYPE_HEADER as SIGNATURE_TYPE_HEADER,
SIGNATURE_TYPE_QUERY as SIGNATURE_TYPE_QUERY,
)
from ..base_client import OAuthError as OAuthError
from .assertion_session import AssertionSession as AssertionSession
from .oauth1_session import OAuth1Auth as OAuth1Auth, OAuth1Session as OAuth1Session
from .oauth2_session import OAuth2Auth as OAuth2Auth, OAuth2Session as OAuth2Session
__all__ = [
"OAuthError",
"OAuth1Session",
"OAuth1Auth",
"SIGNATURE_HMAC_SHA1",
"SIGNATURE_RSA_SHA1",
"SIGNATURE_PLAINTEXT",
"SIGNATURE_TYPE_HEADER",
"SIGNATURE_TYPE_QUERY",
"SIGNATURE_TYPE_BODY",
"OAuth2Session",
"OAuth2Auth",
"AssertionSession",
]
@@ -0,0 +1,31 @@
from _typeshed import Incomplete
from authlib.oauth2.rfc7521 import AssertionClient
from .oauth2_session import OAuth2Auth
class AssertionAuth(OAuth2Auth):
def ensure_active_token(self): ...
# Inherits from requests.Session
class AssertionSession(AssertionClient):
token_auth_class = AssertionAuth
JWT_BEARER_GRANT_TYPE: Incomplete
ASSERTION_METHODS: Incomplete
DEFAULT_GRANT_TYPE: Incomplete
default_timeout: Incomplete
def __init__(
self,
token_endpoint,
issuer,
subject,
audience=None,
grant_type=None,
claims=None,
token_placement="header",
scope=None,
default_timeout=None,
leeway=60,
**kwargs,
) -> None: ...
def request(self, method, url, withhold_token=False, auth=None, **kwargs): ...
@@ -0,0 +1,29 @@
from typing import NoReturn
from authlib.oauth1 import ClientAuth
from authlib.oauth1.client import OAuth1Client
# Inherits from requests.auth.AuthBase
class OAuth1Auth(ClientAuth):
def __call__(self, req): ...
# Inherits from requests.Session
class OAuth1Session(OAuth1Client):
auth_class = OAuth1Auth
def __init__(
self,
client_id,
client_secret=None,
token=None,
token_secret=None,
redirect_uri=None,
rsa_key=None,
verifier=None,
signature_method=...,
signature_type=...,
force_include_body=False,
**kwargs,
) -> None: ...
def rebuild_auth(self, prepared_request, response) -> None: ...
@staticmethod
def handle_error(error_type: str | None, error_description: str | None) -> NoReturn: ...
@@ -0,0 +1,43 @@
from _typeshed import Incomplete
from authlib.oauth2.auth import ClientAuth, TokenAuth
from authlib.oauth2.client import OAuth2Client
from ..base_client import OAuthError
__all__ = ["OAuth2Session", "OAuth2Auth"]
# Inherits from requests.auth.AuthBase
class OAuth2Auth(TokenAuth):
def ensure_active_token(self) -> None: ...
def __call__(self, req): ...
# Inherits from requests.auth.AuthBase
class OAuth2ClientAuth(ClientAuth):
def __call__(self, req): ...
# Inherits from requests.Session
class OAuth2Session(OAuth2Client):
client_auth_class = OAuth2ClientAuth
token_auth_class = OAuth2Auth
oauth_error_class = OAuthError # type: ignore[assignment]
SESSION_REQUEST_PARAMS: tuple[str, ...]
default_timeout: Incomplete
def __init__(
self,
client_id=None,
client_secret=None,
token_endpoint_auth_method=None,
revocation_endpoint_auth_method=None,
scope=None,
state=None,
redirect_uri=None,
token=None,
token_placement="header",
update_token=None,
leeway=60,
default_timeout=None,
**kwargs,
) -> None: ...
def fetch_access_token(self, url=None, **kwargs): ...
def request(self, method, url, withhold_token=False, auth=None, **kwargs): ...
@@ -0,0 +1,6 @@
from _typeshed import Incomplete
from typing import Final
REQUESTS_SESSION_KWARGS: Final = ["proxies", "hooks", "stream", "verify", "cert", "max_redirects", "trust_env"]
def update_session_configure(session, kwargs: dict[str, Incomplete]) -> None: ...
@@ -0,0 +1,20 @@
from .client_mixin import OAuth2ClientMixin as OAuth2ClientMixin
from .functions import (
create_bearer_token_validator as create_bearer_token_validator,
create_query_client_func as create_query_client_func,
create_query_token_func as create_query_token_func,
create_revocation_endpoint as create_revocation_endpoint,
create_save_token_func as create_save_token_func,
)
from .tokens_mixins import OAuth2AuthorizationCodeMixin as OAuth2AuthorizationCodeMixin, OAuth2TokenMixin as OAuth2TokenMixin
__all__ = [
"OAuth2ClientMixin",
"OAuth2AuthorizationCodeMixin",
"OAuth2TokenMixin",
"create_query_client_func",
"create_save_token_func",
"create_query_token_func",
"create_revocation_endpoint",
"create_bearer_token_validator",
]
@@ -0,0 +1,55 @@
from _typeshed import Incomplete
from authlib.oauth2.rfc6749 import ClientMixin
class OAuth2ClientMixin(ClientMixin):
client_id: Incomplete
client_secret: Incomplete
client_id_issued_at: Incomplete
client_secret_expires_at: Incomplete
_client_metadata: Incomplete
@property
def client_info(self) -> dict[str, Incomplete]: ...
@property
def client_metadata(self): ...
def set_client_metadata(self, value) -> None: ...
@property
def redirect_uris(self): ...
@property
def token_endpoint_auth_method(self): ...
@property
def grant_types(self): ...
@property
def response_types(self): ...
@property
def client_name(self): ...
@property
def client_uri(self): ...
@property
def logo_uri(self): ...
@property
def scope(self): ...
@property
def contacts(self): ...
@property
def tos_uri(self): ...
@property
def policy_uri(self): ...
@property
def jwks_uri(self): ...
@property
def jwks(self): ...
@property
def software_id(self): ...
@property
def software_version(self): ...
@property
def id_token_signed_response_alg(self): ...
def get_client_id(self): ...
def get_default_redirect_uri(self): ...
def get_allowed_scope(self, scope) -> str: ...
def check_redirect_uri(self, redirect_uri) -> bool: ...
def check_client_secret(self, client_secret) -> bool: ...
def check_endpoint_auth_method(self, method, endpoint) -> bool: ...
def check_response_type(self, response_type) -> bool: ...
def check_grant_type(self, grant_type) -> bool: ...
@@ -0,0 +1,21 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import type_check_only
from authlib.oauth2.rfc6750 import BearerTokenValidator
from authlib.oauth2.rfc7009 import RevocationEndpoint
@type_check_only
class _RevocationEndpoint(RevocationEndpoint):
def query_token(self, token, token_type_hint): ...
def revoke_token(self, token, request) -> None: ...
@type_check_only
class _BearerTokenValidator(BearerTokenValidator):
def authenticate_token(self, token_string): ...
def create_query_client_func(session, client_model) -> Callable[[Incomplete], Incomplete]: ...
def create_save_token_func(session, token_model) -> Callable[[Incomplete, Incomplete], None]: ...
def create_query_token_func(session, token_model) -> Callable[[Incomplete, Incomplete], Incomplete]: ...
def create_revocation_endpoint(session, token_model) -> type[_RevocationEndpoint]: ...
def create_bearer_token_validator(session, token_model) -> type[_BearerTokenValidator]: ...
@@ -0,0 +1,39 @@
from _typeshed import Incomplete
from authlib.oauth2.rfc6749 import AuthorizationCodeMixin, TokenMixin
class OAuth2AuthorizationCodeMixin(AuthorizationCodeMixin):
code: Incomplete
client_id: Incomplete
redirect_uri: Incomplete
response_type: Incomplete
scope: Incomplete
nonce: Incomplete
auth_time: Incomplete
acr: Incomplete
amr: Incomplete
code_challenge: Incomplete
code_challenge_method: Incomplete
def is_expired(self) -> bool: ...
def get_redirect_uri(self): ...
def get_scope(self): ...
def get_auth_time(self): ...
def get_acr(self): ...
def get_amr(self): ...
def get_nonce(self): ...
class OAuth2TokenMixin(TokenMixin):
client_id: Incomplete
token_type: Incomplete
access_token: Incomplete
refresh_token: Incomplete
scope: Incomplete
issued_at: Incomplete
access_token_revoked_at: Incomplete
refresh_token_revoked_at: Incomplete
expires_in: Incomplete
def check_client(self, client) -> bool: ...
def get_scope(self): ...
def get_expires_in(self): ...
def is_revoked(self): ...
def is_expired(self) -> bool: ...
@@ -0,0 +1,14 @@
from _typeshed import Incomplete
from ..base_client import BaseOAuth, OAuthError as OAuthError
from .apps import StarletteOAuth1App as StarletteOAuth1App, StarletteOAuth2App as StarletteOAuth2App
from .integration import StarletteIntegration as StarletteIntegration
class OAuth(BaseOAuth):
oauth1_client_cls = StarletteOAuth1App
oauth2_client_cls = StarletteOAuth2App
framework_integration_cls = StarletteIntegration
config: Incomplete
def __init__(self, config=None, cache=None, fetch_token=None, update_token=None) -> None: ...
__all__ = ["OAuth", "OAuthError", "StarletteIntegration", "StarletteOAuth1App", "StarletteOAuth2App"]
@@ -0,0 +1,16 @@
from ..base_client import BaseApp
from ..base_client.async_app import AsyncOAuth1Mixin, AsyncOAuth2Mixin
from ..base_client.async_openid import AsyncOpenIDMixin
from ..httpx_client import AsyncOAuth1Client, AsyncOAuth2Client
class StarletteAppMixin:
async def save_authorize_data(self, request, **kwargs) -> None: ...
async def authorize_redirect(self, request, redirect_uri=None, **kwargs): ...
class StarletteOAuth1App(StarletteAppMixin, AsyncOAuth1Mixin, BaseApp):
client_cls = AsyncOAuth1Client
async def authorize_access_token(self, request, **kwargs): ...
class StarletteOAuth2App(StarletteAppMixin, AsyncOAuth2Mixin, AsyncOpenIDMixin, BaseApp):
client_cls = AsyncOAuth2Client
async def authorize_access_token(self, request, **kwargs): ...
@@ -0,0 +1,13 @@
from _typeshed import Incomplete
from typing import Any
from ..base_client import FrameworkIntegration
class StarletteIntegration(FrameworkIntegration):
# annotated by source code
async def get_state_data(self, session: dict[str, Any] | None, state: str) -> dict[str, Any]: ...
async def set_state_data(self, session: dict[str, Any] | None, state: str, data: Any) -> None: ...
async def clear_state_data(self, session: dict[str, Any] | None, state: str) -> None: ...
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
@staticmethod
def load_config(oauth, name, params) -> dict[Incomplete, Incomplete]: ...
@@ -5,8 +5,8 @@ from authlib.oauth1.rfc5849.base_server import BaseServer
class AuthorizationServer(BaseServer):
TOKEN_RESPONSE_HEADER: Incomplete
TEMPORARY_CREDENTIALS_METHOD: str
def create_oauth1_request(self, request) -> None: ...
def handle_response(self, status_code, payload, headers) -> None: ...
def create_oauth1_request(self, request): ...
def handle_response(self, status_code, payload, headers): ...
def handle_error_response(self, error): ...
def validate_temporary_credentials_request(self, request): ...
def create_temporary_credentials_response(self, request=None): ...
@@ -14,8 +14,8 @@ class AuthorizationServer(BaseServer):
def create_authorization_response(self, request, grant_user=None): ...
def validate_token_request(self, request): ...
def create_token_response(self, request): ...
def create_temporary_credential(self, request) -> None: ...
def get_temporary_credential(self, request) -> None: ...
def delete_temporary_credential(self, request) -> None: ...
def create_authorization_verifier(self, request) -> None: ...
def create_token_credential(self, request) -> None: ...
def create_temporary_credential(self, request): ...
def get_temporary_credential(self, request): ...
def delete_temporary_credential(self, request): ...
def create_authorization_verifier(self, request): ...
def create_token_credential(self, request): ...
@@ -8,5 +8,5 @@ class BaseServer:
def register_signature_method(cls, name, verify) -> None: ...
def validate_timestamp_and_nonce(self, request) -> None: ...
def validate_oauth_signature(self, request) -> None: ...
def get_client_by_id(self, client_id) -> None: ...
def exists_nonce(self, nonce, request) -> None: ...
def get_client_by_id(self, client_id): ...
def exists_nonce(self, nonce, request): ...