pypomes-jwt 0.7.9__py3-none-any.whl → 0.8.1__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 +2 -2
- pypomes_jwt/jwt_constants.py +2 -1
- pypomes_jwt/jwt_data.py +4 -3
- pypomes_jwt/jwt_pomes.py +20 -19
- {pypomes_jwt-0.7.9.dist-info → pypomes_jwt-0.8.1.dist-info}/METADATA +1 -1
- pypomes_jwt-0.8.1.dist-info/RECORD +8 -0
- pypomes_jwt-0.7.9.dist-info/RECORD +0 -8
- {pypomes_jwt-0.7.9.dist-info → pypomes_jwt-0.8.1.dist-info}/WHEEL +0 -0
- {pypomes_jwt-0.7.9.dist-info → pypomes_jwt-0.8.1.dist-info}/licenses/LICENSE +0 -0
pypomes_jwt/__init__.py
CHANGED
|
@@ -8,7 +8,7 @@ from .jwt_constants import (
|
|
|
8
8
|
from .jwt_pomes import (
|
|
9
9
|
jwt_needed, jwt_verify_request,
|
|
10
10
|
jwt_get_tokens, jwt_get_claims, jwt_validate_token,
|
|
11
|
-
|
|
11
|
+
jwt_assert_account, jwt_set_account, jwt_remove_account, jwt_revoke_token
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
__all__ = [
|
|
@@ -21,7 +21,7 @@ __all__ = [
|
|
|
21
21
|
# jwt_pomes
|
|
22
22
|
"jwt_needed", "jwt_verify_request",
|
|
23
23
|
"jwt_get_tokens", "jwt_get_claims", "jwt_validate_token",
|
|
24
|
-
"
|
|
24
|
+
"jwt_assert_account", "jwt_set_account", "jwt_remove_account", "jwt_revoke_token"
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
from importlib.metadata import version
|
pypomes_jwt/jwt_constants.py
CHANGED
|
@@ -47,7 +47,8 @@ JWT_DB_ENGINE: Final[DbEngine] = DbEngine(__db_engine) if __db_engine else None
|
|
|
47
47
|
|
|
48
48
|
# one of HS256, HS512, RSA256, RSA512
|
|
49
49
|
JWT_DEFAULT_ALGORITHM: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_DEFAULT_ALGORITHM",
|
|
50
|
-
def_value="
|
|
50
|
+
def_value="RS256")
|
|
51
|
+
|
|
51
52
|
# recommended: between 5 min and 1 hour (set to 5 min)
|
|
52
53
|
JWT_ACCESS_MAX_AGE: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_ACCESS_MAX_AGE",
|
|
53
54
|
def_value=300)
|
pypomes_jwt/jwt_data.py
CHANGED
|
@@ -397,8 +397,9 @@ def _jwt_persist_token(errors: list[str],
|
|
|
397
397
|
# ruff: noqa: S324
|
|
398
398
|
hasher = hashlib.new(name="md5",
|
|
399
399
|
data=jwt_token.encode())
|
|
400
|
-
token_hash: str = hasher.digest().
|
|
400
|
+
token_hash: str = hasher.digest().hex()
|
|
401
401
|
db_insert(errors=errors,
|
|
402
402
|
insert_stmt=f"INSERT INTO {JWT_DB_TABLE}",
|
|
403
|
-
insert_data={
|
|
404
|
-
|
|
403
|
+
insert_data={JWT_DB_COL_ACCOUNT: account_id,
|
|
404
|
+
JWT_DB_COL_HASH: token_hash,
|
|
405
|
+
JWT_DB_COL_TOKEN: jwt_token})
|
pypomes_jwt/jwt_pomes.py
CHANGED
|
@@ -7,7 +7,8 @@ from typing import Any, Literal
|
|
|
7
7
|
from .jwt_constants import (
|
|
8
8
|
JWT_ACCESS_MAX_AGE, JWT_REFRESH_MAX_AGE,
|
|
9
9
|
JWT_DEFAULT_ALGORITHM, JWT_DECODING_KEY,
|
|
10
|
-
JWT_DB_ENGINE, JWT_DB_TABLE,
|
|
10
|
+
JWT_DB_ENGINE, JWT_DB_TABLE,
|
|
11
|
+
JWT_DB_COL_ACCOUNT, JWT_DB_COL_HASH, JWT_DB_COL_TOKEN
|
|
11
12
|
)
|
|
12
13
|
from .jwt_data import JwtData
|
|
13
14
|
|
|
@@ -77,7 +78,7 @@ def jwt_verify_request(request: Request,
|
|
|
77
78
|
return result
|
|
78
79
|
|
|
79
80
|
|
|
80
|
-
def
|
|
81
|
+
def jwt_assert_account(account_id: str) -> bool:
|
|
81
82
|
"""
|
|
82
83
|
Determine whether access for *account_id* has been established.
|
|
83
84
|
|
|
@@ -87,17 +88,17 @@ def jwt_assert_access(account_id: str) -> bool:
|
|
|
87
88
|
return __jwt_data.access_data.get(account_id) is not None
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
def
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
def jwt_set_account(account_id: str,
|
|
92
|
+
reference_url: str,
|
|
93
|
+
claims: dict[str, Any],
|
|
94
|
+
access_max_age: int = JWT_ACCESS_MAX_AGE,
|
|
95
|
+
refresh_max_age: int = JWT_REFRESH_MAX_AGE,
|
|
96
|
+
grace_interval: int = None,
|
|
97
|
+
token_audience: str = None,
|
|
98
|
+
token_nonce: str = None,
|
|
99
|
+
request_timeout: int = None,
|
|
100
|
+
remote_provider: bool = True,
|
|
101
|
+
logger: Logger = None) -> None:
|
|
101
102
|
"""
|
|
102
103
|
Set the data needed to obtain JWT tokens for *account_id*.
|
|
103
104
|
|
|
@@ -226,14 +227,14 @@ def jwt_revoke_token(errors: list[str] | None,
|
|
|
226
227
|
# ruff: noqa: S324
|
|
227
228
|
hasher = hashlib.new(name="md5",
|
|
228
229
|
data=refresh_token.encode())
|
|
229
|
-
token_hash: str = hasher.digest().
|
|
230
|
+
token_hash: str = hasher.digest().hex()
|
|
230
231
|
if db_exists(errors=op_errors,
|
|
231
232
|
table=JWT_DB_TABLE,
|
|
232
|
-
where_data={
|
|
233
|
+
where_data={JWT_DB_COL_HASH: token_hash},
|
|
233
234
|
logger=logger):
|
|
234
235
|
db_delete(errors=errors,
|
|
235
236
|
delete_stmt=f"DELETE FROM {JWT_DB_TABLE}",
|
|
236
|
-
where_data={
|
|
237
|
+
where_data={JWT_DB_COL_HASH: token_hash},
|
|
237
238
|
logger=logger)
|
|
238
239
|
elif not op_errors:
|
|
239
240
|
op_errors.append("Token was not found")
|
|
@@ -336,7 +337,7 @@ def jwt_get_claims(errors: list[str] | None,
|
|
|
336
337
|
Structure of the returned data:
|
|
337
338
|
{
|
|
338
339
|
"header": {
|
|
339
|
-
"alg": "
|
|
340
|
+
"alg": "RS256",
|
|
340
341
|
"typ": "JWT",
|
|
341
342
|
"kid": "rt466ytRTYH64577uydhDFGHDYJH2341"
|
|
342
343
|
},
|
|
@@ -347,10 +348,10 @@ def jwt_get_claims(errors: list[str] | None,
|
|
|
347
348
|
"iat": 1516239022,
|
|
348
349
|
"iss": "https://my_id_provider/issue",
|
|
349
350
|
"jti": "Uhsdfgr67FGH567qwSDF33er89retert",
|
|
350
|
-
"gender": "M,
|
|
351
|
+
"gender": "M",
|
|
351
352
|
"name": "John Doe",
|
|
352
353
|
"nbt": 1516249022
|
|
353
|
-
"sub": "
|
|
354
|
+
"sub": "11111111111",
|
|
354
355
|
"roles": [
|
|
355
356
|
"administrator",
|
|
356
357
|
"operator"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.1
|
|
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=06WdwiP2m5jtrFjpPSacg4fRd2Dh6gVo93xJhmu73J4,1134
|
|
2
|
+
pypomes_jwt/jwt_constants.py,sha256=EjdrTP5AptGoOdI0gzsxexmM4lrgm2r0KHX-DyyGhFc,4330
|
|
3
|
+
pypomes_jwt/jwt_data.py,sha256=q4KUVOuLXHA9tVIfuVEPo8uZPulElWM04wqtGVxcV-0,19239
|
|
4
|
+
pypomes_jwt/jwt_pomes.py,sha256=lACMvNHRVpGgOGmQJ67zbURnR6p4kcxU4UomoZYahto,15246
|
|
5
|
+
pypomes_jwt-0.8.1.dist-info/METADATA,sha256=g4cWSIxewY90pfkQ2gLJlLdE_LqHeX2E6mU2CfX0eak,599
|
|
6
|
+
pypomes_jwt-0.8.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
pypomes_jwt-0.8.1.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
+
pypomes_jwt-0.8.1.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pypomes_jwt/__init__.py,sha256=xUDd_xphRQFHuTxrvlQxO-mHIXgTqZjHWHMgp5gRrXU,1130
|
|
2
|
-
pypomes_jwt/jwt_constants.py,sha256=6-Jw4ORgf32hRWnaGyVISXMJMtTBk7LdKl3RrDy7Ll0,4328
|
|
3
|
-
pypomes_jwt/jwt_data.py,sha256=gyhGquSQbHevOKIoXmAmjMSwCjXB7pYbI2sY-7sGGO8,19158
|
|
4
|
-
pypomes_jwt/jwt_pomes.py,sha256=xNBlHhvrOH07WP6hKE0PyDl4fKSl0R1Xg7AQO_1b1uo,15201
|
|
5
|
-
pypomes_jwt-0.7.9.dist-info/METADATA,sha256=rXu25F1ufUL_U7frUaV1DMAj27pH8gvPX-TIA0qLlrg,599
|
|
6
|
-
pypomes_jwt-0.7.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
pypomes_jwt-0.7.9.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
-
pypomes_jwt-0.7.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|