trovesuite 1.0.3__tar.gz → 1.0.4__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.
- {trovesuite-1.0.3/src/trovesuite.egg-info → trovesuite-1.0.4}/PKG-INFO +3 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/pyproject.toml +5 -3
- {trovesuite-1.0.3 → trovesuite-1.0.4}/setup.py +1 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/auth_controller.py +2 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/auth_read_dto.py +0 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/auth_service.py +3 -3
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/auth_write_dto.py +1 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/configs/database.py +29 -17
- {trovesuite-1.0.3 → trovesuite-1.0.4/src/trovesuite.egg-info}/PKG-INFO +3 -1
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite.egg-info/requires.txt +2 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/LICENSE +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/MANIFEST.in +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/README.md +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/requirements.txt +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/setup.cfg +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/__init__.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/__init__.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/auth/auth_base.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/configs/__init__.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/configs/logging.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/configs/settings.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/entities/__init__.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/entities/health.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/entities/sh_response.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/utils/__init__.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite/utils/helper.py +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite.egg-info/SOURCES.txt +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite.egg-info/dependency_links.txt +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/src/trovesuite.egg-info/not-zip-safe +0 -0
- {trovesuite-1.0.3 → trovesuite-1.0.4}/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.
|
|
3
|
+
Version: 1.0.4
|
|
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
|
|
@@ -34,6 +34,8 @@ Requires-Dist: python-multipart>=0.0.6
|
|
|
34
34
|
Requires-Dist: python-jose[cryptography]>=3.3.0
|
|
35
35
|
Requires-Dist: passlib[bcrypt]>=1.7.4
|
|
36
36
|
Requires-Dist: passlib[argon2]<2.0.0,>=1.7.4
|
|
37
|
+
Requires-Dist: uvicorn<0.39.0,>=0.38.0
|
|
38
|
+
Requires-Dist: pyjwt<3.0.0,>=2.10.1
|
|
37
39
|
Provides-Extra: dev
|
|
38
40
|
Requires-Dist: pytest>=8.4.2; extra == "dev"
|
|
39
41
|
Requires-Dist: pytest-asyncio>=0.21.1; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "trovesuite"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.4"
|
|
8
8
|
description = "TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications"
|
|
9
9
|
authors = ["brightgclt <brightgclt@gmail.com>"]
|
|
10
10
|
license = "MIT"
|
|
@@ -56,7 +56,7 @@ Documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
|
|
|
56
56
|
|
|
57
57
|
[project]
|
|
58
58
|
name = "trovesuite"
|
|
59
|
-
version = "1.0.
|
|
59
|
+
version = "1.0.4"
|
|
60
60
|
description = "TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications"
|
|
61
61
|
readme = "README.md"
|
|
62
62
|
license = {text = "MIT"}
|
|
@@ -89,7 +89,9 @@ dependencies = [
|
|
|
89
89
|
"python-multipart>=0.0.6",
|
|
90
90
|
"python-jose[cryptography]>=3.3.0",
|
|
91
91
|
"passlib[bcrypt]>=1.7.4",
|
|
92
|
-
"passlib[argon2] (>=1.7.4,<2.0.0)"
|
|
92
|
+
"passlib[argon2] (>=1.7.4,<2.0.0)",
|
|
93
|
+
"uvicorn (>=0.38.0,<0.39.0)",
|
|
94
|
+
"pyjwt (>=2.10.1,<3.0.0)"
|
|
93
95
|
|
|
94
96
|
]
|
|
95
97
|
|
|
@@ -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.
|
|
18
|
+
version="1.0.4",
|
|
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",
|
|
@@ -2,9 +2,10 @@ from fastapi import APIRouter
|
|
|
2
2
|
from src.trovesuite.auth.auth_write_dto import AuthControllerWriteDto
|
|
3
3
|
from src.trovesuite.auth.auth_read_dto import AuthControllerReadDto
|
|
4
4
|
from src.trovesuite.auth.auth_service import AuthService
|
|
5
|
+
from src.trovesuite.entities.sh_response import Respons
|
|
5
6
|
|
|
6
7
|
auth_router = APIRouter()
|
|
7
8
|
|
|
8
|
-
@auth_router.post("/auth", response_model=AuthControllerReadDto)
|
|
9
|
+
@auth_router.post("/auth", response_model=Respons[AuthControllerReadDto])
|
|
9
10
|
async def authorize(data: AuthControllerWriteDto):
|
|
10
11
|
return AuthService.authorize(data=data)
|
|
@@ -11,7 +11,6 @@ class AuthControllerReadDto(BaseModel):
|
|
|
11
11
|
role_id: Optional[str] = None
|
|
12
12
|
tenant_id: Optional[str] = None
|
|
13
13
|
permissions: Optional[List[str]] = None
|
|
14
|
-
shared_resource_id: Optional[str] = None
|
|
15
14
|
resource_id: Optional[str] = None
|
|
16
15
|
|
|
17
16
|
class AuthServiceReadDto(AuthControllerReadDto):
|
|
@@ -48,7 +48,7 @@ class AuthService:
|
|
|
48
48
|
|
|
49
49
|
user_id: str = data.user_id
|
|
50
50
|
tenant_id: str = data.tenant_id
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
"""Check if a user is authorized based on login settings and roles"""
|
|
53
53
|
# Input validation
|
|
54
54
|
if not user_id or not isinstance(user_id, str):
|
|
@@ -68,14 +68,14 @@ class AuthService:
|
|
|
68
68
|
status_code=400,
|
|
69
69
|
error="INVALID_TENANT_ID"
|
|
70
70
|
)
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
try:
|
|
73
73
|
|
|
74
74
|
is_tenant_verified = DatabaseManager.execute_query(
|
|
75
75
|
f"SELECT is_verified FROM {db_settings.MAIN_TENANTS_TABLE} WHERE delete_status = 'NOT_DELETED' AND id = %s",
|
|
76
76
|
(tenant_id,),
|
|
77
77
|
)
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
if not is_tenant_verified or len(is_tenant_verified) == 0:
|
|
80
80
|
logger.warning("Login failed - tenant not found: %s", tenant_id)
|
|
81
81
|
return Respons[AuthServiceReadDto](
|
|
@@ -13,7 +13,6 @@ logger = get_logger("database")
|
|
|
13
13
|
|
|
14
14
|
# Database connection pool
|
|
15
15
|
_connection_pool: Optional[psycopg2.pool.ThreadedConnectionPool] = None
|
|
16
|
-
_sqlmodel_engine = None
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class DatabaseConfig:
|
|
@@ -21,16 +20,20 @@ class DatabaseConfig:
|
|
|
21
20
|
|
|
22
21
|
def __init__(self):
|
|
23
22
|
self.settings = db_settings
|
|
23
|
+
self.database_url = self.settings.database_url
|
|
24
24
|
self.pool_size = 5
|
|
25
25
|
self.max_overflow = 10
|
|
26
|
-
|
|
27
|
-
@property
|
|
28
|
-
def database_url(self):
|
|
29
|
-
"""Get database URL (lazy evaluation)"""
|
|
30
|
-
return self.settings.database_url
|
|
31
26
|
|
|
32
27
|
def get_connection_params(self) -> dict:
|
|
33
28
|
"""Get database connection parameters"""
|
|
29
|
+
if self.settings.DATABASE_URL:
|
|
30
|
+
# Use full DATABASE_URL if available
|
|
31
|
+
return {
|
|
32
|
+
"dsn": self.settings.DATABASE_URL,
|
|
33
|
+
"cursor_factory": RealDictCursor
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# fallback to individual DB_* variables
|
|
34
37
|
return {
|
|
35
38
|
"host": self.settings.DB_HOST,
|
|
36
39
|
"port": self.settings.DB_PORT,
|
|
@@ -98,18 +101,19 @@ def get_connection_pool() -> psycopg2.pool.ThreadedConnectionPool:
|
|
|
98
101
|
"""Get the database connection pool"""
|
|
99
102
|
global _connection_pool
|
|
100
103
|
if _connection_pool is None:
|
|
101
|
-
|
|
104
|
+
error_msg = (
|
|
105
|
+
"Database not initialized. This usually means:\n"
|
|
106
|
+
"1. Missing or incorrect .env file in app/ directory\n"
|
|
107
|
+
"2. Database credentials are wrong\n"
|
|
108
|
+
"3. Database container is not running\n"
|
|
109
|
+
"4. Database initialization failed during startup\n"
|
|
110
|
+
"Please check the startup logs for more details."
|
|
111
|
+
)
|
|
112
|
+
logger.error(error_msg)
|
|
113
|
+
raise Exception(error_msg)
|
|
102
114
|
return _connection_pool
|
|
103
115
|
|
|
104
116
|
|
|
105
|
-
def get_sqlmodel_engine():
|
|
106
|
-
"""Get the SQLModel engine"""
|
|
107
|
-
global _sqlmodel_engine
|
|
108
|
-
if _sqlmodel_engine is None:
|
|
109
|
-
raise Exception("Database not initialized. Call initialize_database() first.")
|
|
110
|
-
return _sqlmodel_engine
|
|
111
|
-
|
|
112
|
-
|
|
113
117
|
@contextmanager
|
|
114
118
|
def get_db_connection():
|
|
115
119
|
"""Get a database connection from the pool (context manager)"""
|
|
@@ -217,5 +221,13 @@ class DatabaseManager:
|
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
|
|
220
|
-
# Database initialization
|
|
221
|
-
|
|
224
|
+
# Database initialization on module import
|
|
225
|
+
try:
|
|
226
|
+
initialize_database()
|
|
227
|
+
except Exception as e:
|
|
228
|
+
logger.error(f"Failed to initialize database on startup: {str(e)}")
|
|
229
|
+
logger.error("⚠️ CRITICAL: Application started without database connection!")
|
|
230
|
+
logger.error("⚠️ Please check your .env file and database configuration")
|
|
231
|
+
logger.error("⚠️ The application will not function properly without a database connection")
|
|
232
|
+
# Don't raise here to allow the app to start even if DB is unavailable
|
|
233
|
+
# But log it clearly so it's obvious what's wrong
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trovesuite
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
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
|
|
@@ -34,6 +34,8 @@ Requires-Dist: python-multipart>=0.0.6
|
|
|
34
34
|
Requires-Dist: python-jose[cryptography]>=3.3.0
|
|
35
35
|
Requires-Dist: passlib[bcrypt]>=1.7.4
|
|
36
36
|
Requires-Dist: passlib[argon2]<2.0.0,>=1.7.4
|
|
37
|
+
Requires-Dist: uvicorn<0.39.0,>=0.38.0
|
|
38
|
+
Requires-Dist: pyjwt<3.0.0,>=2.10.1
|
|
37
39
|
Provides-Extra: dev
|
|
38
40
|
Requires-Dist: pytest>=8.4.2; extra == "dev"
|
|
39
41
|
Requires-Dist: pytest-asyncio>=0.21.1; extra == "dev"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|