middleware
diapason.server.middleware
¶
Security middleware -- HTTP security headers and request guards.
create_security_middleware()
¶
Create a FastAPI middleware that adds security headers.
Returns a middleware class/callable, or None if FastAPI is not available.
Headers added: - X-Content-Type-Options: nosniff - X-Frame-Options: DENY - X-XSS-Protection: 0 (legacy browser filter disabled) - Strict-Transport-Security on HTTPS only - Referrer-Policy: strict-origin-when-cross-origin - Permissions-Policy: camera=(), microphone=(), geolocation=()
OPTIONS requests are passed through without headers so that CORS preflight is not blocked.