pypomes-jwt 0.6.6__tar.gz → 0.6.7__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: 0.6.6
3
+ Version: 0.6.7
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 = "0.6.6"
9
+ version = "0.6.7"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
@@ -199,14 +199,14 @@ class JwtData:
199
199
  result: dict[str, Any]
200
200
 
201
201
  # obtain the item in storage
202
- item_data: dict[str, Any] = self.get_access_data(account_id=account_id,
203
- logger=logger)
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 item_data:
205
+ if access_data:
206
206
  # yes, proceed
207
- control_data: dict[str, Any] = item_data.get("control-data")
208
- reserved_claims: dict[str, Any] = item_data.get("reserved-claims")
209
- custom_claims: dict[str, Any] = item_data.get("custom-claims")
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
212
  custom_claims.update(m=superceding_claims)
@@ -240,7 +240,7 @@ class JwtData:
240
240
  raise RuntimeError(" - ".join(errors))
241
241
  else:
242
242
  # JWT service is being provided locally
243
- claims: dict[str, Any] = item_data.get("public-claims").copy()
243
+ claims: dict[str, Any] = access_data.get("public-claims").copy()
244
244
  claims.update(m=reserved_claims)
245
245
  claims.update(m=custom_claims)
246
246
  # may raise an exception
@@ -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
- control_data: dict[str, Any] = self.get_access_data(access_token=token,
291
- logger=logger)
292
- if control_data:
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 InvalidTokenError or ExpiredSignatureError
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) if JWT_ENDPOINT_URL else None
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 'None' if error
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