cardo-python-utils 0.5.dev25__tar.gz → 0.5.dev27__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.dev25/cardo_python_utils.egg-info → cardo_python_utils-0.5.dev27}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27/cardo_python_utils.egg-info}/PKG-INFO +1 -1
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/pyproject.toml +1 -1
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/admin/auth.py +8 -5
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/utils.py +3 -1
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/LICENSE +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/MANIFEST.in +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/README.rst +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/cardo_python_utils.egg-info/SOURCES.txt +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/cardo_python_utils.egg-info/dependency_links.txt +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/cardo_python_utils.egg-info/requires.txt +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/cardo_python_utils.egg-info/top_level.txt +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/choices.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/data_structures.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/db.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/django_utils.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/esma_choices.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/exceptions.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/imports.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/admin/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/admin/user_group.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/api/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/api/drf.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/api/ninja.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/api/utils.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/models/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/models/user_group.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/service.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/tests/__init__.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/django/tests/conftest.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/math.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/text.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/time.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/types_hinting.py +0 -0
- {cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/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.dev27"
|
|
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"
|
|
@@ -6,15 +6,18 @@ from ...utils import get_keycloak_confidential_client_token
|
|
|
6
6
|
|
|
7
7
|
class AdminAuthenticationBackend(OIDCAuthenticationBackend):
|
|
8
8
|
def get_token(self, payload):
|
|
9
|
-
|
|
9
|
+
# Instead of passing client_id and client_secret,
|
|
10
|
+
# client_assertion with service account token will be used
|
|
11
|
+
payload.pop("client_id", None)
|
|
12
|
+
payload.pop("client_secret", None)
|
|
13
|
+
|
|
14
|
+
return get_keycloak_confidential_client_token(**payload)
|
|
10
15
|
|
|
11
16
|
def _get_user_data(self, claims) -> dict:
|
|
12
17
|
client_roles = (
|
|
13
|
-
claims.get("resource_access", {})
|
|
14
|
-
.get(getattr(settings, "OIDC_RP_CLIENT_ID", ""), {})
|
|
15
|
-
.get("roles", [])
|
|
18
|
+
claims.get("resource_access", {}).get(getattr(settings, "OIDC_RP_CLIENT_ID", ""), {}).get("roles", [])
|
|
16
19
|
)
|
|
17
|
-
is_superuser = "
|
|
20
|
+
is_superuser = "AdminPanel" in client_roles
|
|
18
21
|
|
|
19
22
|
return {
|
|
20
23
|
"username": claims.get("preferred_username"),
|
{cardo_python_utils-0.5.dev25 → cardo_python_utils-0.5.dev27}/python_utils/keycloak/utils.py
RENAMED
|
@@ -31,17 +31,19 @@ def get_confidential_client_service_account_token() -> str:
|
|
|
31
31
|
return token
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
def get_keycloak_confidential_client_token() -> dict:
|
|
34
|
+
def get_keycloak_confidential_client_token(**kwargs) -> dict:
|
|
35
35
|
"""
|
|
36
36
|
Obtains token for a Keycloak confidential client with the client credentials grant,
|
|
37
37
|
using a service account token for authentication.
|
|
38
38
|
"""
|
|
39
|
+
|
|
39
40
|
response = requests.post(
|
|
40
41
|
KEYCLOAK_TOKEN_ENDPOINT,
|
|
41
42
|
data={
|
|
42
43
|
"grant_type": KEYCLOAK_CLIENT_CREDENTIALS_GRANT_TYPE,
|
|
43
44
|
"client_assertion_type": KEYCLOAK_CLIENT_ASSERTION_TYPE,
|
|
44
45
|
"client_assertion": get_confidential_client_service_account_token(),
|
|
46
|
+
**kwargs,
|
|
45
47
|
},
|
|
46
48
|
)
|
|
47
49
|
response.raise_for_status()
|
|
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.dev25 → cardo_python_utils-0.5.dev27}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|