pypomes-jwt 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

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.

@@ -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 id to add to the request body
40
- :param use_header: use HTTP header on the request
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
- "client_id": client_id,
49
- "use_header": use_header,
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
- if provider.get("use_header"):
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
- if provider.get("client_id"):
85
- data["client_id"] = provider.get("client_id")
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_jwt
3
- Version: 1.2.4
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
@@ -1,9 +1,9 @@
1
1
  pypomes_jwt/__init__.py,sha256=XS646zYwxnTHHfqnl5ioRN3YGi5QvIpKfrMZcw-grjM,966
2
2
  pypomes_jwt/jwt_config.py,sha256=3r9XPWXXAG_wKUs_FDZoTj9j6lmTdNymud_q4E4Opk0,3338
3
- pypomes_jwt/jwt_external.py,sha256=KYW7V4lL_bY4nVZjB2JvPsgxZFEEQ4ivYCf1JhKUQdw,4974
3
+ pypomes_jwt/jwt_external.py,sha256=tEMsOO3Q-rbWR-6TR_7yapB7Xe9qDVvrL-h8RbxgB2I,5145
4
4
  pypomes_jwt/jwt_pomes.py,sha256=em_apYg0ptfa5BvobnfXz7BPh_ghPhXGg7zHFK3A8y4,23901
5
5
  pypomes_jwt/jwt_registry.py,sha256=pNBpPiR2xINzNnWu_2dcPtRVfXqqPzMVYCXG1HtatUA,22268
6
- pypomes_jwt-1.2.4.dist-info/METADATA,sha256=QwMXX6r5bS9-2ulkZ-54AIcoGRKVslYWBqx8EWtX_wY,660
7
- pypomes_jwt-1.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pypomes_jwt-1.2.4.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
9
- pypomes_jwt-1.2.4.dist-info/RECORD,,
6
+ pypomes_jwt-1.2.5.dist-info/METADATA,sha256=Ib7ZJwqF9ZzIENLC27xxddSw-_oPIlnDnftKEVxvs6c,660
7
+ pypomes_jwt-1.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ pypomes_jwt-1.2.5.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
9
+ pypomes_jwt-1.2.5.dist-info/RECORD,,