pypomes-jwt 0.8.1__py3-none-any.whl → 0.8.2__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_data.py +2 -2
- pypomes_jwt/jwt_pomes.py +23 -11
- {pypomes_jwt-0.8.1.dist-info → pypomes_jwt-0.8.2.dist-info}/METADATA +1 -1
- pypomes_jwt-0.8.2.dist-info/RECORD +8 -0
- pypomes_jwt-0.8.1.dist-info/RECORD +0 -8
- {pypomes_jwt-0.8.1.dist-info → pypomes_jwt-0.8.2.dist-info}/WHEEL +0 -0
- {pypomes_jwt-0.8.1.dist-info → pypomes_jwt-0.8.2.dist-info}/licenses/LICENSE +0 -0
pypomes_jwt/jwt_data.py
CHANGED
|
@@ -239,8 +239,8 @@ class JwtData:
|
|
|
239
239
|
just_now: int = int(datetime.now(tz=timezone.utc).timestamp())
|
|
240
240
|
current_claims["iat"] = just_now
|
|
241
241
|
token_header: dict[str, Any] = None \
|
|
242
|
-
if JWT_DEFAULT_ALGORITHM not in ["
|
|
243
|
-
else {"kid": JWT_DECODING_KEY}
|
|
242
|
+
if JWT_DEFAULT_ALGORITHM not in ["RS256", "RS512"] \
|
|
243
|
+
else {"kid": JWT_DECODING_KEY.hex()}
|
|
244
244
|
|
|
245
245
|
# issue the access token first
|
|
246
246
|
current_claims["nat"] = "A"
|
pypomes_jwt/jwt_pomes.py
CHANGED
|
@@ -7,8 +7,7 @@ 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,
|
|
11
|
-
JWT_DB_COL_ACCOUNT, JWT_DB_COL_HASH, JWT_DB_COL_TOKEN
|
|
10
|
+
JWT_DB_ENGINE, JWT_DB_TABLE, JWT_DB_COL_HASH
|
|
12
11
|
)
|
|
13
12
|
from .jwt_data import JwtData
|
|
14
13
|
|
|
@@ -186,6 +185,17 @@ def jwt_validate_token(errors: list[str] | None,
|
|
|
186
185
|
if nature and nature != claims.get("nat"):
|
|
187
186
|
nat: str = "an access" if nature == "A" else "a refresh"
|
|
188
187
|
err_msg = f"Token is not {nat} token"
|
|
188
|
+
elif JWT_DB_ENGINE and claims.get("nat") == "R":
|
|
189
|
+
from pypomes_db import db_exists
|
|
190
|
+
# ruff: noqa: S324
|
|
191
|
+
hasher = hashlib.new(name="md5",
|
|
192
|
+
data=token.encode())
|
|
193
|
+
token_hash: str = hasher.digest().hex()
|
|
194
|
+
if not db_exists(errors=errors,
|
|
195
|
+
table=JWT_DB_TABLE,
|
|
196
|
+
where_data={JWT_DB_COL_HASH: token_hash},
|
|
197
|
+
logger=logger):
|
|
198
|
+
err_msg = "Token is not valid"
|
|
189
199
|
except Exception as e:
|
|
190
200
|
err_msg = str(e)
|
|
191
201
|
|
|
@@ -287,19 +297,21 @@ def jwt_get_tokens(errors: list[str] | None,
|
|
|
287
297
|
if refresh_token:
|
|
288
298
|
# verify whether this refresh token is legitimate
|
|
289
299
|
if JWT_DB_ENGINE:
|
|
290
|
-
from pypomes_db import
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
from pypomes_db import db_exists
|
|
301
|
+
# ruff: noqa: S324
|
|
302
|
+
hasher = hashlib.new(name="md5",
|
|
303
|
+
data=refresh_token.encode())
|
|
304
|
+
token_hash: str = hasher.digest().hex()
|
|
305
|
+
if db_exists(errors=op_errors,
|
|
306
|
+
table=JWT_DB_TABLE,
|
|
307
|
+
where_data={JWT_DB_COL_HASH: token_hash},
|
|
308
|
+
logger=logger) is False:
|
|
298
309
|
op_errors.append("Invalid refresh token")
|
|
310
|
+
|
|
299
311
|
if not op_errors:
|
|
300
312
|
account_claims = jwt_get_claims(errors=op_errors,
|
|
301
313
|
token=refresh_token)
|
|
302
|
-
if not op_errors and account_claims.get("nat") != "R":
|
|
314
|
+
if not op_errors and (account_claims.get("payload") or {}).get("nat") != "R":
|
|
303
315
|
op_errors.append("Invalid parameters")
|
|
304
316
|
|
|
305
317
|
if not op_errors:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
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=d11IsRLKF7_3RTfm5ju-U--eCHJemD50OzQBOzFNtYQ,19243
|
|
4
|
+
pypomes_jwt/jwt_pomes.py,sha256=hsWrlq_9OqcScS1fPKFl5yxxjicj_AAE2Z5NfKicDkw,15686
|
|
5
|
+
pypomes_jwt-0.8.2.dist-info/METADATA,sha256=gHPs2FSSALkn4gsXnCXnbNBIjDYt7a4QxMY11NYBvb8,599
|
|
6
|
+
pypomes_jwt-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
pypomes_jwt-0.8.2.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
+
pypomes_jwt-0.8.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
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,,
|
|
File without changes
|
|
File without changes
|