pypomes-jwt 1.3.8__py3-none-any.whl → 1.3.9__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.
- pypomes_jwt/jwt_pomes.py +14 -13
- {pypomes_jwt-1.3.8.dist-info → pypomes_jwt-1.3.9.dist-info}/METADATA +1 -1
- pypomes_jwt-1.3.9.dist-info/RECORD +8 -0
- pypomes_jwt-1.3.8.dist-info/RECORD +0 -8
- {pypomes_jwt-1.3.8.dist-info → pypomes_jwt-1.3.9.dist-info}/WHEEL +0 -0
- {pypomes_jwt-1.3.8.dist-info → pypomes_jwt-1.3.9.dist-info}/licenses/LICENSE +0 -0
pypomes_jwt/jwt_pomes.py
CHANGED
|
@@ -52,7 +52,7 @@ def jwt_verify_request(request: Request) -> Response:
|
|
|
52
52
|
# validate the authorization token
|
|
53
53
|
bad_token: bool = True
|
|
54
54
|
if auth_header and auth_header.startswith("Bearer "):
|
|
55
|
-
#
|
|
55
|
+
# extract and validate the JWT access token
|
|
56
56
|
token: str = auth_header.split(" ")[1]
|
|
57
57
|
claims: dict[str, Any] = jwt_validate_token(token=token,
|
|
58
58
|
nature="A")
|
|
@@ -224,14 +224,17 @@ def jwt_validate_token(token: str,
|
|
|
224
224
|
# InvalidIssuedAtError: 'iat' claim is non-numeric
|
|
225
225
|
# MissingRequiredClaimError: a required claim is not contained in the claimset
|
|
226
226
|
payload: dict[str, Any] = jwt.decode(jwt=token,
|
|
227
|
+
key=token_decoder,
|
|
228
|
+
algorithms=token_alg,
|
|
227
229
|
options={
|
|
228
|
-
"
|
|
230
|
+
"require": ["iat", "iss", "exp", "sub"],
|
|
231
|
+
"verify_aud": False,
|
|
229
232
|
"verify_exp": True,
|
|
230
|
-
"
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
"verify_iat": True,
|
|
234
|
+
"verify_iss": False,
|
|
235
|
+
"verify_nbf": True,
|
|
236
|
+
"verify_signature": True
|
|
237
|
+
})
|
|
235
238
|
if account_id and payload.get("sub") != account_id:
|
|
236
239
|
if logger:
|
|
237
240
|
logger.error(msg=f"Token does not belong to account '{account_id}'")
|
|
@@ -505,7 +508,7 @@ def jwt_refresh_tokens(account_id: str,
|
|
|
505
508
|
|
|
506
509
|
def jwt_get_claims(token: str,
|
|
507
510
|
errors: list[str] = None,
|
|
508
|
-
logger: Logger = None) -> dict[str, Any] | None:
|
|
511
|
+
logger: Logger = None) -> dict[str, dict[str, Any]] | None:
|
|
509
512
|
"""
|
|
510
513
|
Retrieve the claims set of a JWT *token*.
|
|
511
514
|
|
|
@@ -520,8 +523,6 @@ def jwt_get_claims(token: str,
|
|
|
520
523
|
"kid": "A1234"
|
|
521
524
|
},
|
|
522
525
|
"payload": {
|
|
523
|
-
"valid-from": <YYYY-MM-DDThh:mm:ss+00:00>
|
|
524
|
-
"valid-until": <YYYY-MM-DDThh:mm:ss+00:00>
|
|
525
526
|
"birthdate": "1980-01-01",
|
|
526
527
|
"email": "jdoe@mail.com",
|
|
527
528
|
"exp": 1516640454,
|
|
@@ -539,13 +540,13 @@ def jwt_get_claims(token: str,
|
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
542
|
|
|
542
|
-
:param token: the token
|
|
543
|
+
:param token: the reference token
|
|
543
544
|
:param errors: incidental error messages
|
|
544
545
|
:param logger: optional logger
|
|
545
546
|
:return: the token's claimset, or *None* if error
|
|
546
547
|
"""
|
|
547
548
|
# initialize the return variable
|
|
548
|
-
result: dict[str, Any] | None = None
|
|
549
|
+
result: dict[str, dict[str, Any]] | None = None
|
|
549
550
|
|
|
550
551
|
if logger:
|
|
551
552
|
logger.debug(msg="Retrieve claims for token")
|
|
@@ -562,7 +563,7 @@ def jwt_get_claims(token: str,
|
|
|
562
563
|
exc_err: str = exc_format(exc=e,
|
|
563
564
|
exc_info=sys.exc_info())
|
|
564
565
|
if logger:
|
|
565
|
-
logger.error(msg=f"Error retrieving the token's
|
|
566
|
+
logger.error(msg=f"Error retrieving the token's claims: {exc_err}")
|
|
566
567
|
if isinstance(errors, list):
|
|
567
568
|
errors.append(exc_err)
|
|
568
569
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.9
|
|
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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pypomes_jwt/__init__.py,sha256=esLvNt3Vr4WiZlx1lqKbLIXpDhdBFjqhqKUM6laSwg4,820
|
|
2
|
+
pypomes_jwt/jwt_config.py,sha256=ypr7BCRp1slJ503iyVmma-ljbaZAnbk_qpZKNRjD5CI,4026
|
|
3
|
+
pypomes_jwt/jwt_pomes.py,sha256=sje_1kTSp4I8MEw7jlwYHrEX2JB7a8iEqwt4curfvqc,23659
|
|
4
|
+
pypomes_jwt/jwt_registry.py,sha256=ypBEoL0I2F08sR2G2VO9wXxVeE252lNzjIAC3FGORhA,22631
|
|
5
|
+
pypomes_jwt-1.3.9.dist-info/METADATA,sha256=Rf63Qn0O4FSB-IHmnjZDgI39_Mq5_VRreon8QKYhgpA,660
|
|
6
|
+
pypomes_jwt-1.3.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
pypomes_jwt-1.3.9.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
+
pypomes_jwt-1.3.9.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pypomes_jwt/__init__.py,sha256=esLvNt3Vr4WiZlx1lqKbLIXpDhdBFjqhqKUM6laSwg4,820
|
|
2
|
-
pypomes_jwt/jwt_config.py,sha256=ypr7BCRp1slJ503iyVmma-ljbaZAnbk_qpZKNRjD5CI,4026
|
|
3
|
-
pypomes_jwt/jwt_pomes.py,sha256=WWmZYVpG6wqlIjcJU3jNyBquCgfB-OcgCJBmm6imL4Q,23524
|
|
4
|
-
pypomes_jwt/jwt_registry.py,sha256=ypBEoL0I2F08sR2G2VO9wXxVeE252lNzjIAC3FGORhA,22631
|
|
5
|
-
pypomes_jwt-1.3.8.dist-info/METADATA,sha256=8qS7vQRszQmdG5YU2bWTzlFIy_XpoaEcruzNL40TDec,660
|
|
6
|
-
pypomes_jwt-1.3.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
pypomes_jwt-1.3.8.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
-
pypomes_jwt-1.3.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|