pypomes-jwt 0.7.2__py3-none-any.whl → 0.7.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/__init__.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from .jwt_constants import (
2
2
  JWT_DB_ENGINE, JWT_DB_HOST, JWT_DB_NAME,
3
3
  JWT_DB_PORT, JWT_DB_USER, JWT_DB_PWD,
4
+ JWT_DB_TABLE, JWT_DB_COL_ACCOUNT, JWT_DB_COL_TOKEN,
4
5
  JWT_ACCESS_MAX_AGE, JWT_REFRESH_MAX_AGE,
5
6
  JWT_ENCODING_KEY, JWT_DECODING_KEY
6
7
  )
@@ -14,6 +15,7 @@ __all__ = [
14
15
  # jwt_constants
15
16
  "JWT_DB_ENGINE", "JWT_DB_HOST", "JWT_DB_NAME",
16
17
  "JWT_DB_PORT", "JWT_DB_USER", "JWT_DB_PWD",
18
+ "JWT_DB_TABLE", "JWT_DB_COL_ACCOUNT", "JWT_DB_COL_TOKEN",
17
19
  "JWT_ACCESS_MAX_AGE", "JWT_REFRESH_MAX_AGE",
18
20
  "JWT_ENCODING_KEY", "JWT_DECODING_KEY",
19
21
  # jwt_pomes
@@ -17,11 +17,10 @@ JWT_DB_PWD: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_PWD")
17
17
  JWT_DB_CLIENT: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_CLIENT") # for Oracle, only
18
18
  JWT_DB_DRIVER: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_DRIVER") # for SQLServer, only
19
19
  JWT_DB_TABLE: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_TABLE")
20
- JWT_ROTATE_TOKENS: Final[bool] = env_get_bool(key=f"{APP_PREFIX}_JWT_ROTATE_TOKENS",
21
- def_value=True)
22
-
20
+ JWT_DB_COL_ACCOUNT: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_COL_ACCOUNT")
21
+ JWT_DB_COL_TOKEN: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DB_COL_TOKEN")
22
+ # define the database engine
23
23
  __db_engine: str | None = env_get_str(key=f"{APP_PREFIX}_JWT_DB_ENGINE")
24
- __rotate_tokens: bool = False
25
24
  if __db_engine:
26
25
  from pypomes_db import DbEngine, db_setup, db_assert_access, db_delete
27
26
  from sys import stderr
@@ -42,6 +41,7 @@ if __db_engine:
42
41
  else:
43
42
  stderr.write("Invalid database parameters\n")
44
43
  __db_engine = None
44
+ # if set to 'None', no further attempt will be made to access the database
45
45
  JWT_DB_ENGINE: Final[DbEngine] = DbEngine(__db_engine) if __db_engine else None
46
46
 
47
47
  # one of HS256, HS512, RSA256, RSA512
@@ -53,6 +53,8 @@ JWT_ACCESS_MAX_AGE: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_ACCESS_MAX_A
53
53
  # recommended: at least 2 hours (set to 24 hours)
54
54
  JWT_REFRESH_MAX_AGE: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_REFRESH_MAX_AGE",
55
55
  def_value=86400)
56
+ JWT_ROTATE_TOKENS: Final[bool] = env_get_bool(key=f"{APP_PREFIX}_JWT_ROTATE_TOKENS",
57
+ def_value=True)
56
58
 
57
59
  # recommended: allow the encode and decode keys to be generated anew when app starts
58
60
  __encoding_key: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_ENCODE_KEY")
pypomes_jwt/jwt_data.py CHANGED
@@ -9,8 +9,8 @@ from threading import Lock
9
9
  from typing import Any
10
10
 
11
11
  from .jwt_constants import (
12
- JWT_DEFAULT_ALGORITHM, JWT_ENCODING_KEY,
13
- JWT_ROTATE_TOKENS, JWT_DB_ENGINE, JWT_DB_TABLE
12
+ JWT_DEFAULT_ALGORITHM, JWT_ENCODING_KEY, JWT_ROTATE_TOKENS,
13
+ JWT_DB_ENGINE, JWT_DB_TABLE, JWT_DB_COL_ACCOUNT, JWT_DB_COL_TOKEN
14
14
  )
15
15
 
16
16
 
@@ -113,7 +113,7 @@ class JwtData:
113
113
  with self.access_lock:
114
114
  if account_id not in self.access_data:
115
115
  self.access_data[account_id] = {
116
- "reference_url": reference_url,
116
+ "reference-url": reference_url,
117
117
  "access-max-age": access_max_age,
118
118
  "refresh-max-age": refresh_max_age,
119
119
  "grace-interval": grace_interval,
@@ -232,14 +232,15 @@ class JwtData:
232
232
  if JWT_ROTATE_TOKENS:
233
233
  db_delete(errors=errors,
234
234
  delete_stmt=f"DELETE FROM {JWT_DB_TABLE} "
235
- f"WHERE account_id = '{account_id}'",
235
+ f"WHERE {JWT_DB_COL_ACCOUNT} = '{account_id}'",
236
236
  logger=logger)
237
237
  else:
238
- recs: list[tuple[str]] = db_select(errors=errors,
239
- sel_stmt=f"SELECT jwt_token FROM {JWT_DB_TABLE} "
240
- f"WHERE account_id = '{account_id}'",
241
- max_count=1,
242
- logger=logger)
238
+ recs: list[tuple[str]] = \
239
+ db_select(errors=errors,
240
+ sel_stmt=f"SELECT token FROM {JWT_DB_TABLE} "
241
+ f"WHERE {JWT_DB_COL_ACCOUNT} = '{account_id}'",
242
+ max_count=1,
243
+ logger=logger)
243
244
  if recs:
244
245
  refresh_token = recs[0][0]
245
246
  if errors:
@@ -259,8 +260,8 @@ class JwtData:
259
260
  from pypomes_db import db_insert
260
261
  db_insert(errors=errors,
261
262
  insert_stmt=f"INSERT INTO {JWT_DB_TABLE}",
262
- insert_data={"account_id": account_id,
263
- "jwt_token": refresh_token},
263
+ insert_data={JWT_DB_COL_ACCOUNT: account_id,
264
+ JWT_DB_COL_TOKEN: refresh_token},
264
265
  logger=logger)
265
266
  if errors:
266
267
  raise RuntimeError(" - ".join(errors))
pypomes_jwt/jwt_pomes.py CHANGED
@@ -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
9
+ JWT_DB_ENGINE, JWT_DB_TABLE, JWT_DB_COL_ACCOUNT
10
10
  )
11
11
  from .jwt_data import JwtData
12
12
 
@@ -176,7 +176,7 @@ def jwt_revoke_tokens(errors: list[str] | None,
176
176
  if JWT_DB_ENGINE:
177
177
  from pypomes_db import db_delete
178
178
  delete_stmt: str = (f"DELETE FROM {JWT_DB_TABLE} "
179
- f"WHERE account_id = '{account_id}'")
179
+ f"WHERE {JWT_DB_COL_ACCOUNT} = '{account_id}'")
180
180
  db_delete(errors=op_errors,
181
181
  delete_stmt=delete_stmt,
182
182
  logger=logger)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_jwt
3
- Version: 0.7.2
3
+ Version: 0.7.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
@@ -0,0 +1,8 @@
1
+ pypomes_jwt/__init__.py,sha256=dkWeYPNwypjwFuTjx4YtC8QV9ihykF4xcJJ7x86Wc5g,1130
2
+ pypomes_jwt/jwt_constants.py,sha256=xUX2raEaDUPJsjAm78lQ0APs4KSs5GYBxSPC5QKrrFE,4327
3
+ pypomes_jwt/jwt_data.py,sha256=YH3v8zvOURkB_o0XLMu2y2sFkKCxZBmbyWU5rC2gre4,16419
4
+ pypomes_jwt/jwt_pomes.py,sha256=zFU1TyeR3BhK9ToC1Vs1wh67uE2DGvzH9FltiQxI0EM,12160
5
+ pypomes_jwt-0.7.4.dist-info/METADATA,sha256=DwlCneMVk9Qv4RovwWslSRK_zb2DF5lgnJd4nRVeeWE,599
6
+ pypomes_jwt-0.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ pypomes_jwt-0.7.4.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
8
+ pypomes_jwt-0.7.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- pypomes_jwt/__init__.py,sha256=Op7UEyEDniIkvk65ro8JUPHjGCV_q35k0YL_Ql_DjBc,1010
2
- pypomes_jwt/jwt_constants.py,sha256=MGuIKc9tFsbWjx3wBlNbdibzytbndK9uhL2kVPW7X2A,4086
3
- pypomes_jwt/jwt_data.py,sha256=e5KX0slUtrXbbyCtbdjycuqdQwVrvE8BK-_-XhVvHIs,16403
4
- pypomes_jwt/jwt_pomes.py,sha256=uyhwZzI781yGzWbHKfI-aM9dVXHBB28okQzlvfT4D00,12130
5
- pypomes_jwt-0.7.2.dist-info/METADATA,sha256=WamGD3ya5b3Ut04oVeFX8TzEeTHRZra6cjpmxJVkeBI,599
6
- pypomes_jwt-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- pypomes_jwt-0.7.2.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
8
- pypomes_jwt-0.7.2.dist-info/RECORD,,