miso-client 1.8.1__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.
- miso_client-1.8.1/CHANGELOG.md +514 -0
- miso_client-1.8.1/LICENSE +21 -0
- miso_client-1.8.1/MANIFEST.in +12 -0
- miso_client-1.8.1/PKG-INFO +932 -0
- miso_client-1.8.1/README.md +883 -0
- miso_client-1.8.1/miso_client/__init__.py +547 -0
- miso_client-1.8.1/miso_client/errors.py +70 -0
- miso_client-1.8.1/miso_client/models/__init__.py +5 -0
- miso_client-1.8.1/miso_client/models/config.py +159 -0
- miso_client-1.8.1/miso_client/models/error_response.py +41 -0
- miso_client-1.8.1/miso_client/models/filter.py +140 -0
- miso_client-1.8.1/miso_client/models/pagination.py +45 -0
- miso_client-1.8.1/miso_client/models/sort.py +25 -0
- miso_client-1.8.1/miso_client/py.typed +0 -0
- miso_client-1.8.1/miso_client/services/__init__.py +20 -0
- miso_client-1.8.1/miso_client/services/auth.py +175 -0
- miso_client-1.8.1/miso_client/services/cache.py +205 -0
- miso_client-1.8.1/miso_client/services/encryption.py +94 -0
- miso_client-1.8.1/miso_client/services/logger.py +472 -0
- miso_client-1.8.1/miso_client/services/permission.py +202 -0
- miso_client-1.8.1/miso_client/services/redis.py +184 -0
- miso_client-1.8.1/miso_client/services/role.py +172 -0
- miso_client-1.8.1/miso_client/utils/__init__.py +15 -0
- miso_client-1.8.1/miso_client/utils/config_loader.py +95 -0
- miso_client-1.8.1/miso_client/utils/data_masker.py +227 -0
- miso_client-1.8.1/miso_client/utils/error_utils.py +100 -0
- miso_client-1.8.1/miso_client/utils/filter.py +256 -0
- miso_client-1.8.1/miso_client/utils/http_client.py +526 -0
- miso_client-1.8.1/miso_client/utils/http_client_logging.py +456 -0
- miso_client-1.8.1/miso_client/utils/internal_http_client.py +471 -0
- miso_client-1.8.1/miso_client/utils/jwt_tools.py +177 -0
- miso_client-1.8.1/miso_client/utils/pagination.py +157 -0
- miso_client-1.8.1/miso_client/utils/sensitive_fields_loader.py +116 -0
- miso_client-1.8.1/miso_client/utils/sort.py +116 -0
- miso_client-1.8.1/miso_client.egg-info/PKG-INFO +932 -0
- miso_client-1.8.1/miso_client.egg-info/SOURCES.txt +44 -0
- miso_client-1.8.1/miso_client.egg-info/dependency_links.txt +1 -0
- miso_client-1.8.1/miso_client.egg-info/not-zip-safe +1 -0
- miso_client-1.8.1/miso_client.egg-info/requires.txt +16 -0
- miso_client-1.8.1/miso_client.egg-info/top_level.txt +1 -0
- miso_client-1.8.1/pyproject.toml +99 -0
- miso_client-1.8.1/pytest.ini +11 -0
- miso_client-1.8.1/requirements-test.txt +7 -0
- miso_client-1.8.1/requirements.txt +8 -0
- miso_client-1.8.1/setup.cfg +4 -0
- miso_client-1.8.1/setup.py +64 -0
|
@@ -0,0 +1,514 @@
|
|
|
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.8.1] - 2025-11-02
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Breaking Change: All Outgoing Data Now Uses camelCase Naming Convention**
|
|
13
|
+
- All Pydantic model fields sent to API now use camelCase (e.g., `pageSize`, `totalItems`, `currentPage`, `userId`, `statusCode`, `correlationId`)
|
|
14
|
+
- All JSON request bodies now use camelCase field names
|
|
15
|
+
- All query parameters now use camelCase (e.g., `pageSize` instead of `page_size`)
|
|
16
|
+
- All response data from API is expected in camelCase format
|
|
17
|
+
- Python code conventions remain snake_case (functions, methods, variables, parameters)
|
|
18
|
+
|
|
19
|
+
- **Model Field Updates**:
|
|
20
|
+
- `FilterQuery`: Changed `page_size` → `pageSize`
|
|
21
|
+
- `Meta`: Changed `total_items` → `totalItems`, `current_page` → `currentPage`, `page_size` → `pageSize`
|
|
22
|
+
- `ErrorResponse`: Changed `request_key` → `correlationId`, removed `status_code` alias (now only `statusCode`)
|
|
23
|
+
- `LogEntry`: Removed all aliases (already camelCase): `applicationId`, `userId`, `correlationId`, `requestId`, `sessionId`, `stackTrace`, `ipAddress`, `userAgent`
|
|
24
|
+
- `UserInfo`: Removed `first_name`/`last_name` aliases (now only `firstName`/`lastName`)
|
|
25
|
+
- `RoleResult`: Removed `user_id` alias (now only `userId`)
|
|
26
|
+
- `PermissionResult`: Removed `user_id` alias (now only `userId`)
|
|
27
|
+
- `ClientTokenResponse`: Removed `expires_in`/`expires_at` aliases (now only `expiresIn`/`expiresAt`)
|
|
28
|
+
- `PerformanceMetrics`: Removed `start_time`/`end_time`/`memory_usage` aliases (now only `startTime`/`endTime`/`memoryUsage`)
|
|
29
|
+
- `ClientLoggingOptions`: Removed all aliases (already camelCase): `applicationId`, `userId`, `correlationId`, `requestId`, `sessionId`, `maskSensitiveData`, `performanceMetrics`
|
|
30
|
+
|
|
31
|
+
- **Query Parameter Updates**:
|
|
32
|
+
- `build_query_string()`: Now generates `pageSize` instead of `page_size` in query strings
|
|
33
|
+
- `_add_pagination_params()`: Now adds `pageSize` instead of `page_size` to request parameters
|
|
34
|
+
- `parse_pagination_params()`: Still accepts both `pageSize` and `page_size` for backward compatibility (can parse either format)
|
|
35
|
+
|
|
36
|
+
- **Utility Function Updates**:
|
|
37
|
+
- `create_meta_object()`: Now creates `Meta` objects with camelCase field names (`totalItems`, `currentPage`, `pageSize`)
|
|
38
|
+
- `error_utils.py`: Updated to handle only camelCase error responses (removed snake_case handling)
|
|
39
|
+
- `transform_error_to_snake_case()`: Function name retained for backward compatibility, but now expects camelCase data
|
|
40
|
+
- `handle_api_error_snake_case()`: Function name retained for backward compatibility, but now expects camelCase data
|
|
41
|
+
|
|
42
|
+
- **Backward Compatibility Removed**:
|
|
43
|
+
- Removed all `populate_by_name` configs from Pydantic models
|
|
44
|
+
- Removed all snake_case property accessors (e.g., `status_code`, `totalItems`, `currentPage`, `pageSize` properties)
|
|
45
|
+
- Removed all Field aliases that supported snake_case input
|
|
46
|
+
|
|
47
|
+
### Documentation
|
|
48
|
+
|
|
49
|
+
- Updated `.cursorrules` with "API Data Conventions (camelCase)" section documenting camelCase requirements
|
|
50
|
+
- Updated all test files to use camelCase field names when creating models and accessing fields
|
|
51
|
+
- Updated all docstrings and examples to reflect camelCase naming convention
|
|
52
|
+
|
|
53
|
+
### Migration Guide
|
|
54
|
+
|
|
55
|
+
**For users upgrading from previous versions:**
|
|
56
|
+
|
|
57
|
+
1. **Update model field references**: Change all snake_case field access to camelCase
|
|
58
|
+
- Old: `response.meta.total_items` → New: `response.meta.totalItems`
|
|
59
|
+
- Old: `response.meta.current_page` → New: `response.meta.currentPage`
|
|
60
|
+
- Old: `response.meta.page_size` → New: `response.meta.pageSize`
|
|
61
|
+
- Old: `error_response.status_code` → New: `error_response.statusCode`
|
|
62
|
+
- Old: `error_response.request_key` → New: `error_response.correlationId`
|
|
63
|
+
|
|
64
|
+
2. **Update model instantiation**: Use camelCase field names when creating models
|
|
65
|
+
- Old: `FilterQuery(page_size=25)` → New: `FilterQuery(pageSize=25)`
|
|
66
|
+
- Old: `Meta(total_items=120, current_page=1, page_size=25)` → New: `Meta(totalItems=120, currentPage=1, pageSize=25)`
|
|
67
|
+
|
|
68
|
+
3. **Update query parameters**: Query strings now use camelCase
|
|
69
|
+
- Old: `?page=1&page_size=25` → New: `?page=1&pageSize=25`
|
|
70
|
+
|
|
71
|
+
4. **Update JSON request bodies**: All outgoing JSON must use camelCase
|
|
72
|
+
- Old: `{"user_id": "123", "application_id": "app-1"}` → New: `{"userId": "123", "applicationId": "app-1"}`
|
|
73
|
+
|
|
74
|
+
5. **API responses**: All API responses are expected in camelCase format
|
|
75
|
+
|
|
76
|
+
### Testing
|
|
77
|
+
|
|
78
|
+
- Updated all 409 unit tests to use camelCase field names
|
|
79
|
+
- All tests passing with 91% code coverage
|
|
80
|
+
- Comprehensive test coverage for all model field changes
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## [0.5.0] - 2025-11-02
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
|
|
88
|
+
- **Pagination Utilities**: Complete pagination support for list responses
|
|
89
|
+
- `Meta` and `PaginatedListResponse` Pydantic models for standardized paginated responses
|
|
90
|
+
- `parse_pagination_params()` function to parse `page` and `page_size` query parameters
|
|
91
|
+
- `create_meta_object()` function to construct pagination metadata objects
|
|
92
|
+
- `apply_pagination_to_array()` function for local pagination in tests/mocks
|
|
93
|
+
- `create_paginated_list_response()` function to wrap data with pagination metadata
|
|
94
|
+
- Support for both snake_case (`total_items`, `current_page`, `page_size`) and camelCase (`totalItems`, `currentPage`, `pageSize`) attribute access
|
|
95
|
+
- Full type safety with Pydantic models and generic type support
|
|
96
|
+
|
|
97
|
+
- **Filtering Utilities**: Comprehensive filtering support for API queries
|
|
98
|
+
- `FilterOption`, `FilterQuery`, and `FilterBuilder` classes for building filter queries
|
|
99
|
+
- `FilterOperator` type supporting: `eq`, `neq`, `in`, `nin`, `gt`, `lt`, `gte`, `lte`, `contains`, `like`
|
|
100
|
+
- `parse_filter_params()` function to parse `filter=field:op:value` query parameters
|
|
101
|
+
- `build_query_string()` function to convert `FilterQuery` objects to URL query strings
|
|
102
|
+
- `apply_filters()` function for local filtering in tests/mocks
|
|
103
|
+
- `FilterBuilder` class with fluent API for method chaining (e.g., `FilterBuilder().add('status', 'eq', 'active').add('region', 'in', ['eu', 'us'])`)
|
|
104
|
+
- URL encoding support for field names and values (comma separators preserved for array values)
|
|
105
|
+
- Integration with `/metadata/filter` endpoint through `FilterBuilder` compatibility with `AccessFieldFilter`
|
|
106
|
+
|
|
107
|
+
- **Sorting Utilities**: Sort parameter parsing and building
|
|
108
|
+
- `SortOption` Pydantic model with `field` and `order` (asc/desc) properties
|
|
109
|
+
- `parse_sort_params()` function to parse `sort=-field` query parameters
|
|
110
|
+
- `build_sort_string()` function to convert `SortOption` lists to query string format
|
|
111
|
+
- Support for multiple sort fields with ascending/descending order
|
|
112
|
+
- URL encoding for field names with special characters
|
|
113
|
+
|
|
114
|
+
- **Error Handling Utilities**: Enhanced error response transformation and handling
|
|
115
|
+
- `transform_error_to_snake_case()` function for converting error dictionaries to `ErrorResponse` objects
|
|
116
|
+
- `handle_api_error_snake_case()` function for creating `MisoClientError` from API error responses
|
|
117
|
+
- Support for both camelCase and snake_case field names in error responses
|
|
118
|
+
- Automatic parameter overriding (instance and status_code parameters override response data)
|
|
119
|
+
- Graceful handling of missing optional fields (title, instance, request_key)
|
|
120
|
+
|
|
121
|
+
- **HTTP Client Enhancements**: New helper methods for filtered and paginated requests
|
|
122
|
+
- `get_with_filters()` method for making GET requests with `FilterBuilder` support
|
|
123
|
+
- `get_paginated()` method for making GET requests with pagination parameters
|
|
124
|
+
- Automatic query string building from filter/sort/pagination options
|
|
125
|
+
- Flexible response parsing (returns `PaginatedListResponse` when format matches, raw response otherwise)
|
|
126
|
+
|
|
127
|
+
- **ErrorResponse Model Enhancements**:
|
|
128
|
+
- Added `request_key` field for error tracking (supports both `request_key` and `correlationId` aliases)
|
|
129
|
+
- Made `title` field optional (defaults to `None`) for graceful handling of missing titles
|
|
130
|
+
- Added `status_code` property getter for snake_case access (complements `statusCode` camelCase field)
|
|
131
|
+
- Full support for both snake_case and camelCase attribute access
|
|
132
|
+
|
|
133
|
+
- **Model Exports**: All new models and utilities exported from main module
|
|
134
|
+
- Pagination: `Meta`, `PaginatedListResponse`, `parse_pagination_params`, `create_meta_object`, `apply_pagination_to_array`, `create_paginated_list_response`
|
|
135
|
+
- Filtering: `FilterOperator`, `FilterOption`, `FilterQuery`, `FilterBuilder`, `parse_filter_params`, `build_query_string`, `apply_filters`
|
|
136
|
+
- Sorting: `SortOption`, `parse_sort_params`, `build_sort_string`
|
|
137
|
+
- Error: `transform_error_to_snake_case`, `handle_api_error_snake_case`
|
|
138
|
+
- All utilities follow snake_case naming convention matching Miso/Dataplane API conventions
|
|
139
|
+
|
|
140
|
+
### Changed
|
|
141
|
+
|
|
142
|
+
- **ErrorResponse Model**: Made `title` field optional to support APIs that don't provide titles
|
|
143
|
+
- Old: `title: str = Field(..., description="Human-readable error title")`
|
|
144
|
+
- New: `title: Optional[str] = Field(default=None, description="Human-readable error title")`
|
|
145
|
+
- Backward compatible - existing code with required titles still works
|
|
146
|
+
|
|
147
|
+
- **handle_api_error_snake_case Function**: Enhanced parameter override behavior
|
|
148
|
+
- `instance` parameter now overrides instance in response_data (was only set if missing)
|
|
149
|
+
- `status_code` parameter now always overrides status_code in response_data (was only set if missing)
|
|
150
|
+
- Better error message generation when title is missing
|
|
151
|
+
|
|
152
|
+
### Technical Improvements
|
|
153
|
+
|
|
154
|
+
- **Type Safety**: Full type hints throughout all new utilities and models
|
|
155
|
+
- **Pydantic Models**: All new data structures use Pydantic for validation and serialization
|
|
156
|
+
- **Property Getters**: Added property getters to support both snake_case and camelCase attribute access in models
|
|
157
|
+
- **URL Encoding**: Smart encoding that preserves comma delimiters in array filter values
|
|
158
|
+
- **Comprehensive Tests**: 123 unit tests covering all utilities with 100% coverage for models and utilities
|
|
159
|
+
- **Documentation**: Complete README documentation with usage examples for all utilities
|
|
160
|
+
- **Snake_case Convention**: All utilities follow Python snake_case naming to match Miso/Dataplane API conventions
|
|
161
|
+
|
|
162
|
+
### Documentation
|
|
163
|
+
|
|
164
|
+
- Added comprehensive README section for pagination, filtering, and sorting utilities
|
|
165
|
+
- Usage examples for all utilities including combined usage patterns
|
|
166
|
+
- Integration examples with `/metadata/filter` endpoint
|
|
167
|
+
- Type hints and docstrings for all public APIs
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## [0.4.0] - 2025-11-02
|
|
172
|
+
|
|
173
|
+
### Added
|
|
174
|
+
|
|
175
|
+
- **ISO 27001 Compliant HTTP Client with Automatic Audit and Debug Logging**: New public `HttpClient` class that wraps `InternalHttpClient` with automatic ISO 27001 compliant audit and debug logging
|
|
176
|
+
- Automatic audit logging for all HTTP requests (`http.request.{METHOD}` format)
|
|
177
|
+
- Debug logging when `log_level === 'debug'` with detailed request/response information
|
|
178
|
+
- Automatic data masking using `DataMasker` before logging (ISO 27001 compliant)
|
|
179
|
+
- All request headers are masked (Authorization, x-client-token, Cookie, etc.)
|
|
180
|
+
- All request bodies are recursively masked for sensitive fields (password, token, secret, SSN, etc.)
|
|
181
|
+
- All response bodies are masked (limited to first 1000 characters)
|
|
182
|
+
- Query parameters are automatically masked
|
|
183
|
+
- Error messages are masked if they contain sensitive data
|
|
184
|
+
- Sensitive endpoints (`/api/logs`, `/api/auth/token`) are excluded from audit logging to prevent infinite loops
|
|
185
|
+
- JWT user ID extraction from Authorization headers for audit context
|
|
186
|
+
- Request duration tracking for performance monitoring
|
|
187
|
+
- Request/response size tracking for observability
|
|
188
|
+
|
|
189
|
+
- **JSON Configuration Support for DataMasker**: Enhanced `DataMasker` with JSON configuration file support for sensitive fields
|
|
190
|
+
- New `sensitive_fields_config.json` file with default ISO 27001 compliant sensitive fields
|
|
191
|
+
- Categories: authentication, pii, security
|
|
192
|
+
- Support for custom configuration path via `MISO_SENSITIVE_FIELDS_CONFIG` environment variable
|
|
193
|
+
- `DataMasker.set_config_path()` method for programmatic configuration
|
|
194
|
+
- Automatic merging of JSON fields with hardcoded defaults (fallback if JSON cannot be loaded)
|
|
195
|
+
- Backward compatible - existing hardcoded fields still work as fallback
|
|
196
|
+
|
|
197
|
+
- **New InternalHttpClient Class**: Separated core HTTP functionality into `InternalHttpClient` class
|
|
198
|
+
- Pure HTTP functionality with automatic client token management (no logging)
|
|
199
|
+
- Used internally by public `HttpClient` for actual HTTP requests
|
|
200
|
+
- Used by `LoggerService` for sending logs to prevent circular dependencies
|
|
201
|
+
- Not exported in public API (internal use only)
|
|
202
|
+
|
|
203
|
+
- **New sensitive_fields_loader Module**: Utility module for loading and merging sensitive fields configuration
|
|
204
|
+
- `load_sensitive_fields_config()` function for loading JSON configuration
|
|
205
|
+
- `get_sensitive_fields_array()` function for flattened sensitive fields list
|
|
206
|
+
- `get_field_patterns()` function for pattern matching rules
|
|
207
|
+
- Support for custom configuration paths via environment variables
|
|
208
|
+
|
|
209
|
+
### Changed
|
|
210
|
+
|
|
211
|
+
- **Breaking Change: HttpClient Constructor**: Public `HttpClient` constructor now requires `logger` parameter
|
|
212
|
+
- Old: `HttpClient(config)`
|
|
213
|
+
- New: `HttpClient(config, logger)`
|
|
214
|
+
- This is handled automatically when using `MisoClient` - no changes needed for typical usage
|
|
215
|
+
- Only affects code that directly instantiates `HttpClient`
|
|
216
|
+
|
|
217
|
+
- **Breaking Change: LoggerService Constructor**: `LoggerService` constructor now uses `InternalHttpClient` instead of `HttpClient`
|
|
218
|
+
- Old: `LoggerService(http_client: HttpClient, redis: RedisService)`
|
|
219
|
+
- New: `LoggerService(internal_http_client: InternalHttpClient, redis: RedisService)`
|
|
220
|
+
- This is handled automatically when using `MisoClient` - no changes needed for typical usage
|
|
221
|
+
- Prevents circular dependency (LoggerService uses InternalHttpClient for log sending)
|
|
222
|
+
|
|
223
|
+
- **MisoClient Architecture**: Updated `MisoClient` constructor to use new HttpClient architecture
|
|
224
|
+
- Creates `InternalHttpClient` first (pure HTTP functionality)
|
|
225
|
+
- Creates `LoggerService` with `InternalHttpClient` (prevents circular dependency)
|
|
226
|
+
- Creates public `HttpClient` wrapping `InternalHttpClient` with logger (adds audit/debug logging)
|
|
227
|
+
- All services now use public `HttpClient` with automatic audit logging
|
|
228
|
+
|
|
229
|
+
- **DataMasker Enhancement**: Updated `DataMasker` to load sensitive fields from JSON configuration
|
|
230
|
+
- Maintains backward compatibility with hardcoded fields as fallback
|
|
231
|
+
- Automatic loading on first use with caching
|
|
232
|
+
- Support for custom configuration paths
|
|
233
|
+
|
|
234
|
+
### ISO 27001 Compliance Features
|
|
235
|
+
|
|
236
|
+
- **Automatic Data Masking**: All sensitive data is automatically masked before logging
|
|
237
|
+
- Request headers: Authorization, x-client-token, Cookie, Set-Cookie, and any header containing sensitive keywords
|
|
238
|
+
- Request bodies: Recursively masks password, token, secret, SSN, creditcard, CVV, PIN, OTP, API keys, etc.
|
|
239
|
+
- Response bodies: Especially important for error responses that might contain sensitive data
|
|
240
|
+
- Query parameters: Automatically extracted and masked
|
|
241
|
+
- Error messages: Masked if containing sensitive data
|
|
242
|
+
|
|
243
|
+
- **Audit Log Structure**: Standardized audit log format for all HTTP requests
|
|
244
|
+
- Action: `http.request.{METHOD}` (e.g., `http.request.GET`, `http.request.POST`)
|
|
245
|
+
- Resource: Request URL path
|
|
246
|
+
- Context: method, url, statusCode, duration, userId, requestSize, responseSize, error (all sensitive data masked)
|
|
247
|
+
|
|
248
|
+
- **Debug Log Structure**: Detailed debug logging when `log_level === 'debug'`
|
|
249
|
+
- All audit context fields plus: requestHeaders, responseHeaders, requestBody, responseBody (all masked)
|
|
250
|
+
- Additional context: baseURL, timeout, queryParams (all sensitive data masked)
|
|
251
|
+
|
|
252
|
+
### Technical Improvements
|
|
253
|
+
|
|
254
|
+
- Improved error handling: Logging errors never break HTTP requests (all errors caught and swallowed)
|
|
255
|
+
- Performance: Async logging that doesn't block request/response flow
|
|
256
|
+
- Safety: Sensitive endpoints excluded from audit logging to prevent infinite loops
|
|
257
|
+
- Flexibility: Configurable sensitive fields via JSON configuration file
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## [0.3.0] - 2025-11-01
|
|
262
|
+
|
|
263
|
+
### Added
|
|
264
|
+
|
|
265
|
+
- **Structured Error Response Interface**: Added generic `ErrorResponse` model following RFC 7807-style format for consistent error handling across applications
|
|
266
|
+
- `ErrorResponse` Pydantic model with fields: `errors`, `type`, `title`, `statusCode`, `instance`
|
|
267
|
+
- Automatic parsing of structured error responses from HTTP responses in `HttpClient`
|
|
268
|
+
- Support for both camelCase (`statusCode`) and snake_case (`status_code`) field names
|
|
269
|
+
- `MisoClientError` now includes optional `error_response` field with structured error information
|
|
270
|
+
- Enhanced error messages automatically generated from structured error responses
|
|
271
|
+
- Instance URI automatically extracted from request URL when not provided in response
|
|
272
|
+
- Backward compatible - falls back to traditional `error_body` dict when structured format is not available
|
|
273
|
+
- Export `ErrorResponse` from main module for reuse in other applications
|
|
274
|
+
- Comprehensive test coverage for error response parsing and fallback behavior
|
|
275
|
+
- Full type safety with Pydantic models
|
|
276
|
+
|
|
277
|
+
### Changed
|
|
278
|
+
|
|
279
|
+
- **Error Handling**: `MisoClientError` now prioritizes structured error information when available
|
|
280
|
+
- Error messages are automatically enhanced from structured error responses
|
|
281
|
+
- Status codes are extracted from structured responses when provided
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## [0.2.0] - 2025-10-31
|
|
286
|
+
|
|
287
|
+
### Added
|
|
288
|
+
|
|
289
|
+
- **API_KEY Support for Testing**: Added optional `API_KEY` environment variable that allows bypassing OAuth2 authentication for testing purposes
|
|
290
|
+
- When `API_KEY` is set in environment, bearer tokens matching the key will automatically validate without OAuth2
|
|
291
|
+
- `validate_token()` returns `True` for matching API_KEY tokens without calling controller
|
|
292
|
+
- `get_user()` and `get_user_info()` return `None` when using API_KEY (by design for testing scenarios)
|
|
293
|
+
- Configuration supports `api_key` field in `MisoClientConfig`
|
|
294
|
+
- Comprehensive test coverage for API_KEY authentication flows
|
|
295
|
+
- Useful for testing without requiring Keycloak setup
|
|
296
|
+
|
|
297
|
+
- **PowerShell Makefile**: Added `Makefile.ps1` with all development commands for Windows PowerShell users
|
|
298
|
+
- Replaces `dev.bat` and `dev.ps1` scripts with unified PowerShell Makefile
|
|
299
|
+
- Supports all standard development commands (install, test, lint, format, build, etc.)
|
|
300
|
+
- Consistent interface with Unix Makefile
|
|
301
|
+
|
|
302
|
+
- **Validate Command**: Added new `validate` target to both Makefile and Makefile.ps1
|
|
303
|
+
- Runs lint + format + test in sequence
|
|
304
|
+
- Useful for pre-commit validation and CI/CD pipelines
|
|
305
|
+
- Usage: `make validate` or `.\Makefile.ps1 validate`
|
|
306
|
+
|
|
307
|
+
### Changed
|
|
308
|
+
|
|
309
|
+
- **Development Scripts**: Replaced `dev.bat` and `dev.ps1` with `Makefile.ps1` for better consistency
|
|
310
|
+
- All development commands now available through Makefile interface
|
|
311
|
+
- Improved cross-platform compatibility
|
|
312
|
+
|
|
313
|
+
### Testing
|
|
314
|
+
|
|
315
|
+
- Added comprehensive test suite for API_KEY functionality
|
|
316
|
+
- Tests for `validate_token()` with API_KEY matching and non-matching scenarios
|
|
317
|
+
- Tests for `get_user()` and `get_user_info()` with API_KEY
|
|
318
|
+
- Tests for config loader API_KEY loading
|
|
319
|
+
- All tests verify OAuth2 fallback behavior when API_KEY doesn't match
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## [0.1.0] - 2025-10-30
|
|
324
|
+
|
|
325
|
+
### Added
|
|
326
|
+
|
|
327
|
+
- **Automatic Client Token Management in HttpClient**: Client tokens are now automatically fetched, cached, and refreshed by the HttpClient
|
|
328
|
+
- Proactive token refresh when < 60 seconds until expiry (30 second buffer before actual expiration)
|
|
329
|
+
- Automatic `x-client-token` header injection for all requests
|
|
330
|
+
- Concurrent token fetch prevention using async locks
|
|
331
|
+
- Automatic token clearing on 401 responses to force refresh
|
|
332
|
+
|
|
333
|
+
- **New Data Models**:
|
|
334
|
+
- `ClientTokenResponse`: Response model for client token requests with expiration tracking
|
|
335
|
+
- `PerformanceMetrics`: Performance metrics model for logging (start time, end time, duration, memory usage)
|
|
336
|
+
- `ClientLoggingOptions`: Advanced logging options with JWT context extraction, correlation IDs, data masking, and performance metrics support
|
|
337
|
+
|
|
338
|
+
- **RedisConfig Enhancement**:
|
|
339
|
+
- Added `db` field to specify Redis database number (default: 0)
|
|
340
|
+
- Supports multi-database Redis deployments
|
|
341
|
+
|
|
342
|
+
### Changed
|
|
343
|
+
|
|
344
|
+
- **Module Structure**: Moved type definitions from `miso_client.types.config` to `miso_client.models.config` for better organization
|
|
345
|
+
- All imports now use `from miso_client.models.config import ...`
|
|
346
|
+
- Previous compatibility layer (`types_backup_test`) removed as no longer needed
|
|
347
|
+
|
|
348
|
+
- **HttpClient Improvements**:
|
|
349
|
+
- Client token management is now fully automatic - no manual token handling required
|
|
350
|
+
- Better error handling with automatic token refresh on authentication failures
|
|
351
|
+
- All HTTP methods (GET, POST, PUT, DELETE) now automatically include client token header
|
|
352
|
+
|
|
353
|
+
### Technical Improvements
|
|
354
|
+
|
|
355
|
+
- Improved token expiration handling with proactive refresh mechanism
|
|
356
|
+
- Reduced API calls through intelligent token caching
|
|
357
|
+
- Better concurrency handling with async locks for token operations
|
|
358
|
+
- Enhanced error recovery with automatic token clearing on 401 responses
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## [0.1.0] - 2025-10-01
|
|
363
|
+
|
|
364
|
+
### Added
|
|
365
|
+
|
|
366
|
+
- **Initial Release**: Complete MisoClient SDK implementation
|
|
367
|
+
- **Authentication**: JWT token validation and user management
|
|
368
|
+
- **Authorization**: Role-based access control (RBAC) with Redis caching
|
|
369
|
+
- **Permissions**: Fine-grained permission management with caching
|
|
370
|
+
- **Logging**: Structured logging with Redis queuing and HTTP fallback
|
|
371
|
+
- **Redis Integration**: Optional Redis caching for improved performance
|
|
372
|
+
- **Async Support**: Full async/await support for modern Python applications
|
|
373
|
+
- **Type Safety**: Complete type hints and Pydantic models
|
|
374
|
+
- **Graceful Degradation**: Works with or without Redis
|
|
375
|
+
- **Comprehensive Documentation**: Complete API reference and integration guides
|
|
376
|
+
- **Unit Tests**: Full test coverage mirroring TypeScript implementation
|
|
377
|
+
- **Package Distribution**: Ready for PyPI distribution with setup.py and pyproject.toml
|
|
378
|
+
|
|
379
|
+
### Features
|
|
380
|
+
|
|
381
|
+
#### Core Client
|
|
382
|
+
- `MisoClient` main class with initialization and lifecycle management
|
|
383
|
+
- Configuration management with `MisoClientConfig` and `RedisConfig`
|
|
384
|
+
- Connection state tracking and graceful fallback
|
|
385
|
+
|
|
386
|
+
#### Authentication Service
|
|
387
|
+
- Token validation with controller integration
|
|
388
|
+
- User information retrieval
|
|
389
|
+
- Login URL generation for web applications
|
|
390
|
+
- Logout functionality
|
|
391
|
+
|
|
392
|
+
#### Role Service
|
|
393
|
+
- Role retrieval with Redis caching (15-minute TTL)
|
|
394
|
+
- Role checking methods: `has_role`, `has_any_role`, `has_all_roles`
|
|
395
|
+
- Role refresh functionality to bypass cache
|
|
396
|
+
- Cache key management with user/environment/application scoping
|
|
397
|
+
|
|
398
|
+
#### Permission Service
|
|
399
|
+
- Permission retrieval with Redis caching (15-minute TTL)
|
|
400
|
+
- Permission checking methods: `has_permission`, `has_any_permission`, `has_all_permissions`
|
|
401
|
+
- Permission refresh functionality to bypass cache
|
|
402
|
+
- Cache clearing functionality
|
|
403
|
+
- Cache key management with user/environment/application scoping
|
|
404
|
+
|
|
405
|
+
#### Logger Service
|
|
406
|
+
- Structured logging with multiple levels: `info`, `error`, `audit`, `debug`
|
|
407
|
+
- Redis queue integration for log batching
|
|
408
|
+
- HTTP fallback when Redis is unavailable
|
|
409
|
+
- Context-aware logging with metadata support
|
|
410
|
+
|
|
411
|
+
#### HTTP Client
|
|
412
|
+
- Async HTTP client wrapper using httpx
|
|
413
|
+
- Automatic header injection (X-Environment, X-Application)
|
|
414
|
+
- Authenticated request support with Bearer token
|
|
415
|
+
- Error handling and status code management
|
|
416
|
+
|
|
417
|
+
#### Redis Service
|
|
418
|
+
- Async Redis integration using redis.asyncio
|
|
419
|
+
- Graceful degradation when Redis is unavailable
|
|
420
|
+
- Connection state tracking
|
|
421
|
+
- Key prefix support for multi-tenant environments
|
|
422
|
+
|
|
423
|
+
### Data Models
|
|
424
|
+
|
|
425
|
+
- `UserInfo`: User information from token validation
|
|
426
|
+
- `AuthResult`: Authentication result structure
|
|
427
|
+
- `LogEntry`: Structured log entry format
|
|
428
|
+
- `RoleResult`: Role query result
|
|
429
|
+
- `PermissionResult`: Permission query result
|
|
430
|
+
- `MisoClientConfig`: Main client configuration
|
|
431
|
+
- `RedisConfig`: Redis connection configuration
|
|
432
|
+
|
|
433
|
+
### Integration Examples
|
|
434
|
+
|
|
435
|
+
- **FastAPI**: Complete integration with dependencies and middleware
|
|
436
|
+
- **Django**: Middleware, decorators, and view integration
|
|
437
|
+
- **Flask**: Decorator-based authentication and authorization
|
|
438
|
+
- **Custom Applications**: Dependency injection and service patterns
|
|
439
|
+
|
|
440
|
+
### Documentation
|
|
441
|
+
|
|
442
|
+
- **README.md**: Comprehensive SDK documentation with quick start guide
|
|
443
|
+
- **API Reference**: Detailed method signatures and parameter descriptions
|
|
444
|
+
- **Integration Guide**: Framework-specific integration examples
|
|
445
|
+
- **Changelog**: Version history and feature tracking
|
|
446
|
+
|
|
447
|
+
### Testing
|
|
448
|
+
|
|
449
|
+
- **Unit Tests**: Comprehensive test coverage for all services
|
|
450
|
+
- **Mock Support**: Mock implementations for testing
|
|
451
|
+
- **Error Handling**: Test coverage for error scenarios and edge cases
|
|
452
|
+
- **Performance Tests**: Concurrent operation testing
|
|
453
|
+
|
|
454
|
+
### Package Management
|
|
455
|
+
|
|
456
|
+
- **setup.py**: Traditional Python package configuration
|
|
457
|
+
- **pyproject.toml**: Modern Python packaging (PEP 518)
|
|
458
|
+
- **Dependencies**: httpx, redis[hiredis], pydantic, pydantic-settings, structlog
|
|
459
|
+
- **Development Dependencies**: pytest, black, isort, mypy
|
|
460
|
+
- **Python Support**: Python 3.8+ compatibility
|
|
461
|
+
|
|
462
|
+
### Security
|
|
463
|
+
|
|
464
|
+
- **Token Handling**: Secure JWT token processing
|
|
465
|
+
- **Redis Security**: Password and key prefix support
|
|
466
|
+
- **Logging Security**: Careful handling of sensitive information
|
|
467
|
+
- **Error Handling**: Graceful error handling without information leakage
|
|
468
|
+
|
|
469
|
+
### Performance
|
|
470
|
+
|
|
471
|
+
- **Caching**: Redis-based caching for roles and permissions
|
|
472
|
+
- **Connection Pooling**: Efficient HTTP and Redis connection management
|
|
473
|
+
- **Async Operations**: Non-blocking async/await throughout
|
|
474
|
+
- **Batch Operations**: Support for concurrent operations
|
|
475
|
+
|
|
476
|
+
### Compatibility
|
|
477
|
+
|
|
478
|
+
- **Python Versions**: 3.8, 3.9, 3.10, 3.11, 3.12
|
|
479
|
+
- **Framework Support**: FastAPI, Django, Flask, and custom applications
|
|
480
|
+
- **Redis Versions**: Compatible with Redis 5.0+
|
|
481
|
+
- **HTTP Clients**: Uses httpx for modern async HTTP support
|
|
482
|
+
|
|
483
|
+
### Migration
|
|
484
|
+
|
|
485
|
+
- **From Keycloak**: Seamless migration from direct Keycloak integration
|
|
486
|
+
- **Backward Compatibility**: Maintains existing API patterns
|
|
487
|
+
- **Configuration**: Simple configuration migration
|
|
488
|
+
- **Testing**: Comprehensive migration testing support
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## Future Releases
|
|
493
|
+
|
|
494
|
+
### Planned Features
|
|
495
|
+
|
|
496
|
+
- **WebSocket Support**: Real-time authentication updates
|
|
497
|
+
- **Metrics Integration**: Prometheus and OpenTelemetry support
|
|
498
|
+
- **Advanced Caching**: Cache invalidation strategies
|
|
499
|
+
- **Multi-Controller Support**: Load balancing across multiple controllers
|
|
500
|
+
- **SDK Extensions**: Framework-specific SDK extensions
|
|
501
|
+
|
|
502
|
+
### Roadmap
|
|
503
|
+
|
|
504
|
+
- **v1.1.0**: WebSocket support and real-time updates
|
|
505
|
+
- **v1.2.0**: Advanced metrics and monitoring
|
|
506
|
+
- **v2.0.0**: Multi-controller support and load balancing
|
|
507
|
+
- **v2.1.0**: Framework-specific SDK extensions
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
For more information about the MisoClient SDK, visit:
|
|
512
|
+
- [Documentation](https://docs.aifabrix.ai/miso-client-python)
|
|
513
|
+
- [GitHub Repository](https://github.com/aifabrix/miso-client-python)
|
|
514
|
+
- [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
|
+
|