pypomes-jwt 1.1.6__py3-none-any.whl → 1.1.8__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_pomes.py +18 -16
- pypomes_jwt/jwt_registry.py +8 -6
- {pypomes_jwt-1.1.6.dist-info → pypomes_jwt-1.1.8.dist-info}/METADATA +4 -3
- pypomes_jwt-1.1.8.dist-info/RECORD +8 -0
- pypomes_jwt-1.1.6.dist-info/RECORD +0 -8
- {pypomes_jwt-1.1.6.dist-info → pypomes_jwt-1.1.8.dist-info}/WHEEL +0 -0
- {pypomes_jwt-1.1.6.dist-info → pypomes_jwt-1.1.8.dist-info}/licenses/LICENSE +0 -0
pypomes_jwt/jwt_pomes.py
CHANGED
|
@@ -8,6 +8,7 @@ from pypomes_db import (
|
|
|
8
8
|
DbEngine, db_connect, db_commit,
|
|
9
9
|
db_rollback, db_select, db_delete
|
|
10
10
|
)
|
|
11
|
+
from pypomes_logging import PYPOMES_LOGGER
|
|
11
12
|
from typing import Any
|
|
12
13
|
|
|
13
14
|
from .jwt_config import JwtConfig, JwtDbConfig
|
|
@@ -79,7 +80,7 @@ def jwt_set_account(account_id: str,
|
|
|
79
80
|
access_max_age: int = JwtConfig.ACCESS_MAX_AGE.value,
|
|
80
81
|
refresh_max_age: int = JwtConfig.REFRESH_MAX_AGE.value,
|
|
81
82
|
lead_interval: int = None,
|
|
82
|
-
logger: Logger =
|
|
83
|
+
logger: Logger = PYPOMES_LOGGER) -> None:
|
|
83
84
|
"""
|
|
84
85
|
Establish the data needed to obtain JWT tokens for *account_id*.
|
|
85
86
|
|
|
@@ -108,7 +109,7 @@ def jwt_set_account(account_id: str,
|
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
def jwt_remove_account(account_id: str,
|
|
111
|
-
logger: Logger =
|
|
112
|
+
logger: Logger = PYPOMES_LOGGER) -> bool:
|
|
112
113
|
"""
|
|
113
114
|
Remove from storage the JWT access data for *account_id*.
|
|
114
115
|
|
|
@@ -127,25 +128,26 @@ def jwt_validate_token(errors: list[str] | None,
|
|
|
127
128
|
token: str,
|
|
128
129
|
nature: str = None,
|
|
129
130
|
account_id: str = None,
|
|
130
|
-
logger: Logger =
|
|
131
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any] | None:
|
|
131
132
|
"""
|
|
132
133
|
Verify if *token* ia a valid JWT token.
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
Attempt to validate non locally issued tokens will not succeed. if *nature* is provided,
|
|
136
|
+
validate whether *token* is of that nature. A token issued locally has the header claim *kid*
|
|
137
|
+
starting with *A* (for *Access*) or *R* (for *Refresh*), followed by its id in the token database,
|
|
138
|
+
or as a single letter in the range *[B-Z]*, less *R*. If the *kid* claim contains such an id,
|
|
139
|
+
then the cryptographic key needed for validation will be obtained from the token database.
|
|
140
|
+
Otherwise, the current decoding key is used.
|
|
140
141
|
|
|
141
|
-
On success, return the token's claims (header and payload), as documented in *jwt_get_claims()*
|
|
142
|
+
On success, return the token's claims (*header* and *payload*), as documented in *jwt_get_claims()*
|
|
143
|
+
On failure, *errors* will contain the reason(s) for rejecting *token*.
|
|
142
144
|
|
|
143
145
|
:param errors: incidental error messages
|
|
144
146
|
:param token: the token to be validated
|
|
145
147
|
:param nature: prefix identifying the nature of locally issued tokens
|
|
146
148
|
:param account_id: optionally, validate the token's account owner
|
|
147
149
|
:param logger: optional logger
|
|
148
|
-
:return: The token's claims (header and payload) if
|
|
150
|
+
:return: The token's claims (*header* and *payload*) if is valid, *None* otherwise
|
|
149
151
|
"""
|
|
150
152
|
# initialize the return variable
|
|
151
153
|
result: dict[str, Any] | None = None
|
|
@@ -251,7 +253,7 @@ def jwt_validate_token(errors: list[str] | None,
|
|
|
251
253
|
def jwt_revoke_token(errors: list[str] | None,
|
|
252
254
|
account_id: str,
|
|
253
255
|
token: str,
|
|
254
|
-
logger: Logger =
|
|
256
|
+
logger: Logger = PYPOMES_LOGGER) -> bool:
|
|
255
257
|
"""
|
|
256
258
|
Revoke the *refresh_token* associated with *account_id*.
|
|
257
259
|
|
|
@@ -304,7 +306,7 @@ def jwt_issue_token(errors: list[str] | None,
|
|
|
304
306
|
duration: int,
|
|
305
307
|
lead_interval: int = None,
|
|
306
308
|
claims: dict[str, Any] = None,
|
|
307
|
-
logger: Logger =
|
|
309
|
+
logger: Logger = PYPOMES_LOGGER) -> str:
|
|
308
310
|
"""
|
|
309
311
|
Issue or refresh, and return, a JWT token associated with *account_id*, of the specified *nature*.
|
|
310
312
|
|
|
@@ -355,7 +357,7 @@ def jwt_issue_token(errors: list[str] | None,
|
|
|
355
357
|
def jwt_issue_tokens(errors: list[str] | None,
|
|
356
358
|
account_id: str,
|
|
357
359
|
account_claims: dict[str, Any] = None,
|
|
358
|
-
logger: Logger =
|
|
360
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any]:
|
|
359
361
|
"""
|
|
360
362
|
Issue the JWT token pair associated with *account_id*, for access and refresh operations.
|
|
361
363
|
|
|
@@ -409,7 +411,7 @@ def jwt_issue_tokens(errors: list[str] | None,
|
|
|
409
411
|
def jwt_refresh_tokens(errors: list[str] | None,
|
|
410
412
|
account_id: str,
|
|
411
413
|
refresh_token: str,
|
|
412
|
-
logger: Logger =
|
|
414
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any]:
|
|
413
415
|
"""
|
|
414
416
|
Refresh the JWT token pair associated with *account_id*, for access and refresh operations.
|
|
415
417
|
|
|
@@ -507,7 +509,7 @@ def jwt_refresh_tokens(errors: list[str] | None,
|
|
|
507
509
|
|
|
508
510
|
def jwt_get_claims(errors: list[str] | None,
|
|
509
511
|
token: str,
|
|
510
|
-
logger: Logger =
|
|
512
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any] | None:
|
|
511
513
|
"""
|
|
512
514
|
Retrieve and return the claims set of a JWT *token*.
|
|
513
515
|
|
pypomes_jwt/jwt_registry.py
CHANGED
|
@@ -9,6 +9,7 @@ from pypomes_db import (
|
|
|
9
9
|
DbEngine, db_connect, db_commit, db_rollback,
|
|
10
10
|
db_select, db_insert, db_update, db_delete
|
|
11
11
|
)
|
|
12
|
+
from pypomes_logging import PYPOMES_LOGGER
|
|
12
13
|
from threading import Lock
|
|
13
14
|
from typing import Any
|
|
14
15
|
|
|
@@ -88,7 +89,7 @@ class JwtRegistry:
|
|
|
88
89
|
access_max_age: int,
|
|
89
90
|
refresh_max_age: int,
|
|
90
91
|
lead_interval: int | None,
|
|
91
|
-
logger: Logger =
|
|
92
|
+
logger: Logger = PYPOMES_LOGGER) -> None:
|
|
92
93
|
"""
|
|
93
94
|
Add to storage the parameters needed to produce and validate JWT tokens for *account_id*.
|
|
94
95
|
|
|
@@ -152,7 +153,7 @@ class JwtRegistry:
|
|
|
152
153
|
duration: int,
|
|
153
154
|
lead_interval: int = None,
|
|
154
155
|
claims: dict[str, Any] = None,
|
|
155
|
-
logger: Logger =
|
|
156
|
+
logger: Logger = PYPOMES_LOGGER) -> str:
|
|
156
157
|
"""
|
|
157
158
|
Issue an return a JWT token associated with *account_id*.
|
|
158
159
|
|
|
@@ -212,7 +213,7 @@ class JwtRegistry:
|
|
|
212
213
|
account_id: str,
|
|
213
214
|
account_claims: dict[str, Any] = None,
|
|
214
215
|
db_conn: Any = None,
|
|
215
|
-
logger: Logger =
|
|
216
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any]:
|
|
216
217
|
"""
|
|
217
218
|
Issue and return a JWT token pair associated with *account_id*.
|
|
218
219
|
|
|
@@ -319,7 +320,7 @@ class JwtRegistry:
|
|
|
319
320
|
|
|
320
321
|
def __get_account_data(self,
|
|
321
322
|
account_id: str,
|
|
322
|
-
logger: Logger =
|
|
323
|
+
logger: Logger = PYPOMES_LOGGER) -> dict[str, Any]:
|
|
323
324
|
"""
|
|
324
325
|
Retrieve the JWT access data associated with *account_id*.
|
|
325
326
|
|
|
@@ -341,7 +342,7 @@ class JwtRegistry:
|
|
|
341
342
|
def _jwt_persist_token(account_id: str,
|
|
342
343
|
jwt_token: str,
|
|
343
344
|
db_conn: Any,
|
|
344
|
-
logger: Logger =
|
|
345
|
+
logger: Logger = PYPOMES_LOGGER) -> int:
|
|
345
346
|
"""
|
|
346
347
|
Persist the given token, making sure that the account limit is complied with.
|
|
347
348
|
|
|
@@ -462,7 +463,8 @@ def _jwt_persist_token(account_id: str,
|
|
|
462
463
|
f"FROM {JwtDbConfig.TABLE}",
|
|
463
464
|
where_clause=where_clause,
|
|
464
465
|
where_data={JwtDbConfig.COL_ACCOUNT: account_id},
|
|
465
|
-
|
|
466
|
+
min_count=1,
|
|
467
|
+
max_count=1,
|
|
466
468
|
engine=DbEngine(JwtDbConfig.ENGINE),
|
|
467
469
|
connection=db_conn,
|
|
468
470
|
committable=False,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.8
|
|
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
|
|
@@ -12,5 +12,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Requires-Python: >=3.12
|
|
13
13
|
Requires-Dist: cryptography>=44.0.2
|
|
14
14
|
Requires-Dist: pyjwt>=2.10.1
|
|
15
|
-
Requires-Dist: pypomes-core>=2.0.
|
|
16
|
-
Requires-Dist: pypomes-db>=2.1.
|
|
15
|
+
Requires-Dist: pypomes-core>=2.0.5
|
|
16
|
+
Requires-Dist: pypomes-db>=2.1.3
|
|
17
|
+
Requires-Dist: pypomes-logging>=0.6.1
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pypomes_jwt/__init__.py,sha256=NZzjWKnhjxNuoE32V6soKo9sG5ypmt25V0mBAh3rAIs,793
|
|
2
|
+
pypomes_jwt/jwt_config.py,sha256=mtihd58_O00FuFXcNBKsabftG6UHu3Cj24i6cZXoskc,3096
|
|
3
|
+
pypomes_jwt/jwt_pomes.py,sha256=IN686t2dFA5iJ4DsGXFMA5rKg48sRmt8f_nIA6kuxHY,23661
|
|
4
|
+
pypomes_jwt/jwt_registry.py,sha256=LZMjAquURa-oEMAyn8RbRBlOQlwg_lmcoB9NASkv39E,22137
|
|
5
|
+
pypomes_jwt-1.1.8.dist-info/METADATA,sha256=gXrJsW1AAzGuPONUdyQQG0_qmH6D-YGUBSnlL49xBaM,670
|
|
6
|
+
pypomes_jwt-1.1.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
pypomes_jwt-1.1.8.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
+
pypomes_jwt-1.1.8.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pypomes_jwt/__init__.py,sha256=NZzjWKnhjxNuoE32V6soKo9sG5ypmt25V0mBAh3rAIs,793
|
|
2
|
-
pypomes_jwt/jwt_config.py,sha256=mtihd58_O00FuFXcNBKsabftG6UHu3Cj24i6cZXoskc,3096
|
|
3
|
-
pypomes_jwt/jwt_pomes.py,sha256=5d7xd0mCRbBZ65k0pMNeiF_UaZu5sfAojZDEs_wOT8Y,23509
|
|
4
|
-
pypomes_jwt/jwt_registry.py,sha256=Zfhv5bn53UcSPuPSHns4AVMv7izrzd75HPp5eId2dck,21993
|
|
5
|
-
pypomes_jwt-1.1.6.dist-info/METADATA,sha256=eTbk1Zi0snGQA9NAmmOW_pS0LwTWC5QFPNAYbu2LGNg,632
|
|
6
|
-
pypomes_jwt-1.1.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
pypomes_jwt-1.1.6.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
-
pypomes_jwt-1.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|