pypomes-jwt 0.8.3__py3-none-any.whl → 0.8.4__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_data.py CHANGED
@@ -400,15 +400,18 @@ def _jwt_persist_token(errors: list[str],
400
400
  if errors:
401
401
  raise RuntimeError("; ".join(errors))
402
402
 
403
- exp: int = token_claims["payload"].get("exp")
403
+ # find expired tokens
404
+ exp: int = token_claims["payload"].get("exp", sys.maxsize)
404
405
  if exp < datetime.now(tz=timezone.utc).timestamp():
405
406
  expired.append(token_kid)
406
- elif exp < oldest:
407
+
408
+ # find oldest token
409
+ iat: int = token_claims["payload"].get("iat", sys.maxsize)
410
+ if iat < oldest:
407
411
  oldest = exp
408
412
  surplus = token_kid
409
413
 
410
414
  # remove expired tokens from persistence
411
- # ruff: noqa: SIM102
412
415
  if expired:
413
416
  db_delete(errors=errors,
414
417
  delete_stmt=f"DELETE FROM {JWT_DB_TABLE}",
@@ -422,7 +425,7 @@ def _jwt_persist_token(errors: list[str],
422
425
  f"'{account_id}' removed from storage")
423
426
 
424
427
  if 0 < JWT_ACCOUNT_LIMIT <= len(recs) - len(expired):
425
- # delete the oldest persisted token to make way for the new one
428
+ # delete the oldest token to make way for the new one
426
429
  db_delete(errors=errors,
427
430
  delete_stmt=f"DELETE FROM {JWT_DB_TABLE}",
428
431
  where_data={JWT_DB_COL_KID: surplus},
pypomes_jwt/jwt_pomes.py CHANGED
@@ -57,7 +57,7 @@ def jwt_verify_request(request: Request,
57
57
  # yes, extract and validate the JWT access token
58
58
  token: str = auth_header.split(" ")[1]
59
59
  if logger:
60
- logger.debug(msg=f"Token is '{token}'")
60
+ logger.debug(msg="Token was found")
61
61
  errors: list[str] = []
62
62
  jwt_validate_token(errors=errors,
63
63
  nature="A",
@@ -174,7 +174,7 @@ def jwt_validate_token(errors: list[str] | None,
174
174
  # initialize the return variable
175
175
  result: dict[str, Any] | None = None
176
176
  if logger:
177
- logger.debug(msg=f"Validate JWT token '{token}'")
177
+ logger.debug(msg="Validate JWT token")
178
178
 
179
179
  # extract needed data from token header
180
180
  token_header: dict[str, Any] = jwt.get_unverified_header(jwt=token)
@@ -245,7 +245,7 @@ def jwt_validate_token(errors: list[str] | None,
245
245
  if isinstance(errors, list):
246
246
  errors.extend(op_errors)
247
247
  elif logger:
248
- logger.debug(msg=f"Token '{token}' is valid")
248
+ logger.debug(msg="Token is valid")
249
249
 
250
250
  return result
251
251
 
@@ -409,7 +409,7 @@ def jwt_get_claims(errors: list[str] | None,
409
409
  result: dict[str, Any] | None = None
410
410
 
411
411
  if logger:
412
- logger.debug(msg=f"Retrieve claims for token '{token}'")
412
+ logger.debug(msg="Retrieve claims for token")
413
413
 
414
414
  try:
415
415
  # retrieve the token's claims
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_jwt
3
- Version: 0.8.3
3
+ Version: 0.8.4
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
@@ -13,4 +13,4 @@ Requires-Python: >=3.12
13
13
  Requires-Dist: cryptography>=44.0.2
14
14
  Requires-Dist: pyjwt>=2.10.1
15
15
  Requires-Dist: pypomes-core>=1.8.3
16
- Requires-Dist: pypomes-db>=1.9.5
16
+ Requires-Dist: pypomes-db>=1.9.6
@@ -0,0 +1,8 @@
1
+ pypomes_jwt/__init__.py,sha256=P7rT6ZVE2BzU3ntYOr83H5iOf5JcCmjDUYakNbrRAP0,1266
2
+ pypomes_jwt/jwt_constants.py,sha256=FA50jKQ3D09MxXkUpVkXW5IQqm_UX6qm3bU5gHvkU-4,3980
3
+ pypomes_jwt/jwt_data.py,sha256=VTMPJz9CqzaxNyKdDa9cRcUbhGf8U9S6ms9XSuO-7Qg,21639
4
+ pypomes_jwt/jwt_pomes.py,sha256=4S-kKc-lLZg_9jMXk6T1IrBJXiUBAuC_nxhKsv6xzVk,17119
5
+ pypomes_jwt-0.8.4.dist-info/METADATA,sha256=ADSxeO2kePBxf5faJtwfl_zgDaDumeYjySyPVHJnM1E,632
6
+ pypomes_jwt-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ pypomes_jwt-0.8.4.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
8
+ pypomes_jwt-0.8.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- pypomes_jwt/__init__.py,sha256=P7rT6ZVE2BzU3ntYOr83H5iOf5JcCmjDUYakNbrRAP0,1266
2
- pypomes_jwt/jwt_constants.py,sha256=FA50jKQ3D09MxXkUpVkXW5IQqm_UX6qm3bU5gHvkU-4,3980
3
- pypomes_jwt/jwt_data.py,sha256=4WT19eHowrMyXJIRt3nLv8FLxEorgP2k-fgKgYY0Vgk,21534
4
- pypomes_jwt/jwt_pomes.py,sha256=m-seMYrQLgTrdxR7bH-RMdlY7Jc9QtmAKmkdyEAhQGY,17156
5
- pypomes_jwt-0.8.3.dist-info/METADATA,sha256=kagRg42MtBTc2zewA2douDPWBYBmeOCsSwSuciJZnNA,632
6
- pypomes_jwt-0.8.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- pypomes_jwt-0.8.3.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
8
- pypomes_jwt-0.8.3.dist-info/RECORD,,