cardo-python-utils 0.5.dev28__py3-none-any.whl → 0.5.dev29__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cardo-python-utils
3
- Version: 0.5.dev28
3
+ Version: 0.5.dev29
4
4
  Summary: Python library enhanced with a wide range of functions for different scenarios.
5
5
  Author-email: CardoAI <hello@cardoai.com>
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- cardo_python_utils-0.5.dev28.dist-info/licenses/LICENSE,sha256=N-YtxDy8n5A1Mo7JKKItNIlboiK_pMOZ48ojx76jo3g,1046
1
+ cardo_python_utils-0.5.dev29.dist-info/licenses/LICENSE,sha256=N-YtxDy8n5A1Mo7JKKItNIlboiK_pMOZ48ojx76jo3g,1046
2
2
  python_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  python_utils/choices.py,sha256=_sLNkSnQqhg55gGKNRsOQCJ75W6gnz8J8Q00528MEYk,2548
4
4
  python_utils/data_structures.py,sha256=ZqkZYPy20zyGYOVhwb9qst4vF_P7X2A9z5E36rMUC6I,16820
@@ -18,14 +18,14 @@ python_utils/keycloak/django/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
18
18
  python_utils/keycloak/django/admin/auth.py,sha256=GlYyokX_nbZiVHa_LlCCrdaKHa9oop7pX1IOspS4mPs,1920
19
19
  python_utils/keycloak/django/admin/user_group.py,sha256=SeXXHL3MRsCxWsdrxfEtXUYT6gqsoLgAaW5rKzyBqck,6063
20
20
  python_utils/keycloak/django/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- python_utils/keycloak/django/api/drf.py,sha256=i4vZoZXta8IOsGO5YerAEfVyc9jMyD95lVePuaB4eeg,2919
22
- python_utils/keycloak/django/api/ninja.py,sha256=PO_i-Wr_sK8f45KddKDg5kMAfiEEN1DibYlsMEYYom8,4727
23
- python_utils/keycloak/django/api/utils.py,sha256=yGUrB1LGatGVy0PFuFhz3t5INWr0xcarGnoZg2-q3B8,2974
21
+ python_utils/keycloak/django/api/drf.py,sha256=a61gp-fSHV760FYfRv_IxnykuB14sSSI6tS1dUB1POk,2957
22
+ python_utils/keycloak/django/api/ninja.py,sha256=r0-tlS8TlCp_q1_3wdplyZmYMjeUwv8YuzWjRTtijBw,4765
23
+ python_utils/keycloak/django/api/utils.py,sha256=4owIexunNlSCCezSRZkJe_MtsH8DqGN9Vd94ImCTL-Y,3062
24
24
  python_utils/keycloak/django/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  python_utils/keycloak/django/models/user_group.py,sha256=WU_KClfj-pboDIKUDHZQfQuhAPIPXgP-LrEvg9XJjmA,504
26
26
  python_utils/keycloak/django/tests/__init__.py,sha256=Nkt0a7LEHyjLvuEBZ7113VjjAWJlyZlMy-H-JZ5tNcs,252
27
27
  python_utils/keycloak/django/tests/conftest.py,sha256=PTA2QAqOMtmeVE87C1FOTC2d_4FSRw_i1vMgLoxKkwA,3176
28
- cardo_python_utils-0.5.dev28.dist-info/METADATA,sha256=iMJi6QV8YXYojGJTomYKAz4F5vwUUPcreUMs_dYczsI,2915
29
- cardo_python_utils-0.5.dev28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
- cardo_python_utils-0.5.dev28.dist-info/top_level.txt,sha256=zAx6OfEsjJs8BEW3okSiG_j9gpkI69xWShzum6oBgKI,13
31
- cardo_python_utils-0.5.dev28.dist-info/RECORD,,
28
+ cardo_python_utils-0.5.dev29.dist-info/METADATA,sha256=qq_kmdvIht_r_lGydfSeYRl5xBzl4xCxeZjtgT_HKww,2915
29
+ cardo_python_utils-0.5.dev29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ cardo_python_utils-0.5.dev29.dist-info/top_level.txt,sha256=zAx6OfEsjJs8BEW3okSiG_j9gpkI69xWShzum6oBgKI,13
31
+ cardo_python_utils-0.5.dev29.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  from django.conf import settings
2
- from jwt.exceptions import InvalidTokenError
2
+ from jwt.exceptions import InvalidTokenError, PyJWKClientError
3
3
 
4
4
  from rest_framework import authentication
5
5
  from rest_framework.exceptions import AuthenticationFailed
@@ -14,7 +14,7 @@ class AuthenticationBackend(authentication.TokenAuthentication):
14
14
  def authenticate_credentials(self, token: str):
15
15
  try:
16
16
  payload = decode_jwt(token, audience=self._get_audience())
17
- except InvalidTokenError as e:
17
+ except (InvalidTokenError, PyJWKClientError) as e:
18
18
  raise AuthenticationFailed(f"Invalid token: {str(e)}") from e
19
19
 
20
20
  try:
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  from typing import Literal, Optional, Union
3
3
 
4
- from jwt.exceptions import InvalidTokenError
4
+ from jwt.exceptions import InvalidTokenError, PyJWKClientError
5
5
 
6
6
  from django.conf import settings
7
7
  from django.http import HttpRequest
@@ -61,7 +61,7 @@ class AuthBearer(HttpBearer):
61
61
  def _decode_token(self, token: str) -> TokenPayload:
62
62
  try:
63
63
  return decode_jwt(token)
64
- except InvalidTokenError as e:
64
+ except (InvalidTokenError, PyJWKClientError) as e:
65
65
  raise AuthenticationError(f"Invalid token: {str(e)}") from e
66
66
 
67
67
  def _get_username(self, payload: TokenPayload) -> str:
@@ -32,6 +32,7 @@ def decode_jwt(token: str, audience: Optional[str] = None) -> TokenPayload:
32
32
  Decode a JWT token using the public certificate of the Auth Server.
33
33
 
34
34
  Raises:
35
+ jwt.exceptions.PyJWKClientError: If there is an error fetching the signing key.
35
36
  jwt.exceptions.InvalidTokenError: If the token is invalid or cannot be decoded.
36
37
  """
37
38
  signing_key = jwks_client.get_signing_key_from_jwt(token)