trovesuite 1.0.8__tar.gz → 1.0.10__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.8/src/trovesuite.egg-info → trovesuite-1.0.10}/PKG-INFO +189 -12
- {trovesuite-1.0.8 → trovesuite-1.0.10}/README.md +181 -8
- {trovesuite-1.0.8 → trovesuite-1.0.10}/pyproject.toml +13 -7
- {trovesuite-1.0.8 → trovesuite-1.0.10}/setup.py +8 -7
- trovesuite-1.0.10/src/trovesuite/__init__.py +21 -0
- trovesuite-1.0.10/src/trovesuite/auth/__init__.py +14 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/auth/auth_base.py +1 -0
- trovesuite-1.0.10/src/trovesuite/auth/auth_controller.py +11 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/auth/auth_read_dto.py +1 -1
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/auth/auth_service.py +7 -7
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/auth/auth_write_dto.py +2 -1
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/configs/database.py +130 -36
- trovesuite-1.0.10/src/trovesuite/configs/settings.py +57 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/entities/health.py +4 -4
- trovesuite-1.0.10/src/trovesuite/notification/__init__.py +14 -0
- trovesuite-1.0.10/src/trovesuite/notification/notification_base.py +13 -0
- trovesuite-1.0.10/src/trovesuite/notification/notification_controller.py +21 -0
- trovesuite-1.0.10/src/trovesuite/notification/notification_read_dto.py +21 -0
- trovesuite-1.0.10/src/trovesuite/notification/notification_service.py +73 -0
- trovesuite-1.0.10/src/trovesuite/notification/notification_write_dto.py +21 -0
- trovesuite-1.0.10/src/trovesuite/storage/__init__.py +42 -0
- trovesuite-1.0.10/src/trovesuite/storage/storage_base.py +63 -0
- trovesuite-1.0.10/src/trovesuite/storage/storage_controller.py +198 -0
- trovesuite-1.0.10/src/trovesuite/storage/storage_read_dto.py +74 -0
- trovesuite-1.0.10/src/trovesuite/storage/storage_service.py +529 -0
- trovesuite-1.0.10/src/trovesuite/storage/storage_write_dto.py +70 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10/src/trovesuite.egg-info}/PKG-INFO +189 -12
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite.egg-info/SOURCES.txt +12 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite.egg-info/requires.txt +4 -0
- trovesuite-1.0.8/src/trovesuite/__init__.py +0 -16
- trovesuite-1.0.8/src/trovesuite/auth/__init__.py +0 -16
- trovesuite-1.0.8/src/trovesuite/auth/auth_controller.py +0 -10
- trovesuite-1.0.8/src/trovesuite/configs/settings.py +0 -153
- {trovesuite-1.0.8 → trovesuite-1.0.10}/LICENSE +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/MANIFEST.in +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/requirements.txt +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/setup.cfg +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/configs/__init__.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/configs/logging.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/entities/__init__.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/entities/sh_response.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/utils/__init__.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite/utils/helper.py +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite.egg-info/dependency_links.txt +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite.egg-info/not-zip-safe +0 -0
- {trovesuite-1.0.8 → trovesuite-1.0.10}/src/trovesuite.egg-info/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trovesuite
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
5
|
-
Home-page: https://
|
|
3
|
+
Version: 1.0.10
|
|
4
|
+
Summary: TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications
|
|
5
|
+
Home-page: https://dev.azure.com/brightgclt/trovesuite/_git/packages
|
|
6
6
|
Author: Bright Debrah Owusu
|
|
7
7
|
Author-email: Bright Debrah Owusu <owusu.debrah@deladetech.com>
|
|
8
8
|
Maintainer-email: Bright Debrah Owusu <owusu.debrah@deladetech.com>
|
|
@@ -11,7 +11,7 @@ Project-URL: Homepage, https://dev.azure.com/brightgclt/trovesuite/_git/packages
|
|
|
11
11
|
Project-URL: Repository, https://dev.azure.com/brightgclt/trovesuite/_git/packages
|
|
12
12
|
Project-URL: Documentation, https://dev.azure.com/brightgclt/trovesuite/_git/packages
|
|
13
13
|
Project-URL: Bug Tracker, https://dev.azure.com/brightgclt/trovesuite/_workitems/create
|
|
14
|
-
Keywords: authentication,authorization,jwt,
|
|
14
|
+
Keywords: authentication,authorization,notifications,jwt,trovesuite,fastapi,security,tenant,permissions,enterprise,services,azure,storage,blob,cloud-storage
|
|
15
15
|
Classifier: Development Status :: 5 - Production/Stable
|
|
16
16
|
Classifier: Intended Audience :: Developers
|
|
17
17
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -34,6 +34,10 @@ 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
|
|
39
|
+
Requires-Dist: azure-storage-blob>=12.19.0
|
|
40
|
+
Requires-Dist: azure-identity>=1.15.0
|
|
37
41
|
Provides-Extra: dev
|
|
38
42
|
Requires-Dist: pytest>=8.4.2; extra == "dev"
|
|
39
43
|
Requires-Dist: pytest-asyncio>=0.21.1; extra == "dev"
|
|
@@ -49,19 +53,21 @@ Dynamic: home-page
|
|
|
49
53
|
Dynamic: license-file
|
|
50
54
|
Dynamic: requires-python
|
|
51
55
|
|
|
52
|
-
# TroveSuite
|
|
56
|
+
# TroveSuite Packages
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
TroveSuite package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications.
|
|
55
59
|
|
|
56
60
|
## Features
|
|
57
61
|
|
|
58
|
-
- **
|
|
59
|
-
- **
|
|
62
|
+
- **Authentication Services**: JWT token validation and user authentication
|
|
63
|
+
- **Authorization Services**: Multi-level authorization with tenant verification
|
|
64
|
+
- **Notification Services**: Send and manage notifications for users
|
|
60
65
|
- **Permission Checking**: Hierarchical permission system (organization > business > app > location > resource)
|
|
61
66
|
- **Database Integration**: PostgreSQL support with connection pooling
|
|
62
67
|
- **Logging**: Comprehensive logging with multiple output formats
|
|
63
68
|
- **Azure Integration**: Support for Azure Storage Queues and Managed Identity
|
|
64
69
|
- **FastAPI Ready**: Built for FastAPI applications
|
|
70
|
+
- **Extensible**: Easy to add new services and functionality
|
|
65
71
|
|
|
66
72
|
## Installation
|
|
67
73
|
|
|
@@ -115,10 +121,28 @@ poetry install --with dev
|
|
|
115
121
|
|
|
116
122
|
## Quick Start
|
|
117
123
|
|
|
124
|
+
> **✅ Package Status**: All import issues have been resolved in version 1.0.5. The package now works correctly when installed from PyPI or wheel files.
|
|
125
|
+
|
|
126
|
+
### Import Patterns
|
|
127
|
+
|
|
128
|
+
The package provides clean, simplified import patterns:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
# Import services and DTOs from main package
|
|
132
|
+
from trovesuite import AuthService, NotificationService
|
|
133
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
134
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
|
|
135
|
+
|
|
136
|
+
# Or import everything you need in one line
|
|
137
|
+
from trovesuite import AuthService, NotificationService
|
|
138
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
139
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
140
|
+
```
|
|
141
|
+
|
|
118
142
|
### Basic Usage
|
|
119
143
|
|
|
120
144
|
```python
|
|
121
|
-
from trovesuite import AuthService
|
|
145
|
+
from trovesuite import AuthService, NotificationService
|
|
122
146
|
from trovesuite.configs.settings import db_settings
|
|
123
147
|
|
|
124
148
|
# Configure your database settings
|
|
@@ -133,7 +157,7 @@ db_settings.SECRET_KEY = "your-secret-key"
|
|
|
133
157
|
auth_service = AuthService()
|
|
134
158
|
|
|
135
159
|
# Authorize a user
|
|
136
|
-
from trovesuite.auth
|
|
160
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
137
161
|
auth_data = AuthServiceWriteDto(user_id="user123", tenant="tenant456")
|
|
138
162
|
result = AuthService.authorize(auth_data)
|
|
139
163
|
|
|
@@ -145,6 +169,30 @@ else:
|
|
|
145
169
|
print(f"Authorization failed: {result.detail}")
|
|
146
170
|
```
|
|
147
171
|
|
|
172
|
+
### Notification Service Usage
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from trovesuite import NotificationService
|
|
176
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
177
|
+
|
|
178
|
+
# Send an email notification
|
|
179
|
+
email_data = NotificationEmailServiceWriteDto(
|
|
180
|
+
sender_email="your-email@gmail.com",
|
|
181
|
+
receiver_email=["recipient1@example.com", "recipient2@example.com"],
|
|
182
|
+
password="your-app-password", # Gmail app password
|
|
183
|
+
subject="Test Notification",
|
|
184
|
+
text_message="This is a plain text message",
|
|
185
|
+
html_message="<h1>This is an HTML message</h1><p>With rich formatting!</p>"
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
result = NotificationService.send_email(email_data)
|
|
189
|
+
|
|
190
|
+
if result.success:
|
|
191
|
+
print(f"Email sent successfully: {result.detail}")
|
|
192
|
+
else:
|
|
193
|
+
print(f"Email failed: {result.error}")
|
|
194
|
+
```
|
|
195
|
+
|
|
148
196
|
### JWT Token Decoding
|
|
149
197
|
|
|
150
198
|
```python
|
|
@@ -162,7 +210,7 @@ async def protected_route(token: str = Depends(oauth2_scheme)):
|
|
|
162
210
|
tenant_id = user_data["tenant_id"]
|
|
163
211
|
|
|
164
212
|
# Authorize user
|
|
165
|
-
from trovesuite.auth
|
|
213
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
166
214
|
auth_data = AuthServiceWriteDto(user_id=user_id, tenant=tenant_id)
|
|
167
215
|
auth_result = AuthService.authorize(auth_data)
|
|
168
216
|
return auth_result
|
|
@@ -391,8 +439,84 @@ Check if user has all of the required permissions.
|
|
|
391
439
|
**Returns:**
|
|
392
440
|
- `bool`: True if user has all of the required permissions
|
|
393
441
|
|
|
442
|
+
### NotificationService
|
|
443
|
+
|
|
444
|
+
#### `send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]`
|
|
445
|
+
|
|
446
|
+
Sends an email notification via Gmail SMTP. Supports both plain text and HTML email bodies.
|
|
447
|
+
|
|
448
|
+
**Parameters:**
|
|
449
|
+
- `data`: Email notification data including sender, recipients, subject, and message content
|
|
450
|
+
|
|
451
|
+
**Returns:**
|
|
452
|
+
- `Respons[NotificationEmailServiceReadDto]`: Email sending result with success status and details
|
|
453
|
+
|
|
454
|
+
**Example:**
|
|
455
|
+
```python
|
|
456
|
+
from trovesuite import NotificationService
|
|
457
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
458
|
+
|
|
459
|
+
email_data = NotificationEmailServiceWriteDto(
|
|
460
|
+
sender_email="sender@gmail.com",
|
|
461
|
+
receiver_email=["user1@example.com", "user2@example.com"],
|
|
462
|
+
password="your-gmail-app-password",
|
|
463
|
+
subject="Welcome to TroveSuite",
|
|
464
|
+
text_message="Welcome! This is a plain text message.",
|
|
465
|
+
html_message="<h1>Welcome!</h1><p>This is an <strong>HTML</strong> message.</p>"
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
result = NotificationService.send_email(email_data)
|
|
469
|
+
if result.success:
|
|
470
|
+
print("Email sent successfully!")
|
|
471
|
+
else:
|
|
472
|
+
print(f"Failed to send email: {result.error}")
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
#### `send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]`
|
|
476
|
+
|
|
477
|
+
Sends an SMS notification (currently not implemented).
|
|
478
|
+
|
|
479
|
+
**Parameters:**
|
|
480
|
+
- `data`: SMS notification data
|
|
481
|
+
|
|
482
|
+
**Returns:**
|
|
483
|
+
- `Respons[NotificationSMSServiceReadDto]`: SMS sending result
|
|
484
|
+
|
|
394
485
|
### Data Models
|
|
395
486
|
|
|
487
|
+
#### `NotificationEmailServiceWriteDto`
|
|
488
|
+
|
|
489
|
+
```python
|
|
490
|
+
class NotificationEmailServiceWriteDto(BaseModel):
|
|
491
|
+
sender_email: str
|
|
492
|
+
receiver_email: Union[str, List[str]] # Single email or list of emails
|
|
493
|
+
password: str # Gmail app password
|
|
494
|
+
subject: str
|
|
495
|
+
text_message: str
|
|
496
|
+
html_message: Optional[str] = None # Optional HTML content
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
#### `NotificationEmailServiceReadDto`
|
|
500
|
+
|
|
501
|
+
```python
|
|
502
|
+
class NotificationEmailServiceReadDto(BaseModel):
|
|
503
|
+
pass # Empty response model for email service
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
#### `NotificationSMSServiceWriteDto`
|
|
507
|
+
|
|
508
|
+
```python
|
|
509
|
+
class NotificationSMSServiceWriteDto(BaseModel):
|
|
510
|
+
pass # To be implemented for SMS functionality
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
#### `NotificationSMSServiceReadDto`
|
|
514
|
+
|
|
515
|
+
```python
|
|
516
|
+
class NotificationSMSServiceReadDto(BaseModel):
|
|
517
|
+
pass # To be implemented for SMS functionality
|
|
518
|
+
```
|
|
519
|
+
|
|
396
520
|
#### `AuthServiceReadDto`
|
|
397
521
|
|
|
398
522
|
```python
|
|
@@ -553,15 +677,65 @@ poetry install
|
|
|
553
677
|
|
|
554
678
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
555
679
|
|
|
680
|
+
## Troubleshooting
|
|
681
|
+
|
|
682
|
+
### Import Issues
|
|
683
|
+
|
|
684
|
+
If you encounter import errors, make sure you're using the correct import patterns:
|
|
685
|
+
|
|
686
|
+
```python
|
|
687
|
+
# ✅ Correct imports
|
|
688
|
+
from trovesuite import AuthService, NotificationService
|
|
689
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
690
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
691
|
+
|
|
692
|
+
# ❌ Incorrect imports (will fail)
|
|
693
|
+
from trovesuite.auth.auth_write_dto import AuthServiceWriteDto # Too specific
|
|
694
|
+
from trovesuite.notification.notification_write_dto import NotificationEmailServiceWriteDto # Too specific
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### Package Installation
|
|
698
|
+
|
|
699
|
+
If you're having issues with the package installation:
|
|
700
|
+
|
|
701
|
+
1. **Make sure you have the latest version**:
|
|
702
|
+
```bash
|
|
703
|
+
pip install --upgrade trovesuite
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
2. **Force reinstall if needed**:
|
|
707
|
+
```bash
|
|
708
|
+
pip install --force-reinstall trovesuite
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
3. **Check your Python environment**:
|
|
712
|
+
```bash
|
|
713
|
+
python -c "import trovesuite; print('Package installed successfully')"
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Common Issues
|
|
717
|
+
|
|
718
|
+
- **ImportError: No module named 'src'**: This was fixed in version 1.0.5. Update to the latest version.
|
|
719
|
+
- **AttributeError: module has no attribute 'AuthServiceWriteDto'**: Use `from trovesuite.auth import AuthServiceWriteDto` instead of importing from the main package.
|
|
720
|
+
|
|
556
721
|
## Support
|
|
557
722
|
|
|
558
723
|
For support, email brightgclt@gmail.com or create a work item in the [Azure DevOps repository](https://dev.azure.com/brightgclt/trovesuite/_workitems/create).
|
|
559
724
|
|
|
560
725
|
## Changelog
|
|
561
726
|
|
|
727
|
+
### 1.0.5
|
|
728
|
+
- Fixed all import issues across auth, notification, and entities modules
|
|
729
|
+
- Changed absolute imports (`from src.trovesuite.`) to relative imports (`from .` and `from ..`)
|
|
730
|
+
- Ensured package works correctly when installed from PyPI or wheel
|
|
731
|
+
- Added service write DTOs to module exports for easier usage
|
|
732
|
+
- Updated documentation with simplified import patterns
|
|
733
|
+
- All services and DTOs now import correctly in clean environments
|
|
734
|
+
- Package builds and installs without import errors
|
|
735
|
+
|
|
562
736
|
### 1.0.8
|
|
563
737
|
- Restructured package for direct service imports
|
|
564
|
-
- Added notification services
|
|
738
|
+
- Added comprehensive notification services with email support
|
|
565
739
|
- Excluded controllers from package build
|
|
566
740
|
- Updated import paths for better usability
|
|
567
741
|
- JWT token validation
|
|
@@ -570,3 +744,6 @@ For support, email brightgclt@gmail.com or create a work item in the [Azure DevO
|
|
|
570
744
|
- PostgreSQL database integration
|
|
571
745
|
- Comprehensive logging
|
|
572
746
|
- Azure integration support
|
|
747
|
+
- Email notification service with Gmail SMTP support
|
|
748
|
+
- Support for both plain text and HTML email content
|
|
749
|
+
- Multiple recipient support for email notifications
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
# TroveSuite
|
|
1
|
+
# TroveSuite Packages
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TroveSuite package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
7
|
+
- **Authentication Services**: JWT token validation and user authentication
|
|
8
|
+
- **Authorization Services**: Multi-level authorization with tenant verification
|
|
9
|
+
- **Notification Services**: Send and manage notifications for users
|
|
9
10
|
- **Permission Checking**: Hierarchical permission system (organization > business > app > location > resource)
|
|
10
11
|
- **Database Integration**: PostgreSQL support with connection pooling
|
|
11
12
|
- **Logging**: Comprehensive logging with multiple output formats
|
|
12
13
|
- **Azure Integration**: Support for Azure Storage Queues and Managed Identity
|
|
13
14
|
- **FastAPI Ready**: Built for FastAPI applications
|
|
15
|
+
- **Extensible**: Easy to add new services and functionality
|
|
14
16
|
|
|
15
17
|
## Installation
|
|
16
18
|
|
|
@@ -64,10 +66,28 @@ poetry install --with dev
|
|
|
64
66
|
|
|
65
67
|
## Quick Start
|
|
66
68
|
|
|
69
|
+
> **✅ Package Status**: All import issues have been resolved in version 1.0.5. The package now works correctly when installed from PyPI or wheel files.
|
|
70
|
+
|
|
71
|
+
### Import Patterns
|
|
72
|
+
|
|
73
|
+
The package provides clean, simplified import patterns:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
# Import services and DTOs from main package
|
|
77
|
+
from trovesuite import AuthService, NotificationService
|
|
78
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
79
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
|
|
80
|
+
|
|
81
|
+
# Or import everything you need in one line
|
|
82
|
+
from trovesuite import AuthService, NotificationService
|
|
83
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
84
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
85
|
+
```
|
|
86
|
+
|
|
67
87
|
### Basic Usage
|
|
68
88
|
|
|
69
89
|
```python
|
|
70
|
-
from trovesuite import AuthService
|
|
90
|
+
from trovesuite import AuthService, NotificationService
|
|
71
91
|
from trovesuite.configs.settings import db_settings
|
|
72
92
|
|
|
73
93
|
# Configure your database settings
|
|
@@ -82,7 +102,7 @@ db_settings.SECRET_KEY = "your-secret-key"
|
|
|
82
102
|
auth_service = AuthService()
|
|
83
103
|
|
|
84
104
|
# Authorize a user
|
|
85
|
-
from trovesuite.auth
|
|
105
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
86
106
|
auth_data = AuthServiceWriteDto(user_id="user123", tenant="tenant456")
|
|
87
107
|
result = AuthService.authorize(auth_data)
|
|
88
108
|
|
|
@@ -94,6 +114,30 @@ else:
|
|
|
94
114
|
print(f"Authorization failed: {result.detail}")
|
|
95
115
|
```
|
|
96
116
|
|
|
117
|
+
### Notification Service Usage
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from trovesuite import NotificationService
|
|
121
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
122
|
+
|
|
123
|
+
# Send an email notification
|
|
124
|
+
email_data = NotificationEmailServiceWriteDto(
|
|
125
|
+
sender_email="your-email@gmail.com",
|
|
126
|
+
receiver_email=["recipient1@example.com", "recipient2@example.com"],
|
|
127
|
+
password="your-app-password", # Gmail app password
|
|
128
|
+
subject="Test Notification",
|
|
129
|
+
text_message="This is a plain text message",
|
|
130
|
+
html_message="<h1>This is an HTML message</h1><p>With rich formatting!</p>"
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
result = NotificationService.send_email(email_data)
|
|
134
|
+
|
|
135
|
+
if result.success:
|
|
136
|
+
print(f"Email sent successfully: {result.detail}")
|
|
137
|
+
else:
|
|
138
|
+
print(f"Email failed: {result.error}")
|
|
139
|
+
```
|
|
140
|
+
|
|
97
141
|
### JWT Token Decoding
|
|
98
142
|
|
|
99
143
|
```python
|
|
@@ -111,7 +155,7 @@ async def protected_route(token: str = Depends(oauth2_scheme)):
|
|
|
111
155
|
tenant_id = user_data["tenant_id"]
|
|
112
156
|
|
|
113
157
|
# Authorize user
|
|
114
|
-
from trovesuite.auth
|
|
158
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
115
159
|
auth_data = AuthServiceWriteDto(user_id=user_id, tenant=tenant_id)
|
|
116
160
|
auth_result = AuthService.authorize(auth_data)
|
|
117
161
|
return auth_result
|
|
@@ -340,8 +384,84 @@ Check if user has all of the required permissions.
|
|
|
340
384
|
**Returns:**
|
|
341
385
|
- `bool`: True if user has all of the required permissions
|
|
342
386
|
|
|
387
|
+
### NotificationService
|
|
388
|
+
|
|
389
|
+
#### `send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]`
|
|
390
|
+
|
|
391
|
+
Sends an email notification via Gmail SMTP. Supports both plain text and HTML email bodies.
|
|
392
|
+
|
|
393
|
+
**Parameters:**
|
|
394
|
+
- `data`: Email notification data including sender, recipients, subject, and message content
|
|
395
|
+
|
|
396
|
+
**Returns:**
|
|
397
|
+
- `Respons[NotificationEmailServiceReadDto]`: Email sending result with success status and details
|
|
398
|
+
|
|
399
|
+
**Example:**
|
|
400
|
+
```python
|
|
401
|
+
from trovesuite import NotificationService
|
|
402
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
403
|
+
|
|
404
|
+
email_data = NotificationEmailServiceWriteDto(
|
|
405
|
+
sender_email="sender@gmail.com",
|
|
406
|
+
receiver_email=["user1@example.com", "user2@example.com"],
|
|
407
|
+
password="your-gmail-app-password",
|
|
408
|
+
subject="Welcome to TroveSuite",
|
|
409
|
+
text_message="Welcome! This is a plain text message.",
|
|
410
|
+
html_message="<h1>Welcome!</h1><p>This is an <strong>HTML</strong> message.</p>"
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
result = NotificationService.send_email(email_data)
|
|
414
|
+
if result.success:
|
|
415
|
+
print("Email sent successfully!")
|
|
416
|
+
else:
|
|
417
|
+
print(f"Failed to send email: {result.error}")
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
#### `send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]`
|
|
421
|
+
|
|
422
|
+
Sends an SMS notification (currently not implemented).
|
|
423
|
+
|
|
424
|
+
**Parameters:**
|
|
425
|
+
- `data`: SMS notification data
|
|
426
|
+
|
|
427
|
+
**Returns:**
|
|
428
|
+
- `Respons[NotificationSMSServiceReadDto]`: SMS sending result
|
|
429
|
+
|
|
343
430
|
### Data Models
|
|
344
431
|
|
|
432
|
+
#### `NotificationEmailServiceWriteDto`
|
|
433
|
+
|
|
434
|
+
```python
|
|
435
|
+
class NotificationEmailServiceWriteDto(BaseModel):
|
|
436
|
+
sender_email: str
|
|
437
|
+
receiver_email: Union[str, List[str]] # Single email or list of emails
|
|
438
|
+
password: str # Gmail app password
|
|
439
|
+
subject: str
|
|
440
|
+
text_message: str
|
|
441
|
+
html_message: Optional[str] = None # Optional HTML content
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### `NotificationEmailServiceReadDto`
|
|
445
|
+
|
|
446
|
+
```python
|
|
447
|
+
class NotificationEmailServiceReadDto(BaseModel):
|
|
448
|
+
pass # Empty response model for email service
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
#### `NotificationSMSServiceWriteDto`
|
|
452
|
+
|
|
453
|
+
```python
|
|
454
|
+
class NotificationSMSServiceWriteDto(BaseModel):
|
|
455
|
+
pass # To be implemented for SMS functionality
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
#### `NotificationSMSServiceReadDto`
|
|
459
|
+
|
|
460
|
+
```python
|
|
461
|
+
class NotificationSMSServiceReadDto(BaseModel):
|
|
462
|
+
pass # To be implemented for SMS functionality
|
|
463
|
+
```
|
|
464
|
+
|
|
345
465
|
#### `AuthServiceReadDto`
|
|
346
466
|
|
|
347
467
|
```python
|
|
@@ -502,15 +622,65 @@ poetry install
|
|
|
502
622
|
|
|
503
623
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
504
624
|
|
|
625
|
+
## Troubleshooting
|
|
626
|
+
|
|
627
|
+
### Import Issues
|
|
628
|
+
|
|
629
|
+
If you encounter import errors, make sure you're using the correct import patterns:
|
|
630
|
+
|
|
631
|
+
```python
|
|
632
|
+
# ✅ Correct imports
|
|
633
|
+
from trovesuite import AuthService, NotificationService
|
|
634
|
+
from trovesuite.auth import AuthServiceWriteDto
|
|
635
|
+
from trovesuite.notification import NotificationEmailServiceWriteDto
|
|
636
|
+
|
|
637
|
+
# ❌ Incorrect imports (will fail)
|
|
638
|
+
from trovesuite.auth.auth_write_dto import AuthServiceWriteDto # Too specific
|
|
639
|
+
from trovesuite.notification.notification_write_dto import NotificationEmailServiceWriteDto # Too specific
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Package Installation
|
|
643
|
+
|
|
644
|
+
If you're having issues with the package installation:
|
|
645
|
+
|
|
646
|
+
1. **Make sure you have the latest version**:
|
|
647
|
+
```bash
|
|
648
|
+
pip install --upgrade trovesuite
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
2. **Force reinstall if needed**:
|
|
652
|
+
```bash
|
|
653
|
+
pip install --force-reinstall trovesuite
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
3. **Check your Python environment**:
|
|
657
|
+
```bash
|
|
658
|
+
python -c "import trovesuite; print('Package installed successfully')"
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### Common Issues
|
|
662
|
+
|
|
663
|
+
- **ImportError: No module named 'src'**: This was fixed in version 1.0.5. Update to the latest version.
|
|
664
|
+
- **AttributeError: module has no attribute 'AuthServiceWriteDto'**: Use `from trovesuite.auth import AuthServiceWriteDto` instead of importing from the main package.
|
|
665
|
+
|
|
505
666
|
## Support
|
|
506
667
|
|
|
507
668
|
For support, email brightgclt@gmail.com or create a work item in the [Azure DevOps repository](https://dev.azure.com/brightgclt/trovesuite/_workitems/create).
|
|
508
669
|
|
|
509
670
|
## Changelog
|
|
510
671
|
|
|
672
|
+
### 1.0.5
|
|
673
|
+
- Fixed all import issues across auth, notification, and entities modules
|
|
674
|
+
- Changed absolute imports (`from src.trovesuite.`) to relative imports (`from .` and `from ..`)
|
|
675
|
+
- Ensured package works correctly when installed from PyPI or wheel
|
|
676
|
+
- Added service write DTOs to module exports for easier usage
|
|
677
|
+
- Updated documentation with simplified import patterns
|
|
678
|
+
- All services and DTOs now import correctly in clean environments
|
|
679
|
+
- Package builds and installs without import errors
|
|
680
|
+
|
|
511
681
|
### 1.0.8
|
|
512
682
|
- Restructured package for direct service imports
|
|
513
|
-
- Added notification services
|
|
683
|
+
- Added comprehensive notification services with email support
|
|
514
684
|
- Excluded controllers from package build
|
|
515
685
|
- Updated import paths for better usability
|
|
516
686
|
- JWT token validation
|
|
@@ -519,3 +689,6 @@ For support, email brightgclt@gmail.com or create a work item in the [Azure DevO
|
|
|
519
689
|
- PostgreSQL database integration
|
|
520
690
|
- Comprehensive logging
|
|
521
691
|
- Azure integration support
|
|
692
|
+
- Email notification service with Gmail SMTP support
|
|
693
|
+
- Support for both plain text and HTML email content
|
|
694
|
+
- Multiple recipient support for email notifications
|
|
@@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "trovesuite"
|
|
7
|
-
version = "1.0.
|
|
8
|
-
description = "
|
|
7
|
+
version = "1.0.10"
|
|
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"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
homepage = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
|
|
13
13
|
repository = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
|
|
14
14
|
documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
|
|
15
|
-
keywords = ["authentication", "authorization", "jwt", "
|
|
15
|
+
keywords = ["authentication", "authorization", "notifications", "jwt", "trovesuite", "fastapi", "security", "tenant", "permissions", "enterprise", "services", "azure", "storage", "blob", "cloud-storage"]
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Development Status :: 5 - Production/Stable",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
@@ -36,6 +36,8 @@ python-dotenv = "^1.0.0"
|
|
|
36
36
|
python-multipart = "^0.0.6"
|
|
37
37
|
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
|
38
38
|
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
|
39
|
+
azure-storage-blob = "^12.19.0"
|
|
40
|
+
azure-identity = "^1.15.0"
|
|
39
41
|
|
|
40
42
|
[tool.poetry.group.dev.dependencies]
|
|
41
43
|
pytest = "^8.4.2"
|
|
@@ -56,8 +58,8 @@ Documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
|
|
|
56
58
|
|
|
57
59
|
[project]
|
|
58
60
|
name = "trovesuite"
|
|
59
|
-
version = "1.0.
|
|
60
|
-
description = "
|
|
61
|
+
version = "1.0.10"
|
|
62
|
+
description = "TroveSuite services package providing authentication, authorization, notifications, Azure Storage, and other enterprise services for TroveSuite applications"
|
|
61
63
|
readme = "README.md"
|
|
62
64
|
license = {text = "MIT"}
|
|
63
65
|
authors = [
|
|
@@ -66,7 +68,7 @@ authors = [
|
|
|
66
68
|
maintainers = [
|
|
67
69
|
{name = "Bright Debrah Owusu", email = "owusu.debrah@deladetech.com"}
|
|
68
70
|
]
|
|
69
|
-
keywords = ["authentication", "authorization", "jwt", "
|
|
71
|
+
keywords = ["authentication", "authorization", "notifications", "jwt", "trovesuite", "fastapi", "security", "tenant", "permissions", "enterprise", "services", "azure", "storage", "blob", "cloud-storage"]
|
|
70
72
|
classifiers = [
|
|
71
73
|
"Development Status :: 5 - Production/Stable",
|
|
72
74
|
"Intended Audience :: Developers",
|
|
@@ -89,7 +91,11 @@ dependencies = [
|
|
|
89
91
|
"python-multipart>=0.0.6",
|
|
90
92
|
"python-jose[cryptography]>=3.3.0",
|
|
91
93
|
"passlib[bcrypt]>=1.7.4",
|
|
92
|
-
"passlib[argon2] (>=1.7.4,<2.0.0)"
|
|
94
|
+
"passlib[argon2] (>=1.7.4,<2.0.0)",
|
|
95
|
+
"uvicorn (>=0.38.0,<0.39.0)",
|
|
96
|
+
"pyjwt (>=2.10.1,<3.0.0)",
|
|
97
|
+
"azure-storage-blob>=12.19.0",
|
|
98
|
+
"azure-identity>=1.15.0"
|
|
93
99
|
|
|
94
100
|
]
|
|
95
101
|
|
|
@@ -14,19 +14,20 @@ with open("pyproject.toml", "r", encoding="utf-8") as fh:
|
|
|
14
14
|
content = fh.read()
|
|
15
15
|
|
|
16
16
|
setup(
|
|
17
|
-
name="trovesuite
|
|
18
|
-
version="1.0.
|
|
17
|
+
name="trovesuite",
|
|
18
|
+
version="1.0.10",
|
|
19
19
|
author="Bright Debrah Owusu",
|
|
20
20
|
author_email="owusu.debrah@deladetech.com",
|
|
21
|
-
description="
|
|
21
|
+
description="TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications",
|
|
22
22
|
long_description=long_description,
|
|
23
23
|
long_description_content_type="text/markdown",
|
|
24
|
-
url="https://
|
|
24
|
+
url="https://dev.azure.com/brightgclt/trovesuite/_git/packages",
|
|
25
25
|
project_urls={
|
|
26
|
-
"Bug Tracker": "https://
|
|
27
|
-
"Documentation": "https://
|
|
26
|
+
"Bug Tracker": "https://dev.azure.com/brightgclt/trovesuite/_workitems/create",
|
|
27
|
+
"Documentation": "https://dev.azure.com/brightgclt/trovesuite/_git/packages",
|
|
28
28
|
},
|
|
29
|
-
packages=find_packages(include=['
|
|
29
|
+
packages=find_packages(where="src", include=['trovesuite*']),
|
|
30
|
+
package_dir={"": "src"},
|
|
30
31
|
classifiers=[
|
|
31
32
|
"Development Status :: 5 - Production/Stable",
|
|
32
33
|
"Intended Audience :: Developers",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TroveSuite Package
|
|
3
|
+
|
|
4
|
+
A comprehensive authentication, authorization, notification, and storage service for ERP systems.
|
|
5
|
+
Provides JWT token validation, user authorization, permission checking, notification capabilities,
|
|
6
|
+
and Azure Storage blob management.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .auth import AuthService
|
|
10
|
+
from .notification import NotificationService
|
|
11
|
+
from .storage import StorageService
|
|
12
|
+
|
|
13
|
+
__version__ = "1.0.7"
|
|
14
|
+
__author__ = "Bright Debrah Owusu"
|
|
15
|
+
__email__ = "owusu.debrah@deladetech.com"
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"AuthService",
|
|
19
|
+
"NotificationService",
|
|
20
|
+
"StorageService"
|
|
21
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TroveSuite Auth Module
|
|
3
|
+
|
|
4
|
+
Authentication and authorization services for ERP systems.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .auth_service import AuthService
|
|
8
|
+
from .auth_write_dto import AuthServiceWriteDto
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"AuthService",
|
|
12
|
+
"AuthServiceWriteDto"
|
|
13
|
+
]
|
|
14
|
+
|