cardo-python-utils 0.5.dev54__py3-none-any.whl → 0.5.dev55__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.dev54
3
+ Version: 0.5.dev55
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.dev54.dist-info/licenses/LICENSE,sha256=N-YtxDy8n5A1Mo7JKKItNIlboiK_pMOZ48ojx76jo3g,1046
1
+ cardo_python_utils-0.5.dev55.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
@@ -11,10 +11,10 @@ python_utils/math.py,sha256=p_v8a9nVSe9426nR8H_SM8hOQrkzESVpCnn3gntw7TA,5603
11
11
  python_utils/text.py,sha256=pw9CZeM_Lcw-6k4GyR-4D1Wix8A7F_V1u1IIZTIazW4,3792
12
12
  python_utils/time.py,sha256=7Wei3uJ02Bk-BFRf-e1axoG418XQOhrXPvTwNZgTdnw,9614
13
13
  python_utils/types_hinting.py,sha256=QVWzmXRgNxhvln14tEX_FbQYryuVYhjWJ0dVOnlF6G4,120
14
- python_utils/django/README.md,sha256=J9CEKaFiMGOnIRsoIpDbQPlno4O6vgymMJLQHmeSnVg,7236
14
+ python_utils/django/README.md,sha256=Yz9GJj_NVNlCgLkH4-6KRpQ7BZ3QIcQno_TqFp7gPQ4,7175
15
15
  python_utils/django/__init__.py,sha256=uXyqF-_5gZAlSIKoQkUTedAeBjnUHqh6lR6SzA1DEOM,64
16
16
  python_utils/django/apps.py,sha256=vH2Ov8XgavTGKFLSjbH1kvuG7RWQCjeJepw6BSp2o3E,126
17
- python_utils/django/oidc_settings.py,sha256=JqF-qOfW23JhmmVciN1B7ZV-KI7qrdn5VigTE7E2k_0,4367
17
+ python_utils/django/oidc_settings.py,sha256=wurcxA3ImauMzT8RoASDDpsNiA5ixaAD5Bjm3fiscDA,4624
18
18
  python_utils/django/settings.py,sha256=dbu4QPvG8N_z7P8eisEgI4qNwy2T8ZPNDkx9FoK4FEs,624
19
19
  python_utils/django/tenant_context.py,sha256=9LN15__PGhajy7raK382vVx8r5k90VUwUZJS4ylW0yA,3231
20
20
  python_utils/django/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -27,7 +27,7 @@ python_utils/django/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
27
27
  python_utils/django/api/drf.py,sha256=ar94uAVIaHDxzi3K7ubNSJDuysUWjV_xv0sFXtkJEuc,3101
28
28
  python_utils/django/api/ninja.py,sha256=Rz7331hYmKo4jyxtuvEKzOaNUjdmuCpXeHYkWGf0NsA,4863
29
29
  python_utils/django/api/utils.py,sha256=ycpSnTtGcfdGP1_Hk0P2c8ZNId70xOYtjx1m0nAUWRM,3465
30
- python_utils/django/auth/service.py,sha256=9gMURteyVnfjpZLyrvjAvgglfi2NPwrdia2LDVPfxBs,7475
30
+ python_utils/django/auth/service.py,sha256=ggv_qc5B3vmoamoqLiEvU5XWJWcVr57rL0INz5826HE,7485
31
31
  python_utils/django/celery/__init__.py,sha256=eqKpBqhClH-7oK-kD1SUEpzt4Gqu7VWLWmhFUktee0A,79
32
32
  python_utils/django/celery/tenant_aware_database_scheduler.py,sha256=Qcz8mFhfFcX8Opzb75qvuF9jxwuY8Nsn0gxIBKFaU8w,8087
33
33
  python_utils/django/celery/tenant_aware_task.py,sha256=kjcAfAAOUAveOKaoOBe-yJLdhXIT7CMgNKOPOFKjEbQ,4065
@@ -64,7 +64,7 @@ python_utils/django/storage/__init__.py,sha256=mNn2YmD7pkXhBLHMM1444BLsCMq78YdYx
64
64
  python_utils/django/storage/tenant_aware_storage.py,sha256=5dDes6xLv7_R8hIBbFIzRvPL7HL9K_RM-G6LI8qUSxM,2550
65
65
  python_utils/django/tests/__init__.py,sha256=Nkt0a7LEHyjLvuEBZ7113VjjAWJlyZlMy-H-JZ5tNcs,252
66
66
  python_utils/django/tests/conftest.py,sha256=KozXmXUWVcDLbkVAb7Aq4sDydGLh2YZkbRa4tkA8Z6U,3167
67
- cardo_python_utils-0.5.dev54.dist-info/METADATA,sha256=SV__9SgTbOipkQM-Ar4UKO0yvoUNJoxgPDLDz9Ykt9A,3007
68
- cardo_python_utils-0.5.dev54.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
69
- cardo_python_utils-0.5.dev54.dist-info/top_level.txt,sha256=zAx6OfEsjJs8BEW3okSiG_j9gpkI69xWShzum6oBgKI,13
70
- cardo_python_utils-0.5.dev54.dist-info/RECORD,,
67
+ cardo_python_utils-0.5.dev55.dist-info/METADATA,sha256=493CmMRlAB8Nmk60wyMjUXF6iNUuAVhs9dnOs4Qx3lU,3007
68
+ cardo_python_utils-0.5.dev55.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
69
+ cardo_python_utils-0.5.dev55.dist-info/top_level.txt,sha256=zAx6OfEsjJs8BEW3okSiG_j9gpkI69xWShzum6oBgKI,13
70
+ cardo_python_utils-0.5.dev55.dist-info/RECORD,,
@@ -10,8 +10,6 @@ This package provides utilities for facilitating IDP communication and multi-ten
10
10
  - DATABASE_CONFIG
11
11
  - A JSON dictionary where each key is the tenant name and the value is a dict with the datase config.
12
12
  - If multiple 'DATABASE_CONFIG'-prefixed variables are set, they will be merged into a single dictionary.
13
- - KEYCLOAK_SERVER_URL
14
- - The URL of the Keycloak deployment
15
13
  - KEYCLOAK_CONFIDENTIAL_CLIENT_ID
16
14
  - The id of the confidential client of the backend service
17
15
  - KEYCLOAK_CONFIDENTIAL_CLIENT_SERVICE_ACCOUNT_TOKEN_FILE_PATHS
@@ -6,8 +6,8 @@ from keycloak import KeycloakOpenIDConnection
6
6
  from keycloak.exceptions import KeycloakGetError
7
7
 
8
8
  from ..oidc_settings import (
9
- KEYCLOAK_SERVER_URL,
10
9
  KEYCLOAK_CONFIDENTIAL_CLIENT_ID,
10
+ get_keycloak_server_url,
11
11
  get_oidc_confidential_client_token,
12
12
  )
13
13
  from ..tenant_context import TenantContext
@@ -70,7 +70,7 @@ class KeycloakService:
70
70
  tenant = TenantContext.get()
71
71
 
72
72
  keycloak_connection = KeycloakOpenIDConnection(
73
- server_url=KEYCLOAK_SERVER_URL,
73
+ server_url=get_keycloak_server_url(),
74
74
  realm_name=tenant,
75
75
  user_realm_name=tenant,
76
76
  client_id=KEYCLOAK_CONFIDENTIAL_CLIENT_ID,
@@ -12,7 +12,7 @@ from django.conf import settings
12
12
  from .tenant_context import TenantContext
13
13
 
14
14
 
15
- KEYCLOAK_SERVER_URL = os.getenv("KEYCLOAK_SERVER_URL", None)
15
+ KEYCLOAK_SERVER_URL_TEMPLATE = os.getenv("KEYCLOAK_SERVER_URL_TEMPLATE", "https://keycloak.{realm}.company.com")
16
16
  KEYCLOAK_CONFIDENTIAL_CLIENT_ID = os.getenv("KEYCLOAK_CONFIDENTIAL_CLIENT_ID", None)
17
17
 
18
18
  OIDC_CLIENT_AUTH_METHOD = getattr(settings, "OIDC_CLIENT_AUTH_METHOD", "client_assertion")
@@ -45,11 +45,17 @@ def get_realm_for_tenant(tenant: str) -> str:
45
45
  return TENANT_REALM_MAPPING.get(tenant, tenant)
46
46
 
47
47
 
48
+ def get_keycloak_server_url() -> str:
49
+ """Get the Keycloak server URL for the current tenant."""
50
+
51
+ return KEYCLOAK_SERVER_URL_TEMPLATE.format(realm=get_realm_for_tenant(TenantContext.get()))
52
+
53
+
48
54
  def get_oidc_op_base_url() -> str:
49
55
  """Get the base URL for the OIDC provider (Keycloak realm URL)."""
50
56
 
51
57
  realm = get_realm_for_tenant(TenantContext.get())
52
- return f"{KEYCLOAK_SERVER_URL}/realms/{realm}"
58
+ return f"{get_keycloak_server_url()}/realms/{realm}"
53
59
 
54
60
 
55
61
  def get_oidc_op_authorization_endpoint() -> str: