pypomes-jwt 0.7.4__tar.gz → 0.7.5__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.7.4
3
+ Version: 0.7.5
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.7.4"
9
+ version = "0.7.5"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
@@ -6,7 +6,7 @@ from typing import Any, Literal
6
6
  from .jwt_constants import (
7
7
  JWT_ACCESS_MAX_AGE, JWT_REFRESH_MAX_AGE,
8
8
  JWT_DEFAULT_ALGORITHM, JWT_DECODING_KEY,
9
- JWT_DB_ENGINE, JWT_DB_TABLE, JWT_DB_COL_ACCOUNT
9
+ JWT_DB_ENGINE, JWT_DB_TABLE, JWT_DB_COL_ACCOUNT, JWT_DB_COL_TOKEN
10
10
  )
11
11
  from .jwt_data import JwtData
12
12
 
@@ -227,10 +227,22 @@ def jwt_get_tokens(errors: list[str] | None,
227
227
  logger.debug(msg=f"Retrieve JWT token data for '{account_id}'")
228
228
  op_errors: list[str] = []
229
229
  if refresh_token:
230
- account_claims = jwt_get_claims(errors=op_errors,
231
- token=refresh_token)
232
- if not op_errors and account_claims.get("nat") != "R":
233
- op_errors.extend("Invalid parameters")
230
+ # verify whether this refresh token is legitimate
231
+ if JWT_DB_ENGINE:
232
+ from pypomes_db import db_select
233
+ recs: list[tuple[str]] = db_select(errors=op_errors,
234
+ sel_stmt=f"SELECT {JWT_DB_COL_TOKEN} "
235
+ f"FROM {JWT_DB_TABLE}",
236
+ where_data={JWT_DB_COL_ACCOUNT: f"'{account_id}'"},
237
+ logger=logger)
238
+ if not op_errors and \
239
+ (len(recs) == 0 or recs[0][0] != refresh_token):
240
+ errors.append("Invalid refresh token")
241
+ if not op_errors:
242
+ account_claims = jwt_get_claims(errors=op_errors,
243
+ token=refresh_token)
244
+ if not op_errors and account_claims.get("nat") != "R":
245
+ op_errors.append("Invalid parameters")
234
246
 
235
247
  if not op_errors:
236
248
  try:
File without changes
File without changes
File without changes
File without changes