feat: Add SaaS robustness middleware - Rate limiting with token bucket and sliding window algorithms - Input validation (file, language, provider) - Security headers middleware (CSP, XSS protection, etc.) - Automatic file cleanup with TTL tracking - Memory and disk monitoring - Enhanced health check and metrics endpoints - Request logging with unique IDs
This commit is contained in:
62
middleware/__init__.py
Normal file
62
middleware/__init__.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
Middleware package for SaaS robustness
|
||||
|
||||
This package provides:
|
||||
- Rate limiting: Protect against abuse and ensure fair usage
|
||||
- Validation: Validate all inputs before processing
|
||||
- Security: Security headers, request logging, error handling
|
||||
- Cleanup: Automatic file cleanup and resource management
|
||||
"""
|
||||
|
||||
from .rate_limiting import (
|
||||
RateLimitConfig,
|
||||
RateLimitManager,
|
||||
RateLimitMiddleware,
|
||||
ClientRateLimiter,
|
||||
)
|
||||
|
||||
from .validation import (
|
||||
ValidationError,
|
||||
ValidationResult,
|
||||
FileValidator,
|
||||
LanguageValidator,
|
||||
ProviderValidator,
|
||||
InputSanitizer,
|
||||
)
|
||||
|
||||
from .security import (
|
||||
SecurityHeadersMiddleware,
|
||||
RequestLoggingMiddleware,
|
||||
ErrorHandlingMiddleware,
|
||||
)
|
||||
|
||||
from .cleanup import (
|
||||
FileCleanupManager,
|
||||
MemoryMonitor,
|
||||
HealthChecker,
|
||||
create_cleanup_manager,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# Rate limiting
|
||||
"RateLimitConfig",
|
||||
"RateLimitManager",
|
||||
"RateLimitMiddleware",
|
||||
"ClientRateLimiter",
|
||||
# Validation
|
||||
"ValidationError",
|
||||
"ValidationResult",
|
||||
"FileValidator",
|
||||
"LanguageValidator",
|
||||
"ProviderValidator",
|
||||
"InputSanitizer",
|
||||
# Security
|
||||
"SecurityHeadersMiddleware",
|
||||
"RequestLoggingMiddleware",
|
||||
"ErrorHandlingMiddleware",
|
||||
# Cleanup
|
||||
"FileCleanupManager",
|
||||
"MemoryMonitor",
|
||||
"HealthChecker",
|
||||
"create_cleanup_manager",
|
||||
]
|
||||
Reference in New Issue
Block a user