feat: complete Phase 2.6 - Security Hardening
- Implement session management with device tracking - Implement audit logging system - Implement account lockout for brute-force protection - Add security headers middleware - Add rate limiting middleware (stub) - Integrate security services into main application Build Status: Compiles successfully Phase: 2.6 of 8 (75% complete)
This commit is contained in:
parent
be49d9d674
commit
4627903999
17 changed files with 910 additions and 61 deletions
39
backend/src/middleware/security_headers.rs
Normal file
39
backend/src/middleware/security_headers.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use axum::{
|
||||
extract::Request,
|
||||
http::HeaderValue,
|
||||
middleware::Next,
|
||||
response::Response,
|
||||
};
|
||||
|
||||
pub async fn security_headers_middleware(
|
||||
req: Request,
|
||||
next: Next,
|
||||
) -> Response {
|
||||
let mut response = next.run(req).await;
|
||||
|
||||
let headers = response.headers_mut();
|
||||
|
||||
// Security headers
|
||||
headers.insert(
|
||||
"X-Content-Type-Options",
|
||||
HeaderValue::from_static("nosniff"),
|
||||
);
|
||||
headers.insert(
|
||||
"X-Frame-Options",
|
||||
HeaderValue::from_static("DENY"),
|
||||
);
|
||||
headers.insert(
|
||||
"X-XSS-Protection",
|
||||
HeaderValue::from_static("1; mode=block"),
|
||||
);
|
||||
headers.insert(
|
||||
"Strict-Transport-Security",
|
||||
HeaderValue::from_static("max-age=31536000; includeSubDomains"),
|
||||
);
|
||||
headers.insert(
|
||||
"Content-Security-Policy",
|
||||
HeaderValue::from_static("default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'"),
|
||||
);
|
||||
|
||||
response
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue