pypomes-jwt 1.1.8__tar.gz → 1.1.9__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypomes_jwt
3
- Version: 1.1.8
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.5
16
- Requires-Dist: pypomes-db>=2.1.3
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
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "pypomes_jwt"
9
- version = "1.1.8"
9
+ version = "1.1.9"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
@@ -21,8 +21,8 @@ classifiers = [
21
21
  dependencies = [
22
22
  "PyJWT>=2.10.1",
23
23
  "cryptography>=44.0.2",
24
- "pypomes_core>=2.0.5",
25
- "pypomes_db>=2.1.3",
24
+ "pypomes_core>=2.0.6",
25
+ "pypomes_db>=2.1.5",
26
26
  "pypomes_logging>=0.6.1"
27
27
  ]
28
28
 
@@ -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
- # was a 'Bearer' authorization obtained ?
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
- if jwt_validate_token(errors=None,
57
- nature="A",
58
- token=token):
59
- bad_token = False
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. if *nature* is provided,
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,
File without changes
File without changes
File without changes