pypomes-jwt 1.2.4__tar.gz → 1.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pypomes-jwt might be problematic. Click here for more details.
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/PKG-INFO +1 -1
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/pyproject.toml +1 -1
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/src/pypomes_jwt/jwt_external.py +13 -11
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/.gitignore +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/LICENSE +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/README.md +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/src/pypomes_jwt/__init__.py +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/src/pypomes_jwt/jwt_config.py +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/src/pypomes_jwt/jwt_pomes.py +0 -0
- {pypomes_jwt-1.2.4 → pypomes_jwt-1.2.5}/src/pypomes_jwt/jwt_registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.5
|
|
4
4
|
Summary: A collection of Python pomes, penyeach (JWT module)
|
|
5
5
|
Project-URL: Homepage, https://github.com/TheWiseCoder/PyPomes-JWT
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/TheWiseCoder/PyPomes-JWT/issues
|
|
@@ -14,6 +14,8 @@ from typing import Any
|
|
|
14
14
|
# "grant-type": <type-of-grant-to-request>,
|
|
15
15
|
# "user": <basic-auth-user>,
|
|
16
16
|
# "pwd": <basic-auth-pwd>,
|
|
17
|
+
# "client-id": <client-identification>,
|
|
18
|
+
# "use-header": <bool>,
|
|
17
19
|
# "token": <auth-token>,
|
|
18
20
|
# "expiration": <timestamp>
|
|
19
21
|
# }
|
|
@@ -29,15 +31,15 @@ def provider_register(provider_id: str,
|
|
|
29
31
|
client_id: str = None,
|
|
30
32
|
use_header: bool = None) -> None:
|
|
31
33
|
"""
|
|
32
|
-
Register an external token provider.
|
|
34
|
+
Register an external authentication token provider.
|
|
33
35
|
|
|
34
36
|
:param provider_id: the provider's identification
|
|
35
37
|
:param grant_type: the type of grant to request (typically, 'client_credentials' or 'password')
|
|
36
|
-
:param access_url: the url to request tokens with
|
|
38
|
+
:param access_url: the url to request authentication tokens with
|
|
37
39
|
:param auth_user: the basic authorization user
|
|
38
40
|
:param auth_pwd: the basic authorization password
|
|
39
|
-
:param client_id: optional client
|
|
40
|
-
:param use_header:
|
|
41
|
+
:param client_id: optional client identification to add to the request data
|
|
42
|
+
:param use_header: add authorization data to HTTP header (defaults to sending them in the body of the request)
|
|
41
43
|
"""
|
|
42
44
|
global _provider_registry # noqa: PLW0602
|
|
43
45
|
_provider_registry[provider_id] = {
|
|
@@ -45,8 +47,8 @@ def provider_register(provider_id: str,
|
|
|
45
47
|
"grant_type": grant_type,
|
|
46
48
|
"user": auth_user,
|
|
47
49
|
"pwd": auth_pwd,
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
+
"client-id": client_id,
|
|
51
|
+
"use-header": use_header,
|
|
50
52
|
"token": None,
|
|
51
53
|
"expiration": datetime.now(tz=TZ_LOCAL).timestamp()
|
|
52
54
|
}
|
|
@@ -71,18 +73,18 @@ def provider_get_token(errors: list[str] | None,
|
|
|
71
73
|
if provider:
|
|
72
74
|
now: float = datetime.now(tz=TZ_LOCAL).timestamp()
|
|
73
75
|
if now > provider.get("expiration"):
|
|
74
|
-
data: dict[str, str] = {"grant_type": provider.get("grant-type")}
|
|
75
|
-
headers: dict[str, str] = {"Content-Type": Mimetype.URLENCODED}
|
|
76
76
|
user: str = provider.get("user")
|
|
77
77
|
pwd: str = provider.get("pwd")
|
|
78
|
-
|
|
78
|
+
data: dict[str, str] = {"grant-type": provider.get("grant-type")}
|
|
79
|
+
headers: dict[str, str] = {"Content-Type": Mimetype.URLENCODED}
|
|
80
|
+
if provider.get("use-header"):
|
|
79
81
|
enc_bytes: bytes = b64encode(f"{user}:{pwd}".encode())
|
|
80
82
|
headers["Authorization"] = f"Basic {enc_bytes.decode()}"
|
|
81
83
|
else:
|
|
82
84
|
data["username"] = user
|
|
83
85
|
data["password"] = pwd
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
if provider.get("client-id"):
|
|
87
|
+
data["client-id"] = provider.get("client-id")
|
|
86
88
|
url: str = provider.get("url")
|
|
87
89
|
try:
|
|
88
90
|
# typical return on a token request:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|