pypomes-jwt 0.8.5__tar.gz → 0.8.7__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.
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/PKG-INFO +2 -2
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/pyproject.toml +2 -2
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/src/pypomes_jwt/jwt_constants.py +2 -1
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/src/pypomes_jwt/jwt_data.py +10 -6
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/src/pypomes_jwt/jwt_pomes.py +2 -2
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/.gitignore +0 -0
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/LICENSE +0 -0
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/README.md +0 -0
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/src/__init__.py +0 -0
- {pypomes_jwt-0.8.5 → pypomes_jwt-0.8.7}/src/pypomes_jwt/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.7
|
|
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,5 @@ 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>=1.8.
|
|
15
|
+
Requires-Dist: pypomes-core>=1.8.4
|
|
16
16
|
Requires-Dist: pypomes-db>=1.9.6
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "pypomes_jwt"
|
|
9
|
-
version = "0.8.
|
|
9
|
+
version = "0.8.7"
|
|
10
10
|
authors = [
|
|
11
11
|
{ name="GT Nunes", email="wisecoder01@gmail.com" }
|
|
12
12
|
]
|
|
@@ -21,7 +21,7 @@ classifiers = [
|
|
|
21
21
|
dependencies = [
|
|
22
22
|
"PyJWT>=2.10.1",
|
|
23
23
|
"cryptography>=44.0.2",
|
|
24
|
-
"pypomes_core>=1.8.
|
|
24
|
+
"pypomes_core>=1.8.4",
|
|
25
25
|
"pypomes_db>=1.9.6"
|
|
26
26
|
]
|
|
27
27
|
|
|
@@ -49,7 +49,8 @@ JWT_REFRESH_MAX_AGE: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_REFRESH_MAX
|
|
|
49
49
|
JWT_ACCOUNT_LIMIT: Final[int] = env_get_int(key=f"{APP_PREFIX}_JWT_ACCOUNT_LIMIT")
|
|
50
50
|
|
|
51
51
|
# recommended: allow the encode and decode keys to be generated anew when app starts
|
|
52
|
-
__encoding_key: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_ENCODE_KEY"
|
|
52
|
+
__encoding_key: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_ENCODE_KEY",
|
|
53
|
+
style="base64")
|
|
53
54
|
__decoding_key: bytes
|
|
54
55
|
if JWT_DEFAULT_ALGORITHM in ["HS256", "HS512"]:
|
|
55
56
|
if not __encoding_key:
|
|
@@ -35,8 +35,8 @@ class JwtData:
|
|
|
35
35
|
"token-audience": <string> # the audience the token is intended for
|
|
36
36
|
"token_nonce": <string> # value used to associate a client session with a token
|
|
37
37
|
"claims": {
|
|
38
|
-
"valid-from": <string> # token's start (<YYYY-MM-
|
|
39
|
-
"valid-until": <string> # token's finish (<YYYY-MM-
|
|
38
|
+
"valid-from": <string> # token's start (<YYYY-MM-DDThh:mm:ss+00:00>)
|
|
39
|
+
"valid-until": <string> # token's finish (<YYYY-MM-DDThh:mm:ss+00:00>)
|
|
40
40
|
"birthdate": <string>, # subject's birth date
|
|
41
41
|
"email": <string>, # subject's email
|
|
42
42
|
"gender": <string>, # subject's gender
|
|
@@ -68,8 +68,8 @@ class JwtData:
|
|
|
68
68
|
|
|
69
69
|
Account-related claims are optional claims, and convey information about the registered account they belong to.
|
|
70
70
|
Alhough they can be freely specified, these are some of the most commonly used claims:
|
|
71
|
-
"valid-from": <string> # token's start (<YYYY-MM-
|
|
72
|
-
"valid-until": <string> # token's finish (<YYYY-MM-
|
|
71
|
+
"valid-from": <string> # token's start (<YYYY-MM-DDThh:mm:ss+00:00>)
|
|
72
|
+
"valid-until": <string> # token's finish (<YYYY-MM-DDThh:mm:ss+00.00>)
|
|
73
73
|
"birthdate": <string> # subject's birth date
|
|
74
74
|
"email": <string> # subject's email
|
|
75
75
|
"gender": <string> # subject's gender
|
|
@@ -151,10 +151,12 @@ class JwtData:
|
|
|
151
151
|
:param logger: optional logger
|
|
152
152
|
return: *True* if the access data was removed, *False* otherwise
|
|
153
153
|
"""
|
|
154
|
+
# remove from internal storage
|
|
154
155
|
account_data: dict[str, Any] | None
|
|
155
156
|
with self.access_lock:
|
|
156
157
|
account_data = self.access_data.pop(account_id, None)
|
|
157
158
|
|
|
159
|
+
# remove from database
|
|
158
160
|
db_delete(errors=None,
|
|
159
161
|
delete_stmt=f"DELETE FROM {JWT_DB_TABLE}",
|
|
160
162
|
where_data={JWT_DB_COL_ACCOUNT: account_id},
|
|
@@ -242,8 +244,10 @@ class JwtData:
|
|
|
242
244
|
|
|
243
245
|
# issue a candidate refresh token first, and persist it
|
|
244
246
|
current_claims["exp"] = just_now + account_data.get("refresh-max-age")
|
|
245
|
-
current_claims["valid-from"] = datetime.fromtimestamp(timestamp=current_claims["iat"]
|
|
246
|
-
|
|
247
|
+
current_claims["valid-from"] = datetime.fromtimestamp(timestamp=current_claims["iat"],
|
|
248
|
+
tz=timezone.utc).isoformat()
|
|
249
|
+
current_claims["valid-until"] = datetime.fromtimestamp(timestamp=current_claims["exp"],
|
|
250
|
+
tz=timezone.utc).isoformat()
|
|
247
251
|
# may raise an exception
|
|
248
252
|
refresh_token: str = jwt.encode(payload=current_claims,
|
|
249
253
|
key=JWT_ENCODING_KEY,
|
|
@@ -382,8 +382,8 @@ def jwt_get_claims(errors: list[str] | None,
|
|
|
382
382
|
"kid": "1234"
|
|
383
383
|
},
|
|
384
384
|
"payload": {
|
|
385
|
-
"valid-from": <YYYY-MM-
|
|
386
|
-
"valid-until": <YYYY-MM-
|
|
385
|
+
"valid-from": <YYYY-MM-DDThh:mm:ss+00:00>
|
|
386
|
+
"valid-until": <YYYY-MM-DDThh:mm:ss+00:00>
|
|
387
387
|
"birthdate": "1980-01-01",
|
|
388
388
|
"email": "jdoe@mail.com",
|
|
389
389
|
"exp": 1516640454,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|