pypomes-jwt 1.1.8__py3-none-any.whl → 1.1.9__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 +13 -7
- {pypomes_jwt-1.1.8.dist-info → pypomes_jwt-1.1.9.dist-info}/METADATA +3 -3
- pypomes_jwt-1.1.9.dist-info/RECORD +8 -0
- pypomes_jwt-1.1.8.dist-info/RECORD +0 -8
- {pypomes_jwt-1.1.8.dist-info → pypomes_jwt-1.1.9.dist-info}/WHEEL +0 -0
- {pypomes_jwt-1.1.8.dist-info → pypomes_jwt-1.1.9.dist-info}/licenses/LICENSE +0 -0
pypomes_jwt/jwt_pomes.py
CHANGED
|
@@ -37,7 +37,9 @@ def jwt_needed(func: callable) -> callable:
|
|
|
37
37
|
|
|
38
38
|
def jwt_verify_request(request: Request) -> Response:
|
|
39
39
|
"""
|
|
40
|
-
Verify whether the HTTP *request* has the proper authorization, as per the JWT standard
|
|
40
|
+
Verify whether the HTTP *request* has the proper authorization, as per the JWT standard..
|
|
41
|
+
|
|
42
|
+
This implementation assumes that HTTP requests are handled with the *Flask* framework.
|
|
41
43
|
|
|
42
44
|
:param request: the *request* to be verified
|
|
43
45
|
:return: *None* if the *request* is valid, otherwise a *Response* reporting the error
|
|
@@ -48,15 +50,19 @@ def jwt_verify_request(request: Request) -> Response:
|
|
|
48
50
|
# retrieve the authorization from the request header
|
|
49
51
|
auth_header: str = request.headers.get("Authorization")
|
|
50
52
|
|
|
51
|
-
#
|
|
53
|
+
# validate the authorization token
|
|
52
54
|
bad_token: bool = True
|
|
53
55
|
if auth_header and auth_header.startswith("Bearer "):
|
|
54
56
|
# yes, extract and validate the JWT access token
|
|
55
57
|
token: str = auth_header.split(" ")[1]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
claims: dict[str, Any] = jwt_validate_token(errors=None,
|
|
59
|
+
token=token,
|
|
60
|
+
nature="A")
|
|
61
|
+
if claims:
|
|
62
|
+
login: str = request.values.get("login")
|
|
63
|
+
subject: str = claims["payload"].get("sub")
|
|
64
|
+
if not login or not subject or login == subject:
|
|
65
|
+
bad_token = False
|
|
60
66
|
|
|
61
67
|
# deny the authorization
|
|
62
68
|
if bad_token:
|
|
@@ -132,7 +138,7 @@ def jwt_validate_token(errors: list[str] | None,
|
|
|
132
138
|
"""
|
|
133
139
|
Verify if *token* ia a valid JWT token.
|
|
134
140
|
|
|
135
|
-
Attempt to validate non locally issued tokens will not succeed.
|
|
141
|
+
Attempt to validate non locally issued tokens will not succeed. If *nature* is provided,
|
|
136
142
|
validate whether *token* is of that nature. A token issued locally has the header claim *kid*
|
|
137
143
|
starting with *A* (for *Access*) or *R* (for *Refresh*), followed by its id in the token database,
|
|
138
144
|
or as a single letter in the range *[B-Z]*, less *R*. If the *kid* claim contains such an id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pypomes_jwt
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.9
|
|
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,6 +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.6
|
|
16
|
+
Requires-Dist: pypomes-db>=2.1.5
|
|
17
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=ptfxnBBtVVan0mBpHtmNto3yBBIDGp29JGeOGN8kD-8,24011
|
|
4
|
+
pypomes_jwt/jwt_registry.py,sha256=LZMjAquURa-oEMAyn8RbRBlOQlwg_lmcoB9NASkv39E,22137
|
|
5
|
+
pypomes_jwt-1.1.9.dist-info/METADATA,sha256=8udfNQmkAQabyf2fivZp_IJYYuJHd6HZt93btgIsmz0,670
|
|
6
|
+
pypomes_jwt-1.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
pypomes_jwt-1.1.9.dist-info/licenses/LICENSE,sha256=NdakochSXm_H_-DSL_x2JlRCkYikj3snYYvTwgR5d_c,1086
|
|
8
|
+
pypomes_jwt-1.1.9.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=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,,
|
|
File without changes
|
|
File without changes
|