trovesuite 1.0.2__py3-none-any.whl → 1.0.3__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/auth/auth_service.py +4 -4
- trovesuite/configs/settings.py +36 -132
- {trovesuite-1.0.2.dist-info → trovesuite-1.0.3.dist-info}/METADATA +1 -1
- {trovesuite-1.0.2.dist-info → trovesuite-1.0.3.dist-info}/RECORD +7 -7
- {trovesuite-1.0.2.dist-info → trovesuite-1.0.3.dist-info}/WHEEL +0 -0
- {trovesuite-1.0.2.dist-info → trovesuite-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {trovesuite-1.0.2.dist-info → trovesuite-1.0.3.dist-info}/top_level.txt +0 -0
trovesuite/auth/auth_service.py
CHANGED
|
@@ -156,7 +156,7 @@ class AuthService:
|
|
|
156
156
|
|
|
157
157
|
# 1️⃣ Get all groups the user belongs to
|
|
158
158
|
user_groups = DatabaseManager.execute_query(
|
|
159
|
-
f"""SELECT group_id FROM "{tenant_id}".{db_settings.
|
|
159
|
+
f"""SELECT group_id FROM "{tenant_id}".{db_settings.TENANT_USER_GROUPS_TABLE}
|
|
160
160
|
WHERE delete_status = 'NOT_DELETED' AND is_active = true AND user_id = %s""",(user_id,),
|
|
161
161
|
)
|
|
162
162
|
|
|
@@ -169,7 +169,7 @@ class AuthService:
|
|
|
169
169
|
f"""
|
|
170
170
|
SELECT DISTINCT ON (org_id, group_id, bus_id, app_id, shared_resource_id, resource_id, user_id, role_id)
|
|
171
171
|
org_id, group_id, bus_id, app_id, shared_resource_id, resource_id, user_id, role_id
|
|
172
|
-
FROM "{tenant_id}".{db_settings.
|
|
172
|
+
FROM "{tenant_id}".{db_settings.TENANT_ASSIGN_ROLES_TABLE}
|
|
173
173
|
WHERE delete_status = 'NOT_DELETED'
|
|
174
174
|
AND is_active = true
|
|
175
175
|
AND (user_id = %s OR group_id = ANY(%s))
|
|
@@ -183,7 +183,7 @@ class AuthService:
|
|
|
183
183
|
f"""
|
|
184
184
|
SELECT DISTINCT ON (org_id, bus_id, app_id, shared_resource_id, resource_id, user_id, role_id)
|
|
185
185
|
org_id, bus_id, app_id, shared_resource_id, resource_id, user_id, role_id
|
|
186
|
-
FROM "{tenant_id}".{db_settings.
|
|
186
|
+
FROM "{tenant_id}".{db_settings.TENANT_ASSIGN_ROLES_TABLE}
|
|
187
187
|
WHERE delete_status = 'NOT_DELETED'
|
|
188
188
|
AND is_active = true
|
|
189
189
|
AND user_id = %s
|
|
@@ -196,7 +196,7 @@ class AuthService:
|
|
|
196
196
|
get_user_roles_with_tenant_and_permissions = []
|
|
197
197
|
for role in get_user_roles:
|
|
198
198
|
permissions = DatabaseManager.execute_query(
|
|
199
|
-
f"""SELECT permission_id FROM {db_settings.
|
|
199
|
+
f"""SELECT permission_id FROM {db_settings.MAIN_ROLE_PERMISSIONS_TABLE} WHERE role_id = %s""",
|
|
200
200
|
params=(role["role_id"],),)
|
|
201
201
|
|
|
202
202
|
role_dict = {**role, "tenant_id": tenant_id, "permissions": [p['permission_id'] for p in permissions]}
|
trovesuite/configs/settings.py
CHANGED
|
@@ -1,153 +1,57 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import warnings
|
|
3
|
-
from typing import Optional
|
|
4
|
-
|
|
5
2
|
class Settings:
|
|
6
|
-
"""Settings configuration for TroveSuite Auth Service"""
|
|
7
3
|
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
# =============================================================================
|
|
11
|
-
DATABASE_URL: str = os.getenv(
|
|
12
|
-
"DATABASE_URL",
|
|
13
|
-
"postgresql://username:password@localhost:5432/database_name"
|
|
14
|
-
)
|
|
4
|
+
# Database URL
|
|
5
|
+
DATABASE_URL: str = os.getenv("DATABASE_URL")
|
|
15
6
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
DB_PASSWORD: Optional[str] = os.getenv("DB_PASSWORD")
|
|
22
|
-
ENVIRONMENT: str = os.getenv("ENVIRONMENT", "development")
|
|
7
|
+
DB_USER: str = os.getenv("DB_USER")
|
|
8
|
+
DB_HOST: str = os.getenv("DB_HOST")
|
|
9
|
+
DB_NAME: str = os.getenv("DB_NAME")
|
|
10
|
+
DB_PORT: str = os.getenv("DB_PORT")
|
|
11
|
+
DB_PASSWORD: str = os.getenv("DB_PASSWORD")
|
|
23
12
|
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
|
29
|
-
|
|
30
|
-
# =============================================================================
|
|
31
|
-
# SECURITY SETTINGS
|
|
32
|
-
# =============================================================================
|
|
33
|
-
ALGORITHM: str = os.getenv("ALGORITHM", "HS256")
|
|
34
|
-
SECRET_KEY: str = os.getenv("SECRET_KEY", "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7")
|
|
35
|
-
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "60"))
|
|
13
|
+
# Application settings
|
|
14
|
+
APP_NAME: str = os.getenv("APP_NAME", "Python Template API")
|
|
15
|
+
DEBUG: bool = os.getenv("DEBUG", "True").lower() in ("true",1)
|
|
16
|
+
APP_VERSION: str = os.getenv("APP_VERSION", "1.0.0")
|
|
36
17
|
|
|
37
|
-
#
|
|
38
|
-
# LOGGING SETTINGS
|
|
39
|
-
# =============================================================================
|
|
18
|
+
# Logging settings
|
|
40
19
|
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
|
41
20
|
LOG_FORMAT: str = os.getenv("LOG_FORMAT", "detailed") # detailed, json, simple
|
|
42
|
-
LOG_TO_FILE: bool = os.getenv("LOG_TO_FILE", "False").lower()
|
|
21
|
+
LOG_TO_FILE: bool = os.getenv("LOG_TO_FILE", "False").lower() in ("true", 1)
|
|
43
22
|
LOG_MAX_SIZE: int = int(os.getenv("LOG_MAX_SIZE", "10485760")) # 10MB
|
|
44
23
|
LOG_BACKUP_COUNT: int = int(os.getenv("LOG_BACKUP_COUNT", "5"))
|
|
45
24
|
LOG_DIR: str = os.getenv("LOG_DIR", "logs")
|
|
46
|
-
|
|
25
|
+
|
|
26
|
+
# Security settings
|
|
27
|
+
ENVIRONMENT: str = os.getenv("ENVIRONMENT")
|
|
28
|
+
ALGORITHM: str = os.getenv("ALGORITHM")
|
|
29
|
+
SECRET_KEY: str = os.getenv("SECRET_KEY")
|
|
30
|
+
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "120"))
|
|
31
|
+
|
|
47
32
|
# =============================================================================
|
|
48
|
-
#
|
|
33
|
+
# SHARED TABLES (main schema)
|
|
49
34
|
# =============================================================================
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
TENANT_LOGIN_SETTINGS_TABLE: str = os.getenv("TENANT_LOGIN_SETTINGS_TABLE", "login_settings")
|
|
56
|
-
USER_GROUPS_TABLE: str = os.getenv("USER_GROUPS_TABLE", "user_groups")
|
|
57
|
-
ASSIGN_ROLES_TABLE: str = os.getenv("ASSIGN_ROLES_TABLE", "assign_roles")
|
|
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")
|
|
58
40
|
|
|
59
41
|
# =============================================================================
|
|
60
|
-
#
|
|
42
|
+
# TENANT-SPECIFIC TABLES (tenant schemas)
|
|
61
43
|
# =============================================================================
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
TENANT_LOGIN_SETTINGS_TABLE = os.getenv("TENANT_LOGIN_SETTINGS_TABLE")
|
|
45
|
+
TENANT_ASSIGN_ROLES_TABLE = os.getenv("TENANT_ASSIGN_ROLES_TABLE")
|
|
46
|
+
TENANT_USER_GROUPS_TABLE = os.getenv("TENANT_USER_GROUPS_TABLE")
|
|
47
|
+
|
|
65
48
|
@property
|
|
66
49
|
def database_url(self) -> str:
|
|
67
|
-
|
|
68
|
-
if self.DATABASE_URL != "postgresql://username:password@localhost:5432/database_name":
|
|
50
|
+
if self.DATABASE_URL:
|
|
69
51
|
return self.DATABASE_URL
|
|
70
|
-
|
|
71
|
-
# Validate individual components
|
|
72
|
-
if not all([self.DB_USER, self.DB_HOST, self.DB_NAME, self.DB_PASSWORD]):
|
|
73
|
-
missing = []
|
|
74
|
-
if not self.DB_USER:
|
|
75
|
-
missing.append("DB_USER")
|
|
76
|
-
if not self.DB_HOST:
|
|
77
|
-
missing.append("DB_HOST")
|
|
78
|
-
if not self.DB_NAME:
|
|
79
|
-
missing.append("DB_NAME")
|
|
80
|
-
if not self.DB_PASSWORD:
|
|
81
|
-
missing.append("DB_PASSWORD")
|
|
82
|
-
|
|
83
|
-
raise ValueError(
|
|
84
|
-
f"Database configuration incomplete. Missing environment variables: {', '.join(missing)}. "
|
|
85
|
-
f"Please set these variables or provide a complete DATABASE_URL."
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
return f"postgresql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"
|
|
89
|
-
|
|
90
|
-
def validate_configuration(self) -> None:
|
|
91
|
-
"""Validate the current configuration and warn about potential issues"""
|
|
92
|
-
warnings_list = []
|
|
93
|
-
|
|
94
|
-
# Check for default secret key
|
|
95
|
-
if self.SECRET_KEY == "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7":
|
|
96
|
-
warnings_list.append(
|
|
97
|
-
"SECRET_KEY is using the default value. This is insecure for production. "
|
|
98
|
-
"Please set a strong, unique SECRET_KEY environment variable."
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
# Check for development environment in production-like settings
|
|
102
|
-
if self.ENVIRONMENT == "development" and self.DEBUG is False:
|
|
103
|
-
warnings_list.append(
|
|
104
|
-
"ENVIRONMENT is set to 'development' but DEBUG is False. "
|
|
105
|
-
"Consider setting ENVIRONMENT to 'production' for production deployments."
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
# Check database configuration
|
|
109
|
-
try:
|
|
110
|
-
self.database_url
|
|
111
|
-
except ValueError as e:
|
|
112
|
-
warnings_list.append(f"Database configuration issue: {str(e)}")
|
|
113
|
-
|
|
114
|
-
# Check for missing Azure configuration if needed
|
|
115
|
-
if self.ENVIRONMENT == "production" and not self.STORAGE_ACCOUNT_NAME:
|
|
116
|
-
warnings_list.append(
|
|
117
|
-
"STORAGE_ACCOUNT_NAME is not set. Azure queue functionality may not work properly."
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
# Emit warnings
|
|
121
|
-
for warning in warnings_list:
|
|
122
|
-
warnings.warn(warning, UserWarning)
|
|
123
|
-
|
|
124
|
-
def get_configuration_summary(self) -> dict:
|
|
125
|
-
"""Get a summary of the current configuration (excluding sensitive data)"""
|
|
126
|
-
return {
|
|
127
|
-
"app_name": self.APP_NAME,
|
|
128
|
-
"environment": self.ENVIRONMENT,
|
|
129
|
-
"debug": self.DEBUG,
|
|
130
|
-
"database_host": self.DB_HOST,
|
|
131
|
-
"database_port": self.DB_PORT,
|
|
132
|
-
"database_name": self.DB_NAME,
|
|
133
|
-
"database_user": self.DB_USER,
|
|
134
|
-
"log_level": self.LOG_LEVEL,
|
|
135
|
-
"log_format": self.LOG_FORMAT,
|
|
136
|
-
"log_to_file": self.LOG_TO_FILE,
|
|
137
|
-
"algorithm": self.ALGORITHM,
|
|
138
|
-
"access_token_expire_minutes": self.ACCESS_TOKEN_EXPIRE_MINUTES,
|
|
139
|
-
"MAIN_TENANTS_TABLE": self.MAIN_TENANTS_TABLE,
|
|
140
|
-
"role_permissions_table": self.ROLE_PERMISSIONS_TABLE,
|
|
141
|
-
"TENANT_LOGIN_SETTINGS_TABLE": self.TENANT_LOGIN_SETTINGS_TABLE,
|
|
142
|
-
"user_groups_table": self.USER_GROUPS_TABLE,
|
|
143
|
-
"assign_roles_table": self.ASSIGN_ROLES_TABLE,
|
|
144
|
-
}
|
|
145
52
|
|
|
146
|
-
|
|
147
|
-
|
|
53
|
+
port = int(self.DB_PORT) if self.DB_PORT else 5432
|
|
54
|
+
return f"postgresql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{port}/{self.DB_NAME}"
|
|
148
55
|
|
|
149
|
-
#
|
|
150
|
-
|
|
151
|
-
db_settings.validate_configuration()
|
|
152
|
-
except Exception as e:
|
|
153
|
-
warnings.warn("Configuration validation failed: %s", str(e), UserWarning)
|
|
56
|
+
# Global settings instance
|
|
57
|
+
db_settings = Settings()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trovesuite
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: TroveSuite services package providing authentication, authorization, notifications, 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
|
|
@@ -3,19 +3,19 @@ trovesuite/auth/__init__.py,sha256=d8d5POjq9lGe7GVbc7Qm6hUpx1bgLqEVQFG1iYafdxI,3
|
|
|
3
3
|
trovesuite/auth/auth_base.py,sha256=rZHQVLeJRBQ8GClgF5UwG-er4_HXVX5-nt8o6_Z29uY,75
|
|
4
4
|
trovesuite/auth/auth_controller.py,sha256=47LsxPvE2wCqpadLPf_m68M8eR7Zu9HxfSSxZQZKQyM,412
|
|
5
5
|
trovesuite/auth/auth_read_dto.py,sha256=3gSyz6YrdXvH6yPSPnqDpOmccWnSY-oH_c7izX96_LA,578
|
|
6
|
-
trovesuite/auth/auth_service.py,sha256=
|
|
6
|
+
trovesuite/auth/auth_service.py,sha256=hz76IhwFG9T9YIivJt70Ao0ywEgHRrB0yly7Rr8uOv8,14286
|
|
7
7
|
trovesuite/auth/auth_write_dto.py,sha256=TkZw78-XNSr5Gy4sCl6DBs1CFsX2V2yMttpSQiXsDqE,231
|
|
8
8
|
trovesuite/configs/__init__.py,sha256=h1mSZOaZ3kUy1ZMO_m9O9KklsxywM0RfMVZLh9h9WvQ,328
|
|
9
9
|
trovesuite/configs/database.py,sha256=tXj-AYIUs-gjYrgioTnQafbDhsaIsgimWWLXR3ru-1A,7580
|
|
10
10
|
trovesuite/configs/logging.py,sha256=mGjR2d4urVNry9l5_aXycMMtcY2RAFIpEL35hw33KZg,9308
|
|
11
|
-
trovesuite/configs/settings.py,sha256=
|
|
11
|
+
trovesuite/configs/settings.py,sha256=yUbkiFi4QdO9JZG1RRFbP4tYurT47HmN-ohgYcs2SHM,2561
|
|
12
12
|
trovesuite/entities/__init__.py,sha256=Dbl_03Bueyh2vOP2hykd40MmNMrl5nNHSRGP-kqwwNo,160
|
|
13
13
|
trovesuite/entities/health.py,sha256=H8-XUywzvMfZy2dZwDyJGAUbmuULuZYvYIUWhiaVGdY,2729
|
|
14
14
|
trovesuite/entities/sh_response.py,sha256=1_sw3PpVaDxWsNiBU0W9YLHZgTFxEj4JJBLBfSY63Ho,1579
|
|
15
15
|
trovesuite/utils/__init__.py,sha256=3UPKTz9cluTgAM-ldNsJxsnoPTZiqacXlAmzUEHy6q8,143
|
|
16
16
|
trovesuite/utils/helper.py,sha256=lvZ1mvaqY84dkIPB5Ov0uwYDOWBziAS8twobEJZh2Ik,1002
|
|
17
|
-
trovesuite-1.0.
|
|
18
|
-
trovesuite-1.0.
|
|
19
|
-
trovesuite-1.0.
|
|
20
|
-
trovesuite-1.0.
|
|
21
|
-
trovesuite-1.0.
|
|
17
|
+
trovesuite-1.0.3.dist-info/licenses/LICENSE,sha256=EJT35ct-Q794JYPdAQy3XNczQGKkU1HzToLeK1YVw2s,1070
|
|
18
|
+
trovesuite-1.0.3.dist-info/METADATA,sha256=ytVHnT7Y477a_2vvdMx3Lb9dC-dFPwsv2ptN_0HW1uM,15925
|
|
19
|
+
trovesuite-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
20
|
+
trovesuite-1.0.3.dist-info/top_level.txt,sha256=GzKhG_-MTaxeHrIgkGkBH_nof2vroGFBrjeHKWUIwNc,11
|
|
21
|
+
trovesuite-1.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|