pypomes-jwt 0.6.6__tar.gz → 0.6.8__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-0.6.6 → pypomes_jwt-0.6.8}/PKG-INFO +1 -1
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/pyproject.toml +1 -1
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/src/pypomes_jwt/jwt_data.py +16 -14
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/src/pypomes_jwt/jwt_pomes.py +2 -3
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/.gitignore +0 -0
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/LICENSE +0 -0
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/README.md +0 -0
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/src/__init__.py +0 -0
- {pypomes_jwt-0.6.6 → pypomes_jwt-0.6.8}/src/pypomes_jwt/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.8
|
|
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
|
|
@@ -199,17 +199,17 @@ class JwtData:
|
|
|
199
199
|
result: dict[str, Any]
|
|
200
200
|
|
|
201
201
|
# obtain the item in storage
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
access_data: dict[str, Any] = self.get_access_data(account_id=account_id,
|
|
203
|
+
logger=logger)
|
|
204
204
|
# was the JWT data obtained ?
|
|
205
|
-
if
|
|
205
|
+
if access_data:
|
|
206
206
|
# yes, proceed
|
|
207
|
-
control_data: dict[str, Any] =
|
|
208
|
-
reserved_claims: dict[str, Any] =
|
|
209
|
-
custom_claims: dict[str, Any] =
|
|
207
|
+
control_data: dict[str, Any] = access_data.get("control-data")
|
|
208
|
+
reserved_claims: dict[str, Any] = access_data.get("reserved-claims")
|
|
209
|
+
custom_claims: dict[str, Any] = access_data.get("custom-claims")
|
|
210
210
|
if superceding_claims:
|
|
211
211
|
custom_claims = custom_claims.copy()
|
|
212
|
-
custom_claims.update(
|
|
212
|
+
custom_claims.update(superceding_claims)
|
|
213
213
|
|
|
214
214
|
# obtain a new token, if the current token has expired
|
|
215
215
|
just_now: int = int(datetime.now(tz=timezone.utc).timestamp())
|
|
@@ -240,9 +240,9 @@ class JwtData:
|
|
|
240
240
|
raise RuntimeError(" - ".join(errors))
|
|
241
241
|
else:
|
|
242
242
|
# JWT service is being provided locally
|
|
243
|
-
claims: dict[str, Any] =
|
|
244
|
-
claims.update(
|
|
245
|
-
claims.update(
|
|
243
|
+
claims: dict[str, Any] = access_data.get("public-claims").copy()
|
|
244
|
+
claims.update(reserved_claims)
|
|
245
|
+
claims.update(custom_claims)
|
|
246
246
|
# may raise an exception
|
|
247
247
|
token: str = jwt.encode(payload=claims,
|
|
248
248
|
key=(control_data.get("hs-secret-key") or
|
|
@@ -280,6 +280,7 @@ class JwtData:
|
|
|
280
280
|
:return: the token's claimset, or *None* if error
|
|
281
281
|
:raises InvalidTokenError: token is not valid
|
|
282
282
|
:raises ExpiredSignatureError: token has expired
|
|
283
|
+
:raises InvalidAlgorithmError: the specified algorithm is not recognized
|
|
283
284
|
"""
|
|
284
285
|
# declare the return variable
|
|
285
286
|
result: dict[str, Any]
|
|
@@ -287,14 +288,15 @@ class JwtData:
|
|
|
287
288
|
if logger:
|
|
288
289
|
logger.debug(msg=f"Retrieve claims for JWT token '{token}'")
|
|
289
290
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if
|
|
291
|
+
access_data: dict[str, Any] = self.get_access_data(access_token=token,
|
|
292
|
+
logger=logger)
|
|
293
|
+
if access_data:
|
|
294
|
+
control_data: dict[str, Any] = access_data.get("control-data")
|
|
293
295
|
if control_data.get("remote-provider"):
|
|
294
296
|
# provider is remote
|
|
295
297
|
result = control_data.get("custom-claims")
|
|
296
298
|
else:
|
|
297
|
-
# may raise
|
|
299
|
+
# may raise an exception
|
|
298
300
|
result = jwt.decode(jwt=token,
|
|
299
301
|
key=(control_data.get("hs-secret-key") or
|
|
300
302
|
control_data.get("rsa-public-key")),
|
|
@@ -19,7 +19,6 @@ JWT_REFRESH_MAX_AGE: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_REFRESH_MAX
|
|
|
19
19
|
def_value=43200)
|
|
20
20
|
JWT_HS_SECRET_KEY: Final[bytes] = env_get_bytes(key=f"{APP_PREFIX}_JWT_HS_SECRET_KEY",
|
|
21
21
|
def_value=token_bytes(nbytes=32))
|
|
22
|
-
# the endpoint must invoke 'jwt_service()' below
|
|
23
22
|
JWT_ENDPOINT_URL: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_ENDPOINT_URL")
|
|
24
23
|
|
|
25
24
|
# obtain a RSA private/public key pair
|
|
@@ -49,7 +48,7 @@ def jwt_needed(func: callable) -> callable:
|
|
|
49
48
|
"""
|
|
50
49
|
# ruff: noqa: ANN003
|
|
51
50
|
def wrapper(*args, **kwargs) -> Response:
|
|
52
|
-
response: Response = jwt_verify_request(request=request)
|
|
51
|
+
response: Response = jwt_verify_request(request=request)
|
|
53
52
|
return response if response else func(*args, **kwargs)
|
|
54
53
|
|
|
55
54
|
# prevent a rogue error ("View function mapping is overwriting an existing endpoint function")
|
|
@@ -185,7 +184,7 @@ def jwt_get_token_claims(errors: list[str],
|
|
|
185
184
|
:param errors: incidental error messages
|
|
186
185
|
:param token: the token to be inspected for claims
|
|
187
186
|
:param logger: optional logger
|
|
188
|
-
:return: the token's claimset, or
|
|
187
|
+
:return: the token's claimset, or *None* if error
|
|
189
188
|
"""
|
|
190
189
|
# initialize the return variable
|
|
191
190
|
result: dict[str, Any] | None = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|