84 lines
1.8 KiB
Python
84 lines
1.8 KiB
Python
"""
|
|
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,
|
|
)
|
|
|
|
from .error_handler import (
|
|
ErrorHandlingMiddleware,
|
|
)
|
|
|
|
from .cleanup import (
|
|
FileCleanupManager,
|
|
MemoryMonitor,
|
|
HealthChecker,
|
|
create_cleanup_manager,
|
|
)
|
|
|
|
from .api_key_auth import (
|
|
APIKeyError,
|
|
get_user_from_api_key,
|
|
get_authenticated_user,
|
|
get_authenticated_user_optional,
|
|
get_current_user_optional,
|
|
require_authenticated_user,
|
|
require_api_key,
|
|
)
|
|
|
|
__all__ = [
|
|
# API Key Authentication
|
|
"APIKeyError",
|
|
"get_user_from_api_key",
|
|
"get_authenticated_user",
|
|
"get_authenticated_user_optional",
|
|
"get_current_user_optional",
|
|
"require_authenticated_user",
|
|
"require_api_key",
|
|
# Rate limiting
|
|
"RateLimitConfig",
|
|
"RateLimitManager",
|
|
"RateLimitMiddleware",
|
|
"ClientRateLimiter",
|
|
# Validation
|
|
"ValidationError",
|
|
"ValidationResult",
|
|
"FileValidator",
|
|
"LanguageValidator",
|
|
"ProviderValidator",
|
|
"InputSanitizer",
|
|
# Security
|
|
"SecurityHeadersMiddleware",
|
|
"RequestLoggingMiddleware",
|
|
"ErrorHandlingMiddleware",
|
|
# Cleanup
|
|
"FileCleanupManager",
|
|
"MemoryMonitor",
|
|
"HealthChecker",
|
|
"create_cleanup_manager",
|
|
]
|