Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions stubs/Authlib/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 0 additions & 1 deletion stubs/Authlib/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version = "1.6.6"
upstream_repository = "https://github.com/lepture/authlib"
requires = ["cryptography"]
partial_stub = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I hastily removed this flag (#14368 #14394), but it seems now is the time for it

Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
10 changes: 10 additions & 0 deletions stubs/Authlib/authlib/integrations/django_client/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 14 additions & 0 deletions stubs/Authlib/authlib/integrations/django_client/apps.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
11 changes: 11 additions & 0 deletions stubs/Authlib/authlib/integrations/django_client/integration.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
4 changes: 4 additions & 0 deletions stubs/Authlib/authlib/integrations/django_oauth1/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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: ...
1 change: 1 addition & 0 deletions stubs/Authlib/authlib/integrations/django_oauth1/nonce.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def exists_nonce_in_cache(nonce, request, timeout) -> bool: ...
Original file line number Diff line number Diff line change
@@ -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): ...
8 changes: 8 additions & 0 deletions stubs/Authlib/authlib/integrations/django_oauth2/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
@@ -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): ...
Original file line number Diff line number Diff line change
@@ -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: ...
20 changes: 20 additions & 0 deletions stubs/Authlib/authlib/integrations/django_oauth2/requests.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Original file line number Diff line number Diff line change
@@ -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): ...
6 changes: 6 additions & 0 deletions stubs/Authlib/authlib/integrations/django_oauth2/signals.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from _typeshed import Incomplete

# actual types is django.dispatch.Signal
client_authenticated: Incomplete
token_revoked: Incomplete
token_authenticated: Incomplete
20 changes: 20 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_client/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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"]
18 changes: 18 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_client/apps.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
10 changes: 10 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_client/integration.pyi
Original file line number Diff line number Diff line change
@@ -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]: ...
7 changes: 7 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_oauth1/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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): ...
8 changes: 8 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_oauth1/cache.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_oauth2/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
@@ -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): ...
14 changes: 14 additions & 0 deletions stubs/Authlib/authlib/integrations/flask_oauth2/errors.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Loading