pypomes-jwt 0.5.0__tar.gz → 0.5.2__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,18 +1,17 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pypomes_jwt
3
- Version: 0.5.0
3
+ Version: 0.5.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
7
7
  Author-email: GT Nunes <wisecoder01@gmail.com>
8
- License-File: LICENSE
9
8
  Classifier: License :: OSI Approved :: MIT License
10
9
  Classifier: Operating System :: OS Independent
11
10
  Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.10
13
- Requires-Dist: pip>=24.2
14
- Requires-Dist: pyjwt>=2.9.0
15
- Requires-Dist: pypomes-core>=1.5.3
16
- Requires-Dist: pypomes-crypto>=0.3.0
17
- Requires-Dist: setuptools>=75.1.0
18
- Requires-Dist: wheel>=0.44.0
11
+ Requires-Python: >=3.12
12
+ Requires-Dist: pip>=24.3.1
13
+ Requires-Dist: pyjwt>=2.10.0
14
+ Requires-Dist: pyopenssl>=24.2.1
15
+ Requires-Dist: pypomes-core>=1.6.2
16
+ Requires-Dist: setuptools>=75.5.0
17
+ Requires-Dist: wheel>=0.45.0
@@ -6,25 +6,25 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "pypomes_jwt"
9
- version = "0.5.0"
9
+ version = "0.5.2"
10
10
  authors = [
11
11
  { name="GT Nunes", email="wisecoder01@gmail.com" }
12
12
  ]
13
13
  description = "A collection of Python pomes, penyeach (JWT module)"
14
14
  readme = "README.md"
15
- requires-python = ">=3.10"
15
+ requires-python = ">=3.12"
16
16
  classifiers = [
17
17
  "Programming Language :: Python :: 3",
18
18
  "License :: OSI Approved :: MIT License",
19
19
  "Operating System :: OS Independent"
20
20
  ]
21
21
  dependencies = [
22
- "pip>=24.2",
23
- "PyJWT>=2.9.0",
24
- "pypomes_core>=1.5.3",
25
- "pypomes_crypto>=0.3.0",
26
- "setuptools>=75.1.0",
27
- "wheel>=0.44.0"
22
+ "pip>=24.3.1",
23
+ "PyJWT>=2.10.0",
24
+ "PyOpenSSL>=24.2.1",
25
+ "pypomes_core>=1.6.2",
26
+ "setuptools>=75.5.0",
27
+ "wheel>=0.45.0"
28
28
  ]
29
29
 
30
30
  [project.urls]
@@ -1,7 +1,7 @@
1
1
  import jwt
2
2
  import math
3
3
  import requests
4
- from datetime import datetime, timedelta
4
+ from datetime import datetime, timedelta, timezone
5
5
  from jwt.exceptions import InvalidTokenError
6
6
  from logging import Logger
7
7
  from requests import Response
@@ -60,8 +60,8 @@ class JwtData:
60
60
  access_max_age: int,
61
61
  refresh_max_age: int,
62
62
  secret_key: bytes,
63
- private_key: str,
64
- public_key: str,
63
+ private_key: bytes,
64
+ public_key: bytes,
65
65
  request_timeout: float,
66
66
  local_provider: bool,
67
67
  logger: Logger = None) -> None:
@@ -98,7 +98,7 @@ class JwtData:
98
98
  "access-max-age": access_max_age,
99
99
  "request-timeout": request_timeout,
100
100
  "local-provider": local_provider,
101
- "refresh-exp": datetime.utcnow() + timedelta(seconds=refresh_max_age)
101
+ "refresh-exp": datetime.now(timezone.utc) + timedelta(seconds=refresh_max_age)
102
102
  }
103
103
  if algorithm in ["HS256", "HS512"]:
104
104
  control_data["secret-key"] = secret_key
@@ -190,7 +190,7 @@ class JwtData:
190
190
  control_data: dict[str, Any] = item_data.get("control-data")
191
191
  custom_claims: dict[str, Any] = item_data.get("custom-claims")
192
192
  standard_claims: dict[str, Any] = item_data.get("standard-claims")
193
- just_now: datetime = datetime.utcnow()
193
+ just_now: datetime = datetime.now(timezone.utc)
194
194
 
195
195
  # is the current token still valid ?
196
196
  if just_now > standard_claims.get("exp"):
@@ -1,8 +1,8 @@
1
1
  import contextlib
2
2
  from flask import Request, Response, request, jsonify
3
3
  from logging import Logger
4
+ from OpenSSL import crypto
4
5
  from pypomes_core import APP_PREFIX, env_get_str, env_get_bytes, env_get_int
5
- from pypomes_crypto import crypto_generate_rsa_keys
6
6
  from secrets import token_bytes
7
7
  from typing import Any, Final, Literal
8
8
 
@@ -19,12 +19,14 @@ JWT_HS_SECRET_KEY: Final[bytes] = env_get_bytes(key=f"{APP_PREFIX}_JWT_HS_SECRET
19
19
  # must point to 'jwt_service()' below
20
20
  JWT_ENDPOINT_URL: Final[str] = env_get_str(key=f"{APP_PREFIX}_JWT_ENDPOINT_URL")
21
21
 
22
- __priv_key: str = env_get_str(key=f"{APP_PREFIX}_JWT_RSA_PRIVATE_KEY")
23
- __pub_key: str = env_get_str(key=f"{APP_PREFIX}_JWT_RSA_PUBLIC_KEY")
22
+ __priv_key: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_RSA_PRIVATE_KEY")
23
+ __pub_key: bytes = env_get_bytes(key=f"{APP_PREFIX}_JWT_RSA_PUBLIC_KEY")
24
24
  if not __priv_key or not __pub_key:
25
- (__priv_key, __pub_key) = crypto_generate_rsa_keys(key_size=2048)
26
- JWT_RSA_PRIVATE_KEY: Final[str] = __priv_key
27
- JWT_RSA_PUBLIC_KEY: Final[str] = __pub_key
25
+ pk = crypto.PKey()
26
+ __priv_key = crypto.dump_privatekey(crypto.FILETYPE_PEM, pk)
27
+ __pub_key = crypto.dump_publickey(crypto.FILETYPE_PEM, pk)
28
+ JWT_RSA_PRIVATE_KEY: Final[bytes] = __priv_key
29
+ JWT_RSA_PUBLIC_KEY: Final[bytes] = __pub_key
28
30
 
29
31
  # the JWT data object
30
32
  __jwt_data: JwtData = JwtData()
@@ -53,8 +55,8 @@ def jwt_set_service_access(service_url: str,
53
55
  access_max_age: int = JWT_ACCESS_MAX_AGE,
54
56
  refresh_max_age: int = JWT_REFRESH_MAX_AGE,
55
57
  secret_key: bytes = JWT_HS_SECRET_KEY,
56
- private_key: str = JWT_RSA_PRIVATE_KEY,
57
- public_key: str = JWT_RSA_PUBLIC_KEY,
58
+ private_key: bytes = JWT_RSA_PRIVATE_KEY,
59
+ public_key: bytes = JWT_RSA_PUBLIC_KEY,
58
60
  request_timeout: int = None,
59
61
  local_provider: bool = False,
60
62
  logger: Logger = None) -> None:
File without changes
File without changes
File without changes
File without changes