pypomes-jwt 1.3.8__tar.gz → 1.3.9__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_jwt
3
- Version: 1.3.8
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
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "pypomes_jwt"
9
- version = "1.3.8"
9
+ version = "1.3.9"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
@@ -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
- # yes, extract and validate the JWT access token
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
- "verify_signature": True,
230
+ "require": ["iat", "iss", "exp", "sub"],
231
+ "verify_aud": False,
229
232
  "verify_exp": True,
230
- "verify_nbf": True
231
- },
232
- key=token_decoder,
233
- require=["iat", "iss", "exp", "sub"],
234
- algorithms=token_alg)
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 to be inspected for claims
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 claimsn: {exc_err}")
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
 
File without changes
File without changes
File without changes