miso-client 0.1.0__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.

Potentially problematic release.


This version of miso-client might be problematic. Click here for more details.

Files changed (35) hide show
  1. miso_client-0.1.0/CHANGELOG.md +199 -0
  2. miso_client-0.1.0/LICENSE +21 -0
  3. miso_client-0.1.0/MANIFEST.in +12 -0
  4. miso_client-0.1.0/PKG-INFO +551 -0
  5. miso_client-0.1.0/README.md +502 -0
  6. miso_client-0.1.0/miso_client/__init__.py +489 -0
  7. miso_client-0.1.0/miso_client/errors.py +44 -0
  8. miso_client-0.1.0/miso_client/models/__init__.py +1 -0
  9. miso_client-0.1.0/miso_client/models/config.py +174 -0
  10. miso_client-0.1.0/miso_client/py.typed +0 -0
  11. miso_client-0.1.0/miso_client/services/__init__.py +20 -0
  12. miso_client-0.1.0/miso_client/services/auth.py +160 -0
  13. miso_client-0.1.0/miso_client/services/cache.py +204 -0
  14. miso_client-0.1.0/miso_client/services/encryption.py +93 -0
  15. miso_client-0.1.0/miso_client/services/logger.py +457 -0
  16. miso_client-0.1.0/miso_client/services/permission.py +208 -0
  17. miso_client-0.1.0/miso_client/services/redis.py +179 -0
  18. miso_client-0.1.0/miso_client/services/role.py +180 -0
  19. miso_client-0.1.0/miso_client/utils/__init__.py +15 -0
  20. miso_client-0.1.0/miso_client/utils/config_loader.py +87 -0
  21. miso_client-0.1.0/miso_client/utils/data_masker.py +156 -0
  22. miso_client-0.1.0/miso_client/utils/http_client.py +377 -0
  23. miso_client-0.1.0/miso_client/utils/jwt_tools.py +78 -0
  24. miso_client-0.1.0/miso_client.egg-info/PKG-INFO +551 -0
  25. miso_client-0.1.0/miso_client.egg-info/SOURCES.txt +33 -0
  26. miso_client-0.1.0/miso_client.egg-info/dependency_links.txt +1 -0
  27. miso_client-0.1.0/miso_client.egg-info/not-zip-safe +1 -0
  28. miso_client-0.1.0/miso_client.egg-info/requires.txt +16 -0
  29. miso_client-0.1.0/miso_client.egg-info/top_level.txt +1 -0
  30. miso_client-0.1.0/pyproject.toml +99 -0
  31. miso_client-0.1.0/pytest.ini +11 -0
  32. miso_client-0.1.0/requirements-test.txt +7 -0
  33. miso_client-0.1.0/requirements.txt +8 -0
  34. miso_client-0.1.0/setup.cfg +4 -0
  35. miso_client-0.1.0/setup.py +64 -0
@@ -0,0 +1,199 @@
1
+ # Changelog
2
+
3
+ All notable changes to the MisoClient SDK will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.0] - 2025-10-30
9
+
10
+ ### Added
11
+
12
+ - **Automatic Client Token Management in HttpClient**: Client tokens are now automatically fetched, cached, and refreshed by the HttpClient
13
+ - Proactive token refresh when < 60 seconds until expiry (30 second buffer before actual expiration)
14
+ - Automatic `x-client-token` header injection for all requests
15
+ - Concurrent token fetch prevention using async locks
16
+ - Automatic token clearing on 401 responses to force refresh
17
+
18
+ - **New Data Models**:
19
+ - `ClientTokenResponse`: Response model for client token requests with expiration tracking
20
+ - `PerformanceMetrics`: Performance metrics model for logging (start time, end time, duration, memory usage)
21
+ - `ClientLoggingOptions`: Advanced logging options with JWT context extraction, correlation IDs, data masking, and performance metrics support
22
+
23
+ - **RedisConfig Enhancement**:
24
+ - Added `db` field to specify Redis database number (default: 0)
25
+ - Supports multi-database Redis deployments
26
+
27
+ ### Changed
28
+
29
+ - **Module Structure**: Moved type definitions from `miso_client.types.config` to `miso_client.models.config` for better organization
30
+ - All imports now use `from miso_client.models.config import ...`
31
+ - Previous compatibility layer (`types_backup_test`) removed as no longer needed
32
+
33
+ - **HttpClient Improvements**:
34
+ - Client token management is now fully automatic - no manual token handling required
35
+ - Better error handling with automatic token refresh on authentication failures
36
+ - All HTTP methods (GET, POST, PUT, DELETE) now automatically include client token header
37
+
38
+ ### Technical Improvements
39
+
40
+ - Improved token expiration handling with proactive refresh mechanism
41
+ - Reduced API calls through intelligent token caching
42
+ - Better concurrency handling with async locks for token operations
43
+ - Enhanced error recovery with automatic token clearing on 401 responses
44
+
45
+ ---
46
+
47
+ ## [1.0.0] - 2025-10-01
48
+
49
+ ### Added
50
+
51
+ - **Initial Release**: Complete MisoClient SDK implementation
52
+ - **Authentication**: JWT token validation and user management
53
+ - **Authorization**: Role-based access control (RBAC) with Redis caching
54
+ - **Permissions**: Fine-grained permission management with caching
55
+ - **Logging**: Structured logging with Redis queuing and HTTP fallback
56
+ - **Redis Integration**: Optional Redis caching for improved performance
57
+ - **Async Support**: Full async/await support for modern Python applications
58
+ - **Type Safety**: Complete type hints and Pydantic models
59
+ - **Graceful Degradation**: Works with or without Redis
60
+ - **Comprehensive Documentation**: Complete API reference and integration guides
61
+ - **Unit Tests**: Full test coverage mirroring TypeScript implementation
62
+ - **Package Distribution**: Ready for PyPI distribution with setup.py and pyproject.toml
63
+
64
+ ### Features
65
+
66
+ #### Core Client
67
+ - `MisoClient` main class with initialization and lifecycle management
68
+ - Configuration management with `MisoClientConfig` and `RedisConfig`
69
+ - Connection state tracking and graceful fallback
70
+
71
+ #### Authentication Service
72
+ - Token validation with controller integration
73
+ - User information retrieval
74
+ - Login URL generation for web applications
75
+ - Logout functionality
76
+
77
+ #### Role Service
78
+ - Role retrieval with Redis caching (15-minute TTL)
79
+ - Role checking methods: `has_role`, `has_any_role`, `has_all_roles`
80
+ - Role refresh functionality to bypass cache
81
+ - Cache key management with user/environment/application scoping
82
+
83
+ #### Permission Service
84
+ - Permission retrieval with Redis caching (15-minute TTL)
85
+ - Permission checking methods: `has_permission`, `has_any_permission`, `has_all_permissions`
86
+ - Permission refresh functionality to bypass cache
87
+ - Cache clearing functionality
88
+ - Cache key management with user/environment/application scoping
89
+
90
+ #### Logger Service
91
+ - Structured logging with multiple levels: `info`, `error`, `audit`, `debug`
92
+ - Redis queue integration for log batching
93
+ - HTTP fallback when Redis is unavailable
94
+ - Context-aware logging with metadata support
95
+
96
+ #### HTTP Client
97
+ - Async HTTP client wrapper using httpx
98
+ - Automatic header injection (X-Environment, X-Application)
99
+ - Authenticated request support with Bearer token
100
+ - Error handling and status code management
101
+
102
+ #### Redis Service
103
+ - Async Redis integration using redis.asyncio
104
+ - Graceful degradation when Redis is unavailable
105
+ - Connection state tracking
106
+ - Key prefix support for multi-tenant environments
107
+
108
+ ### Data Models
109
+
110
+ - `UserInfo`: User information from token validation
111
+ - `AuthResult`: Authentication result structure
112
+ - `LogEntry`: Structured log entry format
113
+ - `RoleResult`: Role query result
114
+ - `PermissionResult`: Permission query result
115
+ - `MisoClientConfig`: Main client configuration
116
+ - `RedisConfig`: Redis connection configuration
117
+
118
+ ### Integration Examples
119
+
120
+ - **FastAPI**: Complete integration with dependencies and middleware
121
+ - **Django**: Middleware, decorators, and view integration
122
+ - **Flask**: Decorator-based authentication and authorization
123
+ - **Custom Applications**: Dependency injection and service patterns
124
+
125
+ ### Documentation
126
+
127
+ - **README.md**: Comprehensive SDK documentation with quick start guide
128
+ - **API Reference**: Detailed method signatures and parameter descriptions
129
+ - **Integration Guide**: Framework-specific integration examples
130
+ - **Changelog**: Version history and feature tracking
131
+
132
+ ### Testing
133
+
134
+ - **Unit Tests**: Comprehensive test coverage for all services
135
+ - **Mock Support**: Mock implementations for testing
136
+ - **Error Handling**: Test coverage for error scenarios and edge cases
137
+ - **Performance Tests**: Concurrent operation testing
138
+
139
+ ### Package Management
140
+
141
+ - **setup.py**: Traditional Python package configuration
142
+ - **pyproject.toml**: Modern Python packaging (PEP 518)
143
+ - **Dependencies**: httpx, redis[hiredis], pydantic, pydantic-settings, structlog
144
+ - **Development Dependencies**: pytest, black, isort, mypy
145
+ - **Python Support**: Python 3.8+ compatibility
146
+
147
+ ### Security
148
+
149
+ - **Token Handling**: Secure JWT token processing
150
+ - **Redis Security**: Password and key prefix support
151
+ - **Logging Security**: Careful handling of sensitive information
152
+ - **Error Handling**: Graceful error handling without information leakage
153
+
154
+ ### Performance
155
+
156
+ - **Caching**: Redis-based caching for roles and permissions
157
+ - **Connection Pooling**: Efficient HTTP and Redis connection management
158
+ - **Async Operations**: Non-blocking async/await throughout
159
+ - **Batch Operations**: Support for concurrent operations
160
+
161
+ ### Compatibility
162
+
163
+ - **Python Versions**: 3.8, 3.9, 3.10, 3.11, 3.12
164
+ - **Framework Support**: FastAPI, Django, Flask, and custom applications
165
+ - **Redis Versions**: Compatible with Redis 5.0+
166
+ - **HTTP Clients**: Uses httpx for modern async HTTP support
167
+
168
+ ### Migration
169
+
170
+ - **From Keycloak**: Seamless migration from direct Keycloak integration
171
+ - **Backward Compatibility**: Maintains existing API patterns
172
+ - **Configuration**: Simple configuration migration
173
+ - **Testing**: Comprehensive migration testing support
174
+
175
+ ---
176
+
177
+ ## Future Releases
178
+
179
+ ### Planned Features
180
+
181
+ - **WebSocket Support**: Real-time authentication updates
182
+ - **Metrics Integration**: Prometheus and OpenTelemetry support
183
+ - **Advanced Caching**: Cache invalidation strategies
184
+ - **Multi-Controller Support**: Load balancing across multiple controllers
185
+ - **SDK Extensions**: Framework-specific SDK extensions
186
+
187
+ ### Roadmap
188
+
189
+ - **v1.1.0**: WebSocket support and real-time updates
190
+ - **v1.2.0**: Advanced metrics and monitoring
191
+ - **v2.0.0**: Multi-controller support and load balancing
192
+ - **v2.1.0**: Framework-specific SDK extensions
193
+
194
+ ---
195
+
196
+ For more information about the MisoClient SDK, visit:
197
+ - [Documentation](https://docs.aifabrix.ai/miso-client-python)
198
+ - [GitHub Repository](https://github.com/aifabrix/miso-client-python)
199
+ - [Issue Tracker](https://github.com/aifabrix/miso-client-python/issues)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 eSystems Nordic Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,12 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include requirements.txt
5
+ include requirements-test.txt
6
+ include pytest.ini
7
+ # recursive-include docs *.md # docs directory is empty
8
+ recursive-include miso_client *.py
9
+ include miso_client/py.typed
10
+ recursive-exclude * __pycache__
11
+ recursive-exclude * *.py[co]
12
+