cardo-python-utils 0.5.dev27__tar.gz → 0.5.dev29__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.
- {cardo_python_utils-0.5.dev27/cardo_python_utils.egg-info → cardo_python_utils-0.5.dev29}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29/cardo_python_utils.egg-info}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/pyproject.toml +1 -1
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/api/drf.py +2 -2
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/api/ninja.py +2 -2
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/api/utils.py +1 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/tests/conftest.py +1 -1
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/LICENSE +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/MANIFEST.in +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/README.rst +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/cardo_python_utils.egg-info/SOURCES.txt +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/cardo_python_utils.egg-info/dependency_links.txt +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/cardo_python_utils.egg-info/requires.txt +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/cardo_python_utils.egg-info/top_level.txt +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/choices.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/data_structures.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/db.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/django_utils.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/esma_choices.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/exceptions.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/imports.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/admin/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/admin/auth.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/admin/user_group.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/api/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/models/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/models/user_group.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/service.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/django/tests/__init__.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/utils.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/math.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/text.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/time.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/types_hinting.py +0 -0
- {cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/setup.cfg +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cardo-python-utils"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.dev29"
|
|
8
8
|
description = "Python library enhanced with a wide range of functions for different scenarios."
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -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)
|
|
@@ -80,7 +80,7 @@ def mock_verify_scopes_ninja():
|
|
|
80
80
|
Patches AuthBearer._verify_scopes, so that no real scope checking is done during tests.
|
|
81
81
|
This is done because scope checking uses route resolution, which the test client does not support.
|
|
82
82
|
"""
|
|
83
|
-
with patch("python_utils.django.
|
|
83
|
+
with patch("python_utils.keycloak.django.api.ninja.AuthBearer._verify_scopes") as mock_verify:
|
|
84
84
|
mock_verify.return_value = None
|
|
85
85
|
yield mock_verify
|
|
86
86
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/data_structures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cardo_python_utils-0.5.dev27 → cardo_python_utils-0.5.dev29}/python_utils/keycloak/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|