Expand description
Security headers middleware
Automatically adds security-related HTTP headers to all responses:
- X-Frame-Options: Prevent clickjacking
- X-Content-Type-Options: Prevent MIME sniffing
- X-XSS-Protection: Enable browser XSS protection
- Strict-Transport-Security: Enforce HTTPS
- Content-Security-Policy: Control resource loading
- Referrer-Policy: Control referrer information
§Example
let config = SecurityHeadersConfig::strict();
let app: Router<()> = Router::new()
.layer(SecurityHeadersLayer::new(config));Structs§
- Hsts
Config - HSTS configuration
- Security
Headers Config - Configuration for security headers middleware
- Security
Headers Layer - Security headers middleware layer
- Security
Headers Middleware - Security headers middleware service
Enums§
- Frame
Options - Frame options for X-Frame-Options header
- Referrer
Policy - Referrer policy options
Functions§
- security_
headers - Axum middleware function for security headers