Skip to content

Commit 1f696b8

Browse files
authored
[Authlib] Add integrations dirs (#15147)
1 parent 0483be6 commit 1f696b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+918
-22
lines changed

stubs/Authlib/@tests/stubtest_allowlist.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ authlib.oidc.core.OpenIDImplicitGrant.validate_consent_request
4747
authlib.oidc.core.grants.OpenIDImplicitGrant.validate_consent_request
4848
authlib.oidc.core.grants.implicit.OpenIDImplicitGrant.validate_consent_request
4949

50-
# Exclude integrations dirs:
51-
authlib.integrations.django_client
52-
authlib.integrations.django_oauth1
53-
authlib.integrations.django_oauth2
54-
authlib.integrations.flask_client
55-
authlib.integrations.flask_oauth1
56-
authlib.integrations.flask_oauth2
57-
authlib.integrations.httpx_client
58-
authlib.integrations.requests_client
59-
authlib.integrations.sqla_oauth2
60-
authlib.integrations.starlette_client
50+
# Exclude integrations dirs
51+
# Failed to import, getting ModuleNotFoundError for third-party libs:
52+
authlib.integrations.django_client.*
53+
authlib.integrations.django_oauth1.*
54+
authlib.integrations.django_oauth2.*
55+
authlib.integrations.flask_client.*
56+
authlib.integrations.flask_oauth1.*
57+
authlib.integrations.flask_oauth2.*
58+
authlib.integrations.httpx_client.*
59+
authlib.integrations.requests_client.*
60+
authlib.integrations.sqla_oauth2.*
61+
authlib.integrations.starlette_client.*

stubs/Authlib/METADATA.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
version = "1.6.6"
22
upstream_repository = "https://github.com/lepture/authlib"
33
requires = ["cryptography"]
4-
partial_stub = true

stubs/Authlib/authlib/integrations/base_client/framework_integration.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class FrameworkIntegration:
1010
def clear_state_data(self, session, state): ...
1111
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
1212
@staticmethod
13-
def load_config(oauth, name, params) -> None: ...
13+
def load_config(oauth, name, params): ...
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from ..base_client import BaseOAuth, OAuthError as OAuthError
2+
from .apps import DjangoOAuth1App as DjangoOAuth1App, DjangoOAuth2App as DjangoOAuth2App
3+
from .integration import DjangoIntegration as DjangoIntegration, token_update as token_update
4+
5+
class OAuth(BaseOAuth):
6+
oauth1_client_cls = DjangoOAuth1App
7+
oauth2_client_cls = DjangoOAuth2App
8+
framework_integration_cls = DjangoIntegration
9+
10+
__all__ = ["OAuth", "DjangoOAuth1App", "DjangoOAuth2App", "DjangoIntegration", "token_update", "OAuthError"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from ..base_client import BaseApp, OAuth1Mixin, OAuth2Mixin, OpenIDMixin
2+
from ..requests_client import OAuth1Session, OAuth2Session
3+
4+
class DjangoAppMixin:
5+
def save_authorize_data(self, request, **kwargs) -> None: ...
6+
def authorize_redirect(self, request, redirect_uri=None, **kwargs): ...
7+
8+
class DjangoOAuth1App(DjangoAppMixin, OAuth1Mixin, BaseApp):
9+
client_cls = OAuth1Session
10+
def authorize_access_token(self, request, **kwargs): ...
11+
12+
class DjangoOAuth2App(DjangoAppMixin, OAuth2Mixin, OpenIDMixin, BaseApp):
13+
client_cls = OAuth2Session
14+
def authorize_access_token(self, request, **kwargs): ...
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from _typeshed import Incomplete
2+
3+
from ..base_client import FrameworkIntegration
4+
5+
# actual type is django.dispatch.Signal
6+
token_update: Incomplete
7+
8+
class DjangoIntegration(FrameworkIntegration):
9+
def update_token(self, token, refresh_token=None, access_token=None) -> None: ...
10+
@staticmethod
11+
def load_config(oauth, name, params): ...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .authorization_server import BaseServer as BaseServer, CacheAuthorizationServer as CacheAuthorizationServer
2+
from .resource_protector import ResourceProtector as ResourceProtector
3+
4+
__all__ = ["BaseServer", "CacheAuthorizationServer", "ResourceProtector"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import logging
2+
from _typeshed import Incomplete
3+
4+
from authlib.oauth1 import AuthorizationServer as _AuthorizationServer, OAuth1Request, TemporaryCredential
5+
6+
log: logging.Logger
7+
8+
class BaseServer(_AuthorizationServer):
9+
token_generator: Incomplete
10+
client_model: Incomplete
11+
token_model: Incomplete
12+
SUPPORTED_SIGNATURE_METHODS: Incomplete
13+
def __init__(self, client_model, token_model, token_generator=None) -> None: ...
14+
def get_client_by_id(self, client_id): ...
15+
def exists_nonce(self, nonce, request) -> bool: ...
16+
def create_token_credential(self, request): ...
17+
def check_authorization_request(self, request) -> OAuth1Request: ...
18+
def create_oauth1_request(self, request) -> OAuth1Request: ...
19+
def handle_response(self, status_code, payload, headers): ...
20+
21+
class CacheAuthorizationServer(BaseServer):
22+
def __init__(self, client_model, token_model, token_generator=None) -> None: ...
23+
def create_temporary_credential(self, request) -> TemporaryCredential: ...
24+
def get_temporary_credential(self, request) -> TemporaryCredential | None: ...
25+
def delete_temporary_credential(self, request) -> None: ...
26+
def create_authorization_verifier(self, request) -> str: ...
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def exists_nonce_in_cache(nonce, request, timeout) -> bool: ...
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from _typeshed import Incomplete
2+
3+
from authlib.oauth1 import ResourceProtector as _ResourceProtector
4+
5+
class ResourceProtector(_ResourceProtector):
6+
client_model: Incomplete
7+
token_model: Incomplete
8+
SUPPORTED_SIGNATURE_METHODS: Incomplete
9+
def __init__(self, client_model, token_model) -> None: ...
10+
def get_client_by_id(self, client_id): ...
11+
def get_token_credential(self, request): ...
12+
def exists_nonce(self, nonce, request) -> bool: ...
13+
def acquire_credential(self, request): ...
14+
def __call__(self, realm=None): ...

0 commit comments

Comments
 (0)