diff --git a/stubs/Authlib/@tests/stubtest_allowlist.txt b/stubs/Authlib/@tests/stubtest_allowlist.txt index 5ef79bb6121f..f6fa5a1738fa 100644 --- a/stubs/Authlib/@tests/stubtest_allowlist.txt +++ b/stubs/Authlib/@tests/stubtest_allowlist.txt @@ -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.* diff --git a/stubs/Authlib/METADATA.toml b/stubs/Authlib/METADATA.toml index 1430fbd476a5..b8a8459de205 100644 --- a/stubs/Authlib/METADATA.toml +++ b/stubs/Authlib/METADATA.toml @@ -1,4 +1,3 @@ version = "1.6.6" upstream_repository = "https://github.com/lepture/authlib" requires = ["cryptography"] -partial_stub = true diff --git a/stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi b/stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi index c6252514276e..2cf271becba0 100644 --- a/stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi +++ b/stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_client/__init__.pyi b/stubs/Authlib/authlib/integrations/django_client/__init__.pyi new file mode 100644 index 000000000000..c5c48e4777c5 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_client/__init__.pyi @@ -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"] diff --git a/stubs/Authlib/authlib/integrations/django_client/apps.pyi b/stubs/Authlib/authlib/integrations/django_client/apps.pyi new file mode 100644 index 000000000000..895db81ec120 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_client/apps.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_client/integration.pyi b/stubs/Authlib/authlib/integrations/django_client/integration.pyi new file mode 100644 index 000000000000..91469e1953da --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_client/integration.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth1/__init__.pyi b/stubs/Authlib/authlib/integrations/django_oauth1/__init__.pyi new file mode 100644 index 000000000000..3c684184a795 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth1/__init__.pyi @@ -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"] diff --git a/stubs/Authlib/authlib/integrations/django_oauth1/authorization_server.pyi b/stubs/Authlib/authlib/integrations/django_oauth1/authorization_server.pyi new file mode 100644 index 000000000000..2d4b0bacaca5 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth1/authorization_server.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth1/nonce.pyi b/stubs/Authlib/authlib/integrations/django_oauth1/nonce.pyi new file mode 100644 index 000000000000..b4d93191444c --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth1/nonce.pyi @@ -0,0 +1 @@ +def exists_nonce_in_cache(nonce, request, timeout) -> bool: ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth1/resource_protector.pyi b/stubs/Authlib/authlib/integrations/django_oauth1/resource_protector.pyi new file mode 100644 index 000000000000..d3e3f568d21b --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth1/resource_protector.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/__init__.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/__init__.pyi new file mode 100644 index 000000000000..d627f322cf4d --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/__init__.pyi @@ -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, +) diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/authorization_server.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/authorization_server.pyi new file mode 100644 index 000000000000..cecb3d9ae968 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/authorization_server.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/endpoints.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/endpoints.pyi new file mode 100644 index 000000000000..9eb7a277a46b --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/endpoints.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/requests.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/requests.pyi new file mode 100644 index 000000000000..05006392b374 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/requests.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/resource_protector.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/resource_protector.pyi new file mode 100644 index 000000000000..1538f368ca44 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/resource_protector.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/django_oauth2/signals.pyi b/stubs/Authlib/authlib/integrations/django_oauth2/signals.pyi new file mode 100644 index 000000000000..c5e48ddef194 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/django_oauth2/signals.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +# actual types is django.dispatch.Signal +client_authenticated: Incomplete +token_revoked: Incomplete +token_authenticated: Incomplete diff --git a/stubs/Authlib/authlib/integrations/flask_client/__init__.pyi b/stubs/Authlib/authlib/integrations/flask_client/__init__.pyi new file mode 100644 index 000000000000..575d8ae26f86 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_client/__init__.pyi @@ -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"] diff --git a/stubs/Authlib/authlib/integrations/flask_client/apps.pyi b/stubs/Authlib/authlib/integrations/flask_client/apps.pyi new file mode 100644 index 000000000000..b0225ab249aa --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_client/apps.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/flask_client/integration.pyi b/stubs/Authlib/authlib/integrations/flask_client/integration.pyi new file mode 100644 index 000000000000..7bcacdd47d99 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_client/integration.pyi @@ -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]: ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth1/__init__.pyi b/stubs/Authlib/authlib/integrations/flask_oauth1/__init__.pyi new file mode 100644 index 000000000000..fbe0b2b0ad44 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth1/__init__.pyi @@ -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 diff --git a/stubs/Authlib/authlib/integrations/flask_oauth1/authorization_server.pyi b/stubs/Authlib/authlib/integrations/flask_oauth1/authorization_server.pyi new file mode 100644 index 000000000000..1a4f39d999a9 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth1/authorization_server.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth1/cache.pyi b/stubs/Authlib/authlib/integrations/flask_oauth1/cache.pyi new file mode 100644 index 000000000000..a88e4f9bcd6f --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth1/cache.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth1/resource_protector.pyi b/stubs/Authlib/authlib/integrations/flask_oauth1/resource_protector.pyi new file mode 100644 index 000000000000..dec0175c3059 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth1/resource_protector.pyi @@ -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 diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/__init__.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/__init__.pyi new file mode 100644 index 000000000000..ba510bf3a322 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/__init__.pyi @@ -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, +) diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/authorization_server.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/authorization_server.pyi new file mode 100644 index 000000000000..3856935af6cf --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/authorization_server.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/errors.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/errors.pyi new file mode 100644 index 000000000000..258839271bd5 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/errors.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/requests.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/requests.pyi new file mode 100644 index 000000000000..f2e657d31aa6 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/requests.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/resource_protector.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/resource_protector.pyi new file mode 100644 index 000000000000..a4c4928a04df --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/resource_protector.pyi @@ -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 diff --git a/stubs/Authlib/authlib/integrations/flask_oauth2/signals.pyi b/stubs/Authlib/authlib/integrations/flask_oauth2/signals.pyi new file mode 100644 index 000000000000..f64d46c1d023 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/flask_oauth2/signals.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +client_authenticated: Incomplete +token_revoked: Incomplete +token_authenticated: Incomplete diff --git a/stubs/Authlib/authlib/integrations/httpx_client/__init__.pyi b/stubs/Authlib/authlib/integrations/httpx_client/__init__.pyi new file mode 100644 index 000000000000..58b88a90fb2d --- /dev/null +++ b/stubs/Authlib/authlib/integrations/httpx_client/__init__.pyi @@ -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", +] diff --git a/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi new file mode 100644 index 000000000000..f2061d98aedf --- /dev/null +++ b/stubs/Authlib/authlib/integrations/httpx_client/assertion_client.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi new file mode 100644 index 000000000000..1160db3b44c9 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth1_client.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi new file mode 100644 index 000000000000..79d45bd3c2af --- /dev/null +++ b/stubs/Authlib/authlib/integrations/httpx_client/oauth2_client.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi new file mode 100644 index 000000000000..d4e4547e4470 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/httpx_client/utils.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/__init__.pyi b/stubs/Authlib/authlib/integrations/requests_client/__init__.pyi new file mode 100644 index 000000000000..fc7b705e0ce0 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/requests_client/__init__.pyi @@ -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", +] diff --git a/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi b/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi new file mode 100644 index 000000000000..87f9ae004384 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/requests_client/assertion_session.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/oauth1_session.pyi b/stubs/Authlib/authlib/integrations/requests_client/oauth1_session.pyi new file mode 100644 index 000000000000..deead135e951 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/requests_client/oauth1_session.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi b/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi new file mode 100644 index 000000000000..63cae01d2b0a --- /dev/null +++ b/stubs/Authlib/authlib/integrations/requests_client/oauth2_session.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/requests_client/utils.pyi b/stubs/Authlib/authlib/integrations/requests_client/utils.pyi new file mode 100644 index 000000000000..f93f9a06f07b --- /dev/null +++ b/stubs/Authlib/authlib/integrations/requests_client/utils.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/sqla_oauth2/__init__.pyi b/stubs/Authlib/authlib/integrations/sqla_oauth2/__init__.pyi new file mode 100644 index 000000000000..364a0a9fb2eb --- /dev/null +++ b/stubs/Authlib/authlib/integrations/sqla_oauth2/__init__.pyi @@ -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", +] diff --git a/stubs/Authlib/authlib/integrations/sqla_oauth2/client_mixin.pyi b/stubs/Authlib/authlib/integrations/sqla_oauth2/client_mixin.pyi new file mode 100644 index 000000000000..94606b7d19e5 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/sqla_oauth2/client_mixin.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/sqla_oauth2/functions.pyi b/stubs/Authlib/authlib/integrations/sqla_oauth2/functions.pyi new file mode 100644 index 000000000000..0590b36eda08 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/sqla_oauth2/functions.pyi @@ -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]: ... diff --git a/stubs/Authlib/authlib/integrations/sqla_oauth2/tokens_mixins.pyi b/stubs/Authlib/authlib/integrations/sqla_oauth2/tokens_mixins.pyi new file mode 100644 index 000000000000..25166d5f0f4c --- /dev/null +++ b/stubs/Authlib/authlib/integrations/sqla_oauth2/tokens_mixins.pyi @@ -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: ... diff --git a/stubs/Authlib/authlib/integrations/starlette_client/__init__.pyi b/stubs/Authlib/authlib/integrations/starlette_client/__init__.pyi new file mode 100644 index 000000000000..ea654f6f55bd --- /dev/null +++ b/stubs/Authlib/authlib/integrations/starlette_client/__init__.pyi @@ -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"] diff --git a/stubs/Authlib/authlib/integrations/starlette_client/apps.pyi b/stubs/Authlib/authlib/integrations/starlette_client/apps.pyi new file mode 100644 index 000000000000..c5118f638285 --- /dev/null +++ b/stubs/Authlib/authlib/integrations/starlette_client/apps.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/integrations/starlette_client/integration.pyi b/stubs/Authlib/authlib/integrations/starlette_client/integration.pyi new file mode 100644 index 000000000000..6848c50141ee --- /dev/null +++ b/stubs/Authlib/authlib/integrations/starlette_client/integration.pyi @@ -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]: ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi index 894cd4646f82..5b124285c50b 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/authorization_server.pyi @@ -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): ... diff --git a/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi b/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi index 17f8ad953126..2508c953034e 100644 --- a/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi +++ b/stubs/Authlib/authlib/oauth1/rfc5849/base_server.pyi @@ -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): ...