trovesuite 1.0.20__py3-none-any.whl → 1.0.22__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.
- trovesuite/__init__.py +1 -1
- trovesuite/auth/auth_service.py +64 -14
- {trovesuite-1.0.20.dist-info → trovesuite-1.0.22.dist-info}/METADATA +1 -1
- {trovesuite-1.0.20.dist-info → trovesuite-1.0.22.dist-info}/RECORD +7 -7
- {trovesuite-1.0.20.dist-info → trovesuite-1.0.22.dist-info}/WHEEL +0 -0
- {trovesuite-1.0.20.dist-info → trovesuite-1.0.22.dist-info}/licenses/LICENSE +0 -0
- {trovesuite-1.0.20.dist-info → trovesuite-1.0.22.dist-info}/top_level.txt +0 -0
trovesuite/__init__.py
CHANGED
trovesuite/auth/auth_service.py
CHANGED
|
@@ -279,24 +279,74 @@ class AuthService:
|
|
|
279
279
|
|
|
280
280
|
# GET permissions and Append to Role
|
|
281
281
|
get_user_roles_with_tenant_and_permissions = []
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
|
|
283
|
+
# Track system role IDs by querying cp_roles table for is_system flag (more reliable)
|
|
284
|
+
system_role_ids = set()
|
|
285
|
+
if all_roles:
|
|
286
|
+
role_ids = [r.get("role_id") for r in all_roles if r.get("role_id")]
|
|
287
|
+
if role_ids:
|
|
288
|
+
try:
|
|
289
|
+
# Check which roles are system roles by querying the roles table
|
|
290
|
+
system_roles_check = DatabaseManager.execute_query(
|
|
291
|
+
f"""SELECT id FROM {db_settings.CORE_PLATFORM_ROLES_TABLE}
|
|
292
|
+
WHERE id = ANY(%s) AND is_system = true AND delete_status = 'NOT_DELETED'""",
|
|
293
|
+
params=(role_ids,),
|
|
294
|
+
)
|
|
295
|
+
if system_roles_check:
|
|
296
|
+
for role_record in system_roles_check:
|
|
297
|
+
role_id = role_record.get("id") if isinstance(role_record, dict) else (role_record[0] if isinstance(role_record, (list, tuple)) and len(role_record) > 0 else None)
|
|
298
|
+
if role_id:
|
|
299
|
+
system_role_ids.add(role_id)
|
|
300
|
+
|
|
301
|
+
logger.info(f"Identified {len(system_role_ids)} system roles for user {user_id}")
|
|
302
|
+
except Exception as e:
|
|
303
|
+
logger.warning(f"Error checking system roles: {str(e)}")
|
|
304
|
+
# Fallback: use system_roles query results
|
|
305
|
+
system_role_ids = {r["role_id"] for r in system_roles} if system_roles else set()
|
|
306
|
+
if direct_system_roles:
|
|
307
|
+
system_role_ids.update({r["role_id"] for r in direct_system_roles})
|
|
286
308
|
|
|
287
309
|
for role in all_roles:
|
|
288
|
-
role_id = role
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
310
|
+
role_id = role.get("role_id")
|
|
311
|
+
if not role_id:
|
|
312
|
+
logger.warning(f"Skipping role with missing role_id: {role}")
|
|
313
|
+
continue
|
|
314
|
+
|
|
315
|
+
# Determine which tenant_id to use for querying permissions
|
|
316
|
+
# For system roles, use 'system-tenant-id'; for tenant roles, use the user's tenant_id
|
|
317
|
+
is_system_role = role_id in system_role_ids
|
|
318
|
+
|
|
319
|
+
# Try the primary tenant_id first based on whether it's a system role
|
|
320
|
+
if is_system_role:
|
|
321
|
+
primary_tenant_id = 'system-tenant-id'
|
|
322
|
+
fallback_tenant_id = tenant_id
|
|
292
323
|
else:
|
|
293
|
-
|
|
324
|
+
primary_tenant_id = tenant_id
|
|
325
|
+
fallback_tenant_id = 'system-tenant-id'
|
|
294
326
|
|
|
295
|
-
permissions
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
327
|
+
# Query permissions for this role with primary tenant_id
|
|
328
|
+
permissions = []
|
|
329
|
+
try:
|
|
330
|
+
permissions = DatabaseManager.execute_query(
|
|
331
|
+
f"""SELECT permission_id FROM {db_settings.CORE_PLATFORM_ROLE_PERMISSIONS_TABLE}
|
|
332
|
+
WHERE role_id = %s AND tenant_id = %s AND delete_status = 'NOT_DELETED'""",
|
|
333
|
+
params=(role_id, primary_tenant_id),
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
# If no permissions found with primary tenant_id, try fallback (handles edge cases)
|
|
337
|
+
if not permissions or len(permissions) == 0:
|
|
338
|
+
logger.debug(f"No permissions found for role {role_id} with tenant {primary_tenant_id}, trying fallback {fallback_tenant_id}")
|
|
339
|
+
fallback_permissions = DatabaseManager.execute_query(
|
|
340
|
+
f"""SELECT permission_id FROM {db_settings.CORE_PLATFORM_ROLE_PERMISSIONS_TABLE}
|
|
341
|
+
WHERE role_id = %s AND tenant_id = %s AND delete_status = 'NOT_DELETED'""",
|
|
342
|
+
params=(role_id, fallback_tenant_id),
|
|
343
|
+
)
|
|
344
|
+
if fallback_permissions and len(fallback_permissions) > 0:
|
|
345
|
+
permissions = fallback_permissions
|
|
346
|
+
logger.info(f"Found permissions for role {role_id} in fallback tenant {fallback_tenant_id}")
|
|
347
|
+
except Exception as e:
|
|
348
|
+
logger.error(f"Error querying permissions for role {role_id}: {str(e)}", exc_info=True)
|
|
349
|
+
permissions = []
|
|
300
350
|
|
|
301
351
|
role_dict = {**role, "tenant_id": tenant_id, "permissions": [p['permission_id'] for p in permissions]}
|
|
302
352
|
get_user_roles_with_tenant_and_permissions.append(role_dict)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trovesuite
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.22
|
|
4
4
|
Summary: TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications
|
|
5
5
|
Home-page: https://dev.azure.com/brightgclt/trovesuite/_git/packages
|
|
6
6
|
Author: Bright Debrah Owusu
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
trovesuite/__init__.py,sha256=
|
|
1
|
+
trovesuite/__init__.py,sha256=vKnbXtMVw2mVbOuJLD1GhwcIx0oaNnyUL7Mrpk9Qa-I,646
|
|
2
2
|
trovesuite/auth/__init__.py,sha256=OjZllVvjul1glDazJ-d5TrNjgHFigFlQQi1G99DYshk,239
|
|
3
3
|
trovesuite/auth/auth_base.py,sha256=rZHQVLeJRBQ8GClgF5UwG-er4_HXVX5-nt8o6_Z29uY,75
|
|
4
4
|
trovesuite/auth/auth_controller.py,sha256=PAgaVlf5TYEfkSfK4vGGsvO84i8zEmeVVXyUF2YBppI,420
|
|
5
5
|
trovesuite/auth/auth_read_dto.py,sha256=e27JqKVPVUM83A_mYF452QCflsvGNo7aKje7q_urwFc,571
|
|
6
|
-
trovesuite/auth/auth_service.py,sha256=
|
|
6
|
+
trovesuite/auth/auth_service.py,sha256=ZSqR8K9HGhza7sJBd-ylsUXwMIyDH8IgCL6rKa6iQg0,23048
|
|
7
7
|
trovesuite/auth/auth_write_dto.py,sha256=rdwI7w6-9QZGv1H0PAGrjkLBCzaMHjgPIXeLb9RmNec,234
|
|
8
8
|
trovesuite/configs/__init__.py,sha256=h1mSZOaZ3kUy1ZMO_m9O9KklsxywM0RfMVZLh9h9WvQ,328
|
|
9
9
|
trovesuite/configs/database.py,sha256=IPSu8fXjxyYeJ3bFknJG06Qm2L2ub6Ht19xhKv8g7nA,11731
|
|
@@ -27,8 +27,8 @@ trovesuite/storage/storage_write_dto.py,sha256=vl1iCZ93bpFmpvkCrn587QtMtOA_TPDse
|
|
|
27
27
|
trovesuite/utils/__init__.py,sha256=mDZuY77BphvQFYLmcWxjP5Tcq9ZZ3WXJWBKB1v6wzHU,185
|
|
28
28
|
trovesuite/utils/helper.py,sha256=NySt18kl4Dc78tN5HiB7SpsCH5DWy3QvG1AMtl-ASBM,26951
|
|
29
29
|
trovesuite/utils/templates.py,sha256=_92k4-EkqWs-h0LNJxPgorbspmp24kDngS7O3qWIFyQ,20388
|
|
30
|
-
trovesuite-1.0.
|
|
31
|
-
trovesuite-1.0.
|
|
32
|
-
trovesuite-1.0.
|
|
33
|
-
trovesuite-1.0.
|
|
34
|
-
trovesuite-1.0.
|
|
30
|
+
trovesuite-1.0.22.dist-info/licenses/LICENSE,sha256=EJT35ct-Q794JYPdAQy3XNczQGKkU1HzToLeK1YVw2s,1070
|
|
31
|
+
trovesuite-1.0.22.dist-info/METADATA,sha256=aUNNd-C2rKgW-tVERlGWzDQsuRHLkZ37qlg1C9EBXfc,21737
|
|
32
|
+
trovesuite-1.0.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
33
|
+
trovesuite-1.0.22.dist-info/top_level.txt,sha256=GzKhG_-MTaxeHrIgkGkBH_nof2vroGFBrjeHKWUIwNc,11
|
|
34
|
+
trovesuite-1.0.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|