pypomes-jwt 0.5.9__tar.gz → 0.6.0__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.5.9 → pypomes_jwt-0.6.0}/PKG-INFO +2 -2
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/pyproject.toml +2 -2
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/src/pypomes_jwt/jwt_data.py +3 -1
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/src/pypomes_jwt/jwt_pomes.py +19 -9
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/.gitignore +0 -0
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/LICENSE +0 -0
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/README.md +0 -0
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/src/__init__.py +0 -0
- {pypomes_jwt-0.5.9 → pypomes_jwt-0.6.0}/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.
|
|
3
|
+
Version: 0.6.0
|
|
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
|
|
@@ -10,6 +10,6 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: cryptography>=44.0.0
|
|
13
14
|
Requires-Dist: pyjwt>=2.10.1
|
|
14
|
-
Requires-Dist: pyopenssl>=25.0.0
|
|
15
15
|
Requires-Dist: pypomes-core>=1.7.1
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "pypomes_jwt"
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.6.0"
|
|
10
10
|
authors = [
|
|
11
11
|
{ name="GT Nunes", email="wisecoder01@gmail.com" }
|
|
12
12
|
]
|
|
@@ -20,7 +20,7 @@ classifiers = [
|
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
22
|
"PyJWT>=2.10.1",
|
|
23
|
-
"
|
|
23
|
+
"cryptography>=44.0.0",
|
|
24
24
|
"pypomes_core>=1.7.1"
|
|
25
25
|
]
|
|
26
26
|
|
|
@@ -418,7 +418,9 @@ def jwt_validate_token(token: str,
|
|
|
418
418
|
:raises InvalidSignatureError: signature does not match the one provided as part of the token
|
|
419
419
|
"""
|
|
420
420
|
if logger:
|
|
421
|
-
logger.debug(msg=f"
|
|
421
|
+
logger.debug(msg=f"Validate JWT token '{token}'")
|
|
422
422
|
jwt.decode(jwt=token,
|
|
423
423
|
key=key,
|
|
424
424
|
algorithms=[algorithm])
|
|
425
|
+
if logger:
|
|
426
|
+
logger.debug(msg=f"Token '{token}' is valid")
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import contextlib
|
|
2
|
+
from cryptography.hazmat.backends import default_backend
|
|
3
|
+
from cryptography.hazmat.primitives import serialization
|
|
4
|
+
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
5
|
+
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
|
|
2
6
|
from flask import Request, Response, request, jsonify
|
|
3
7
|
from logging import Logger
|
|
4
|
-
from OpenSSL import crypto
|
|
5
8
|
from pypomes_core import APP_PREFIX, env_get_str, env_get_bytes, env_get_int
|
|
6
9
|
from secrets import token_bytes
|
|
7
10
|
from typing import Any, Final, Literal
|
|
@@ -19,14 +22,21 @@ JWT_HS_SECRET_KEY: Final[bytes] = env_get_bytes(key=f"{APP_PREFIX}_JWT_HS_SECRET
|
|
|
19
22
|
# must invoke 'jwt_service()' below
|
|
20
23
|
JWT_ENDPOINT_URL: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_ENDPOINT_URL")
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__priv_key =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
# obtain a RSA private/public key pair
|
|
26
|
+
__priv_bytes: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_RSA_PRIVATE_KEY")
|
|
27
|
+
__pub_bytes: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_RSA_PUBLIC_KEY")
|
|
28
|
+
if not __priv_bytes or not __pub_bytes:
|
|
29
|
+
__priv_key: RSAPrivateKey = rsa.generate_private_key(public_exponent=65537,
|
|
30
|
+
key_size=2058,
|
|
31
|
+
backend=default_backend())
|
|
32
|
+
__priv_bytes = __priv_key.private_bytes(encoding=serialization.Encoding.PEM,
|
|
33
|
+
format=serialization.PrivateFormat.TraditionalOpenSSL,
|
|
34
|
+
encryption_algorithm=serialization.NoEncryption())
|
|
35
|
+
__pub_key: RSAPublicKey = __priv_key.public_key()
|
|
36
|
+
__pub_bytes = __pub_key.public_bytes(encoding=serialization.Encoding.PEM,
|
|
37
|
+
format=serialization.PublicFormat.SubjectPublicKeyInfo)
|
|
38
|
+
JWT_RSA_PRIVATE_KEY: Final[bytes] = __priv_bytes
|
|
39
|
+
JWT_RSA_PUBLIC_KEY: Final[bytes] = __pub_bytes
|
|
30
40
|
|
|
31
41
|
# the JWT data object
|
|
32
42
|
__jwt_data: JwtData = JwtData()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|