cardo-python-utils 0.5.dev53__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.dev53
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,20 +1,20 @@
1
- cardo_python_utils-0.5.dev53.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
5
5
  python_utils/db.py,sha256=GA46Eeaoi82PPoEubbpu9uIBCX7brvpvlkekBO5Iaww,455
6
6
  python_utils/django_utils.py,sha256=hZsUnCIRgw6rMLOKwd7RdDznviTIQJBSWpmbmbYt4S0,16107
7
- python_utils/esma_choices.py,sha256=rAOL7rxle1iDVgzguwqN1m38tYgW-3hqC-NUXx2nFOk,16843
7
+ python_utils/esma_choices.py,sha256=5KAg8cB-y2Zdq-MTphhRKO7WdM2nTJH_wNuZLmKvYro,17558
8
8
  python_utils/exceptions.py,sha256=gTpb46B-xE_m6tMo-LJOkWsZjzq1qyH2ZLTYjQcxDQQ,751
9
9
  python_utils/imports.py,sha256=iMHVUiim2rgp-FHdbH-M0H0aFNdCe2dWqBU3kVHFO0Q,913
10
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
@@ -43,7 +43,7 @@ python_utils/django/management/commands/shell.py,sha256=fGHJ1i-p-TQ9lFLOz0j4dm_H
43
43
  python_utils/django/management/commands/showmigrations.py,sha256=mwNnL2EYAqX3iZ5-YI86X1-9YhbHvmMMG_wX3wNykKc,1260
44
44
  python_utils/django/management/commands/tenant_aware_command.py,sha256=MBI7N0BEHZAhK183QmFjjEdDecM060O0nsxg0spH9Mc,2440
45
45
  python_utils/django/middleware/__init__.py,sha256=GyhuzaOtaXW13iB9GL0XF7OvEEzKoJzorJzYX597idA,117
46
- python_utils/django/middleware/tenant_aware_http_middleware.py,sha256=W8U3-nR90b8m_wz5xDJTuImUrPEXvESzYh3VITYMIJU,3825
46
+ python_utils/django/middleware/tenant_aware_http_middleware.py,sha256=ifEkUtGtd9wEyBrPWzUhysSaUM2BkkNu8dnIpabhXI0,3950
47
47
  python_utils/django/middleware/tenant_aware_websocket_middleware.py,sha256=k6bn4pS4uZcTPafF7Yz_8VAj0vchEfJSXM4Bxb-Od-k,4100
48
48
  python_utils/django/migrations/0001_initial.py,sha256=j-y64JqkDv2A1o2YzJB9NE41KFOOiVmQn0-fv9A98WU,4841
49
49
  python_utils/django/migrations/0001_initial_squashed_0005_alter_userrole_id.py,sha256=PveIcroiawK2Mr4Vh0lsj5bjJfyaA98wdSfn_g53WZI,5803
@@ -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.dev53.dist-info/METADATA,sha256=OQENj0UZFzNZWi0xazB6ZH6qv5wc9GsaapXXXocNJWQ,3007
68
- cardo_python_utils-0.5.dev53.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
69
- cardo_python_utils-0.5.dev53.dist-info/top_level.txt,sha256=zAx6OfEsjJs8BEW3okSiG_j9gpkI69xWShzum6oBgKI,13
70
- cardo_python_utils-0.5.dev53.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,
@@ -10,6 +10,8 @@ from ..tenant_context import TenantContext
10
10
 
11
11
  logger = logging.getLogger(__name__)
12
12
 
13
+ DEFAULT_EXCLUDED_PATHS = ["/", "/healthz", "/healthz/"]
14
+
13
15
 
14
16
  class TenantAwareHttpMiddleware:
15
17
  """
@@ -72,6 +74,9 @@ class TenantAwareHttpMiddleware:
72
74
  """
73
75
  Check if the path should be excluded from tenant handling.
74
76
  """
77
+ if path in DEFAULT_EXCLUDED_PATHS:
78
+ return True
79
+
75
80
  for excluded_path in TENANT_AWARE_EXCLUDED_PATHS:
76
81
  if path.startswith(excluded_path):
77
82
  return True
@@ -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:
@@ -42,6 +42,9 @@ class FinancialCreditAssetFinancingPurposeChoices(ChoiceEnum):
42
42
  OTHV = 16, "Other Vehicle"
43
43
  EQUP = 17, "Equipment"
44
44
  PROP = 18, "Property"
45
+ PURC = 20, "Purchase"
46
+ RFTM = 21, "Rate/Term Refinance"
47
+ COUT = 22, "Cash-Out Refinance"
45
48
  OTHR = 100, "Other"
46
49
 
47
50
 
@@ -60,6 +63,9 @@ class InterestRateTypeChoices(ChoiceEnum):
60
63
  MODE = 12, "Modular"
61
64
  OTHR = 13, "Other"
62
65
  FXRT = 14, "Fixed Rate"
66
+ VARI = 15, "Variable (ARM)"
67
+ HYBR = 16, "Hybrid ARM (Fixed-to-Variable)"
68
+ STEP = 17, "Step Rate"
63
69
 
64
70
 
65
71
  class SeniorityChoices(ChoiceEnum):
@@ -86,7 +92,13 @@ class EmploymentStatusChoices(ChoiceEnum):
86
92
  STNT = 6, "Student"
87
93
  PNNR = 7, "Pensioner"
88
94
  NOEM = 8, "No Employment, Obligor is Legal Entity"
95
+ RETI = 9, "Retired"
89
96
  OTHR = 10, "Other"
97
+ UNUM = 11, "Unemployed"
98
+ PATE = 12, "Part-Time Employed"
99
+ CNTR = 13, "Contract / Freelance"
100
+ BOWN = 14, "Business Owner"
101
+ SEAS = 15, "Seasonally Employed"
90
102
 
91
103
 
92
104
  class PrimaryIncomeTypeChoices(ChoiceEnum):
@@ -100,6 +112,15 @@ class PrimaryIncomeTypeChoices(ChoiceEnum):
100
112
  DSPL = 8, "Disposable Income"
101
113
  CORP = 9, "Borrower is legal entity"
102
114
  OTHR = 10, "Other"
115
+ SALR = 11, "Salary"
116
+ SEMP = 12, "Self-Employment Income"
117
+ BUSI = 13, "Business Income"
118
+ RENT = 14, "Rental Income"
119
+ INVT = 15, "Investment Income"
120
+ CNTR = 16, "1099 / Contract Income"
121
+ PENS = 17, "Pension / Retirement"
122
+ SOCS = 18, "Social Security / Disability"
123
+ ROYA = 19, "Royalties"
103
124
 
104
125
 
105
126
  class PrimaryIncomeVerificationChoices(ChoiceEnum):