trovesuite 1.0.19__tar.gz → 1.0.22__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.
Files changed (43) hide show
  1. {trovesuite-1.0.19/src/trovesuite.egg-info → trovesuite-1.0.22}/PKG-INFO +1 -1
  2. {trovesuite-1.0.19 → trovesuite-1.0.22}/pyproject.toml +2 -2
  3. {trovesuite-1.0.19 → trovesuite-1.0.22}/setup.py +1 -1
  4. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/__init__.py +1 -1
  5. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/auth_service.py +67 -17
  6. {trovesuite-1.0.19 → trovesuite-1.0.22/src/trovesuite.egg-info}/PKG-INFO +1 -1
  7. {trovesuite-1.0.19 → trovesuite-1.0.22}/LICENSE +0 -0
  8. {trovesuite-1.0.19 → trovesuite-1.0.22}/MANIFEST.in +0 -0
  9. {trovesuite-1.0.19 → trovesuite-1.0.22}/README.md +0 -0
  10. {trovesuite-1.0.19 → trovesuite-1.0.22}/requirements.txt +0 -0
  11. {trovesuite-1.0.19 → trovesuite-1.0.22}/setup.cfg +0 -0
  12. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/__init__.py +0 -0
  13. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/auth_base.py +0 -0
  14. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/auth_controller.py +0 -0
  15. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/auth_read_dto.py +0 -0
  16. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/auth/auth_write_dto.py +0 -0
  17. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/configs/__init__.py +0 -0
  18. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/configs/database.py +0 -0
  19. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/configs/logging.py +0 -0
  20. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/configs/settings.py +0 -0
  21. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/entities/__init__.py +0 -0
  22. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/entities/health.py +0 -0
  23. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/entities/sh_response.py +0 -0
  24. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/__init__.py +0 -0
  25. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/notification_base.py +0 -0
  26. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/notification_controller.py +0 -0
  27. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/notification_read_dto.py +0 -0
  28. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/notification_service.py +0 -0
  29. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/notification/notification_write_dto.py +0 -0
  30. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/__init__.py +0 -0
  31. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/storage_base.py +0 -0
  32. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/storage_controller.py +0 -0
  33. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/storage_read_dto.py +0 -0
  34. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/storage_service.py +0 -0
  35. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/storage/storage_write_dto.py +0 -0
  36. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/utils/__init__.py +0 -0
  37. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/utils/helper.py +0 -0
  38. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite/utils/templates.py +0 -0
  39. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite.egg-info/SOURCES.txt +0 -0
  40. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite.egg-info/dependency_links.txt +0 -0
  41. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite.egg-info/not-zip-safe +0 -0
  42. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite.egg-info/requires.txt +0 -0
  43. {trovesuite-1.0.19 → trovesuite-1.0.22}/src/trovesuite.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trovesuite
3
- Version: 1.0.19
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "trovesuite"
7
- version = "1.0.19"
7
+ version = "1.0.22"
8
8
  description = "TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications"
9
9
  authors = ["brightgclt <brightgclt@gmail.com>"]
10
10
  license = "MIT"
@@ -58,7 +58,7 @@ Documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
58
58
 
59
59
  [project]
60
60
  name = "trovesuite"
61
- version = "1.0.19"
61
+ version = "1.0.22"
62
62
  description = "TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications"
63
63
  readme = "README.md"
64
64
  license = {text = "MIT"}
@@ -15,7 +15,7 @@ with open("pyproject.toml", "r", encoding="utf-8") as fh:
15
15
 
16
16
  setup(
17
17
  name="trovesuite",
18
- version="1.0.19",
18
+ version="1.0.22",
19
19
  author="Bright Debrah Owusu",
20
20
  author_email="owusu.debrah@deladetech.com",
21
21
  description="TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications",
@@ -11,7 +11,7 @@ from .notification import NotificationService
11
11
  from .storage import StorageService
12
12
  from .utils import Helper
13
13
 
14
- __version__ = "1.0.16"
14
+ __version__ = "1.0.20"
15
15
  __author__ = "Bright Debrah Owusu"
16
16
  __email__ = "owusu.debrah@deladetech.com"
17
17
 
@@ -237,8 +237,8 @@ class AuthService:
237
237
  system_roles = DatabaseManager.execute_query(
238
238
  f"""
239
239
  SELECT DISTINCT sug.group_id, sug.user_id, sar.role_id, sar.resource_type
240
- FROM {db_settings.CORE_PLATFORM_SYSTEM_USER_GROUPS_TABLE} sug
241
- INNER JOIN {db_settings.CORE_PLATFORM_SYSTEM_ASSIGN_ROLES_TABLE} sar
240
+ FROM {db_settings.CORE_PLATFORM_USER_GROUPS_TABLE} sug
241
+ INNER JOIN {db_settings.CORE_PLATFORM_ASSIGN_ROLES_TABLE} sar
242
242
  ON sug.group_id = sar.group_id AND sug.tenant_id = sar.tenant_id
243
243
  WHERE sug.user_id = %s AND sug.tenant_id = %s
244
244
  AND sug.is_system = true
@@ -260,7 +260,7 @@ class AuthService:
260
260
  direct_system_roles = DatabaseManager.execute_query(
261
261
  f"""
262
262
  SELECT DISTINCT NULL as group_id, sar.user_id, sar.role_id, sar.resource_type
263
- FROM {db_settings.CORE_PLATFORM_SYSTEM_ASSIGN_ROLES_TABLE} sar
263
+ FROM {db_settings.CORE_PLATFORM_ASSIGN_ROLES_TABLE} sar
264
264
  WHERE sar.user_id = %s AND sar.tenant_id = %s
265
265
  AND sar.is_active = true
266
266
  AND sar.delete_status = 'NOT_DELETED'
@@ -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
- # Track system role IDs for quick lookup
283
- system_role_ids = {r["role_id"] for r in system_roles} if system_roles else set()
284
- if direct_system_roles:
285
- system_role_ids.update({r["role_id"] for r in direct_system_roles})
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["role_id"]
289
- # For system roles, use system-tenant-id; for tenant roles, use tenant_id
290
- if role_id in system_role_ids:
291
- role_tenant_id = 'system-tenant-id'
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
- role_tenant_id = tenant_id
324
+ primary_tenant_id = tenant_id
325
+ fallback_tenant_id = 'system-tenant-id'
294
326
 
295
- permissions = DatabaseManager.execute_query(
296
- f"""SELECT permission_id FROM {db_settings.CORE_PLATFORM_ROLE_PERMISSIONS_TABLE}
297
- WHERE role_id = %s AND tenant_id = %s""",
298
- params=(role_id, role_tenant_id),
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.19
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
File without changes
File without changes
File without changes
File without changes