Skip to content

Commit 1552ada

Browse files
authored
Improve oauthlib (#13794)
1 parent 9f3310f commit 1552ada

15 files changed

Lines changed: 92 additions & 68 deletions

File tree

stubs/oauthlib/oauthlib/oauth1/rfc5849/__init__.pyi

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from collections.abc import Callable
3+
from logging import Logger
4+
from typing import Any, Final
35

4-
log: Any
5-
SIGNATURE_HMAC_SHA1: str
6-
SIGNATURE_HMAC_SHA256: str
7-
SIGNATURE_HMAC_SHA512: str
8-
SIGNATURE_HMAC: str
9-
SIGNATURE_RSA_SHA1: str
10-
SIGNATURE_RSA_SHA256: str
11-
SIGNATURE_RSA_SHA512: str
12-
SIGNATURE_RSA: str
13-
SIGNATURE_PLAINTEXT: str
14-
SIGNATURE_METHODS: Any
15-
SIGNATURE_TYPE_AUTH_HEADER: str
16-
SIGNATURE_TYPE_QUERY: str
17-
SIGNATURE_TYPE_BODY: str
18-
CONTENT_TYPE_FORM_URLENCODED: str
6+
log: Logger
7+
SIGNATURE_HMAC_SHA1: Final[str]
8+
SIGNATURE_HMAC_SHA256: Final[str]
9+
SIGNATURE_HMAC_SHA512: Final[str]
10+
SIGNATURE_HMAC: Final[str]
11+
SIGNATURE_RSA_SHA1: Final[str]
12+
SIGNATURE_RSA_SHA256: Final[str]
13+
SIGNATURE_RSA_SHA512: Final[str]
14+
SIGNATURE_RSA: Final[str]
15+
SIGNATURE_PLAINTEXT: Final[str]
16+
SIGNATURE_METHODS: Final[tuple[str, str, str, str, str, str, str]]
17+
SIGNATURE_TYPE_AUTH_HEADER: Final[str]
18+
SIGNATURE_TYPE_QUERY: Final[str]
19+
SIGNATURE_TYPE_BODY: Final[str]
20+
CONTENT_TYPE_FORM_URLENCODED: Final[str]
1921

2022
class Client:
21-
SIGNATURE_METHODS: Any
23+
SIGNATURE_METHODS: dict[str, Callable[[str, Incomplete], str]]
2224
@classmethod
2325
def register_signature_method(cls, method_name, method_callback) -> None: ...
2426
client_key: Any
@@ -37,8 +39,8 @@ class Client:
3739
timestamp: Any
3840
def __init__(
3941
self,
40-
client_key,
41-
client_secret: Incomplete | None = None,
42+
client_key: str,
43+
client_secret: str | None = None,
4244
resource_owner_key: Incomplete | None = None,
4345
resource_owner_secret: Incomplete | None = None,
4446
callback_uri: Incomplete | None = None,
@@ -58,7 +60,7 @@ class Client:
5860
self,
5961
uri,
6062
http_method: str = "GET",
61-
body: Incomplete | None = None,
62-
headers: Incomplete | None = None,
63+
body: str | None = None,
64+
headers: dict[str, str] | None = None,
6365
realm: Incomplete | None = None,
6466
): ...

stubs/oauthlib/oauthlib/oauth1/rfc5849/endpoints/access_token.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from logging import Logger
33

44
from .base import BaseEndpoint as BaseEndpoint
55

6-
log: Any
6+
log: Logger
77

88
class AccessTokenEndpoint(BaseEndpoint):
99
def create_access_token(self, request, credentials): ...

stubs/oauthlib/oauthlib/oauth1/rfc5849/endpoints/request_token.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from logging import Logger
33

44
from .base import BaseEndpoint as BaseEndpoint
55

6-
log: Any
6+
log: Logger
77

88
class RequestTokenEndpoint(BaseEndpoint):
99
def create_request_token(self, request, credentials): ...

stubs/oauthlib/oauthlib/oauth1/rfc5849/endpoints/resource.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from logging import Logger
33

44
from .base import BaseEndpoint as BaseEndpoint
55

6-
log: Any
6+
log: Logger
77

88
class ResourceEndpoint(BaseEndpoint):
99
def validate_protected_resource_request(

stubs/oauthlib/oauthlib/oauth1/rfc5849/endpoints/signature_only.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from logging import Logger
33

44
from .base import BaseEndpoint as BaseEndpoint
55

6-
log: Any
6+
log: Logger
77

88
class SignatureOnlyEndpoint(BaseEndpoint):
99
def validate_request(
Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
1-
from _typeshed import Incomplete
2-
from typing import Any
1+
from _typeshed import Incomplete, Unused
2+
from collections.abc import Iterable
3+
from logging import Logger
34

4-
log: Any
5+
from oauthlib.common import Request, _HTTPMethod
56

6-
def signature_base_string(http_method: str, base_str_uri: str, normalized_encoded_request_parameters: str) -> str: ...
7+
log: Logger
8+
9+
def signature_base_string(http_method: _HTTPMethod, base_str_uri: str, normalized_encoded_request_parameters: str) -> str: ...
710
def base_string_uri(uri: str, host: str | None = None) -> str: ...
811
def collect_parameters(
912
uri_query: str = "",
10-
body: Incomplete | None = None,
11-
headers: Incomplete | None = None,
13+
body: str | bytes | dict[str, str] | Iterable[tuple[str, str]] | None = None,
14+
headers: dict[str, str] | None = None,
1215
exclude_oauth_signature: bool = True,
1316
with_realm: bool = False,
14-
): ...
15-
def normalize_parameters(params) -> str: ...
16-
def sign_hmac_sha1_with_client(sig_base_str, client): ...
17-
def verify_hmac_sha1(request, client_secret: Incomplete | None = None, resource_owner_secret: Incomplete | None = None): ...
18-
def sign_hmac_sha1(base_string, client_secret, resource_owner_secret): ...
17+
) -> list[tuple[str, str]]: ...
18+
def normalize_parameters(params: dict[str, str]) -> str: ...
19+
def sign_hmac_sha1_with_client(sig_base_str: str, client): ...
20+
def verify_hmac_sha1(
21+
request: Request, client_secret: Incomplete | None = None, resource_owner_secret: Incomplete | None = None
22+
) -> bool: ...
23+
def sign_hmac_sha1(base_string: str | bytes, client_secret, resource_owner_secret): ...
1924
def sign_hmac_sha256_with_client(sig_base_str, client): ...
20-
def verify_hmac_sha256(request, client_secret: Incomplete | None = None, resource_owner_secret: Incomplete | None = None): ...
21-
def sign_hmac_sha256(base_string, client_secret, resource_owner_secret): ...
25+
def verify_hmac_sha256(
26+
request, client_secret: Incomplete | None = None, resource_owner_secret: Incomplete | None = None
27+
) -> bool: ...
28+
def sign_hmac_sha256(base_string: str | bytes, client_secret, resource_owner_secret): ...
2229
def sign_hmac_sha512_with_client(sig_base_str: str, client): ...
23-
def verify_hmac_sha512(request, client_secret: str | None = None, resource_owner_secret: str | None = None): ...
24-
def sign_rsa_sha1_with_client(sig_base_str, client): ...
25-
def verify_rsa_sha1(request, rsa_public_key: str): ...
30+
def verify_hmac_sha512(request, client_secret: str | None = None, resource_owner_secret: str | None = None) -> bool: ...
31+
def sign_rsa_sha1_with_client(sig_base_str: str | bytes, client): ...
32+
def verify_rsa_sha1(request, rsa_public_key: str) -> bool: ...
2633
def sign_rsa_sha1(base_string, rsa_private_key): ...
2734
def sign_rsa_sha256_with_client(sig_base_str: str, client): ...
28-
def verify_rsa_sha256(request, rsa_public_key: str): ...
35+
def verify_rsa_sha256(request, rsa_public_key: str) -> bool: ...
2936
def sign_rsa_sha512_with_client(sig_base_str: str, client): ...
30-
def verify_rsa_sha512(request, rsa_public_key: str): ...
31-
def sign_plaintext_with_client(_signature_base_string, client): ...
32-
def sign_plaintext(client_secret, resource_owner_secret): ...
33-
def verify_plaintext(request, client_secret: Incomplete | None = None, resource_owner_secret: Incomplete | None = None): ...
37+
def verify_rsa_sha512(request, rsa_public_key: str) -> bool: ...
38+
def sign_plaintext_with_client(_signature_base_string: Unused, client) -> str: ...
39+
def sign_plaintext(client_secret: str | None, resource_owner_secret: str | None) -> str: ...
40+
def verify_plaintext(request, client_secret: str | None = None, resource_owner_secret: str | None = None) -> bool: ...
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
UNICODE_ASCII_CHARACTER_SET: str
1+
from collections.abc import Callable, Iterable
2+
from typing import Any, Final, TypeVar
23

3-
def filter_params(target): ...
4-
def filter_oauth_params(params): ...
5-
def escape(u): ...
6-
def unescape(u): ...
7-
def parse_keqv_list(l): ...
8-
def parse_http_list(u): ...
9-
def parse_authorization_header(authorization_header): ...
4+
_T = TypeVar("_T")
5+
6+
UNICODE_ASCII_CHARACTER_SET: Final[str]
7+
8+
def filter_params(
9+
target: Callable[[dict[str, Any] | Iterable[tuple[str, Any]], _T], object],
10+
) -> Callable[[list[str], _T], object]: ...
11+
def filter_oauth_params(
12+
params: dict[str, Any] | Iterable[tuple[str, Any]],
13+
) -> list[str]: ... # we don't care about second (Any) part
14+
def escape(u: str) -> str: ...
15+
def unescape(u: str) -> str: ...
16+
def parse_keqv_list(l: list[str]) -> dict[str, str]: ...
17+
def parse_http_list(u: str) -> list[str]: ...
18+
def parse_authorization_header(authorization_header: str) -> list[tuple[str, str]]: ...

stubs/oauthlib/oauthlib/openid/connect/core/endpoints/userinfo.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from _typeshed import Incomplete
2+
from logging import Logger
23
from typing import Any
34

45
from oauthlib.oauth2.rfc6749.endpoints.base import BaseEndpoint as BaseEndpoint
56

6-
log: Any
7+
log: Logger
78

89
class UserInfoEndpoint(BaseEndpoint):
910
bearer: Any

stubs/oauthlib/oauthlib/openid/connect/core/grant_types/authorization_code.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from _typeshed import Incomplete
2+
from logging import Logger
23
from typing import Any
34

45
from .base import GrantTypeBase as GrantTypeBase
56

6-
log: Any
7+
log: Logger
78

89
class AuthorizationCodeGrant(GrantTypeBase):
910
proxy_target: Any

stubs/oauthlib/oauthlib/openid/connect/core/grant_types/base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from logging import Logger
33

4-
log: Any
4+
log: Logger
55

66
class GrantTypeBase:
77
def __getattr__(self, attr: str): ...

0 commit comments

Comments
 (0)