trovesuite 1.0.13__tar.gz → 1.0.16__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 (44) hide show
  1. {trovesuite-1.0.13/src/trovesuite.egg-info → trovesuite-1.0.16}/PKG-INFO +1 -1
  2. {trovesuite-1.0.13 → trovesuite-1.0.16}/pyproject.toml +3 -3
  3. {trovesuite-1.0.13 → trovesuite-1.0.16}/setup.py +1 -1
  4. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/__init__.py +5 -3
  5. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/auth_service.py +26 -11
  6. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/configs/settings.py +10 -5
  7. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/utils/__init__.py +3 -1
  8. trovesuite-1.0.16/src/trovesuite/utils/helper.py +653 -0
  9. trovesuite-1.0.16/src/trovesuite/utils/templates.py +487 -0
  10. {trovesuite-1.0.13 → trovesuite-1.0.16/src/trovesuite.egg-info}/PKG-INFO +1 -1
  11. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite.egg-info/SOURCES.txt +2 -1
  12. trovesuite-1.0.13/src/trovesuite/utils/helper.py +0 -36
  13. {trovesuite-1.0.13 → trovesuite-1.0.16}/LICENSE +0 -0
  14. {trovesuite-1.0.13 → trovesuite-1.0.16}/MANIFEST.in +0 -0
  15. {trovesuite-1.0.13 → trovesuite-1.0.16}/README.md +0 -0
  16. {trovesuite-1.0.13 → trovesuite-1.0.16}/requirements.txt +0 -0
  17. {trovesuite-1.0.13 → trovesuite-1.0.16}/setup.cfg +0 -0
  18. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/__init__.py +0 -0
  19. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/auth_base.py +0 -0
  20. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/auth_controller.py +0 -0
  21. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/auth_read_dto.py +0 -0
  22. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/auth/auth_write_dto.py +0 -0
  23. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/configs/__init__.py +0 -0
  24. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/configs/database.py +0 -0
  25. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/configs/logging.py +0 -0
  26. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/entities/__init__.py +0 -0
  27. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/entities/health.py +0 -0
  28. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/entities/sh_response.py +0 -0
  29. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/__init__.py +0 -0
  30. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/notification_base.py +0 -0
  31. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/notification_controller.py +0 -0
  32. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/notification_read_dto.py +0 -0
  33. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/notification_service.py +0 -0
  34. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/notification/notification_write_dto.py +0 -0
  35. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/__init__.py +0 -0
  36. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/storage_base.py +0 -0
  37. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/storage_controller.py +0 -0
  38. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/storage_read_dto.py +0 -0
  39. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/storage_service.py +0 -0
  40. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite/storage/storage_write_dto.py +0 -0
  41. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite.egg-info/dependency_links.txt +0 -0
  42. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite.egg-info/not-zip-safe +0 -0
  43. {trovesuite-1.0.13 → trovesuite-1.0.16}/src/trovesuite.egg-info/requires.txt +0 -0
  44. {trovesuite-1.0.13 → trovesuite-1.0.16}/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.13
3
+ Version: 1.0.16
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.13"
7
+ version = "1.0.16"
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.13"
61
+ version = "1.0.16"
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"}
@@ -121,7 +121,7 @@ Documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
121
121
  [tool.setuptools.packages.find]
122
122
  where = ["src"]
123
123
  include = ["trovesuite*"]
124
- exclude = ["*controller*", "*main*", "*test*"]
124
+ exclude = ["*test*"]
125
125
 
126
126
  [tool.setuptools.package-dir]
127
127
  "" = "src"
@@ -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.13",
18
+ version="1.0.16",
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",
@@ -3,19 +3,21 @@ TroveSuite Package
3
3
 
4
4
  A comprehensive authentication, authorization, notification, and storage service for ERP systems.
5
5
  Provides JWT token validation, user authorization, permission checking, notification capabilities,
6
- and Azure Storage blob management.
6
+ Azure Storage blob management, and utility functions for multi-tenant applications.
7
7
  """
8
8
 
9
9
  from .auth import AuthService
10
10
  from .notification import NotificationService
11
11
  from .storage import StorageService
12
+ from .utils import Helper
12
13
 
13
- __version__ = "1.0.7"
14
+ __version__ = "1.0.16"
14
15
  __author__ = "Bright Debrah Owusu"
15
16
  __email__ = "owusu.debrah@deladetech.com"
16
17
 
17
18
  __all__ = [
18
19
  "AuthService",
19
20
  "NotificationService",
20
- "StorageService"
21
+ "StorageService",
22
+ "Helper",
21
23
  ]
@@ -229,12 +229,11 @@ class AuthService:
229
229
  logger.info(f"Fetching system-level roles for user: {user_id}")
230
230
 
231
231
  system_roles = DatabaseManager.execute_query(
232
- """
232
+ f"""
233
233
  SELECT DISTINCT sug.group_id, sug.user_id, sar.role_id, sar.resource_type
234
- FROM main.system_user_groups sug
235
- INNER JOIN main.system_assign_roles sar ON sug.group_id = sar.group_id
234
+ FROM {db_settings.MAIN_SYSTEM_USER_GROUPS_TABLE} sug
235
+ INNER JOIN {db_settings.MAIN_SYSTEM_ASSIGN_ROLES_TABLE} sar ON sug.group_id = sar.group_id
236
236
  WHERE sug.user_id = %s
237
- AND sug.delete_status = 'NOT_DELETED'
238
237
  AND sar.is_active = true
239
238
  AND sar.delete_status = 'NOT_DELETED'
240
239
  """,
@@ -248,9 +247,9 @@ class AuthService:
248
247
 
249
248
  # ✅ NEW: Also check for direct system role assignments (user_id in system_assign_roles)
250
249
  direct_system_roles = DatabaseManager.execute_query(
251
- """
250
+ f"""
252
251
  SELECT DISTINCT NULL as group_id, sar.user_id, sar.role_id, sar.resource_type
253
- FROM main.system_assign_roles sar
252
+ FROM {db_settings.MAIN_SYSTEM_ASSIGN_ROLES_TABLE} sar
254
253
  WHERE sar.user_id = %s
255
254
  AND sar.is_active = true
256
255
  AND sar.delete_status = 'NOT_DELETED'
@@ -347,18 +346,34 @@ class AuthService:
347
346
  def authorize_user_from_token(token: str) -> Respons[AuthServiceReadDto]:
348
347
  """
349
348
  Convenience method to authorize a user directly from a JWT token.
350
-
349
+
351
350
  Args:
352
351
  token: JWT token string
353
-
352
+
354
353
  Returns:
355
354
  Respons[AuthServiceReadDto]: Authorization result with user roles and permissions
356
-
355
+
357
356
  Raises:
358
357
  HTTPException: If token is invalid
359
358
  """
360
- user_info = AuthService.decode_token(token)
361
- return AuthService.authorize(user_info["user_id"], user_info["tenant_id"])
359
+ credentials_exception = HTTPException(
360
+ status_code=401,
361
+ detail="Could not validate credentials",
362
+ headers={"WWW-Authenticate": "Bearer"},
363
+ )
364
+ try:
365
+ payload = jwt.decode(token, db_settings.SECRET_KEY, algorithms=[db_settings.ALGORITHM])
366
+ user_id = payload.get("user_id")
367
+ tenant_id = payload.get("tenant_id")
368
+
369
+ if user_id is None or tenant_id is None:
370
+ raise credentials_exception
371
+
372
+ data = AuthServiceWriteDto(user_id=user_id, tenant_id=tenant_id)
373
+ return AuthService.authorize(data=data)
374
+
375
+ except jwt.InvalidTokenError as exc:
376
+ raise credentials_exception from exc
362
377
 
363
378
  @staticmethod
364
379
  def get_user_permissions(user_roles: list) -> list:
@@ -32,11 +32,16 @@ class Settings:
32
32
  # =============================================================================
33
33
  # SHARED TABLES (main schema)
34
34
  # =============================================================================
35
- MAIN_TENANTS_TABLE = os.getenv("MAIN_TENANTS_TABLE")
36
- MAIN_ROLE_PERMISSIONS_TABLE = os.getenv("MAIN_ROLE_PERMISSIONS_TABLE")
37
- MAIN_USER_SUBSCRIPTIONS_TABLE = os.getenv("MAIN_USER_SUBSCRIPTIONS_TABLE")
38
- MAIN_USER_SUBSCRIPTION_HISTORY_TABLE = os.getenv("MAIN_USER_SUBSCRIPTION_HISTORY_TABLE")
39
- MAIN_SUBSCRIPTIONS_TABLE = os.getenv("MAIN_SUBSCRIPTIONS_TABLE")
35
+ MAIN_TENANTS_TABLE = os.getenv("MAIN_TENANTS_TABLE", "main.tenants")
36
+ MAIN_ROLE_PERMISSIONS_TABLE = os.getenv("MAIN_ROLE_PERMISSIONS_TABLE", "main.role_permissions")
37
+ MAIN_USER_SUBSCRIPTIONS_TABLE = os.getenv("MAIN_USER_SUBSCRIPTIONS_TABLE", "main.user_subscriptions")
38
+ MAIN_USER_SUBSCRIPTION_HISTORY_TABLE = os.getenv("MAIN_USER_SUBSCRIPTION_HISTORY_TABLE", "main.user_subscription_history")
39
+ MAIN_SUBSCRIPTIONS_TABLE = os.getenv("MAIN_SUBSCRIPTIONS_TABLE", "main.subscriptions")
40
+
41
+ # System-level tables
42
+ MAIN_SYSTEM_GROUPS_TABLE = os.getenv("MAIN_SYSTEM_GROUPS_TABLE", "main.system_groups")
43
+ MAIN_SYSTEM_USER_GROUPS_TABLE = os.getenv("MAIN_SYSTEM_USER_GROUPS_TABLE", "main.system_user_groups")
44
+ MAIN_SYSTEM_ASSIGN_ROLES_TABLE = os.getenv("MAIN_SYSTEM_ASSIGN_ROLES_TABLE", "main.system_assign_roles")
40
45
 
41
46
  # =============================================================================
42
47
  # TENANT-SPECIFIC TABLES (tenant schemas)
@@ -5,7 +5,9 @@ Utility functions and helpers for TroveSuite services.
5
5
  """
6
6
 
7
7
  from .helper import Helper
8
+ from . import templates
8
9
 
9
10
  __all__ = [
10
- "Helper"
11
+ "Helper",
12
+ "templates",
11
13
  ]