1 unstable release
new 0.2.0 | Apr 2, 2025 |
---|
#932 in HTTP server
77KB
946 lines
actix-web-helmet
- Security Middleware for ntex
web framework
actix-web-helmet
is a security middleware for the actix-web
web framework. It's based on the helmet middleware for Node.js.
It works by setting HTTP headers for you. These headers can help protect your app from some well-known web vulnerabilities:
- Cross-Origin-Embedder-Policy
- Cross-Origin-Opener-Policy
- Cross-Origin-Resource-Policy
- Origin-Agent-Cluster
- Referrer-Policy
- Strict-Transport-Security
- X-Content-Type-Options
- X-DNS-Prefetch-Control
- X-Download-Options
- X-Frame-Options
- X-Permitted-Cross-Domain-Policies
- X-XSS-Protection
- X-Powered-By
- Content-Security-Policy
Usage
Add this to your Cargo.toml
:
[dependencies]
actix-web-helmet = "0.1"
Example
use actix_web::{web, App, HttpResponse};
use actix_web_helmet::Helmet;
#[actix_web::main]
async fn main() {
let app = App::new()
.wrap(Helmet::default())
.service(web::resource("/").to(|| HttpResponse::Ok()));
// ...
}
License
This project is licensed under the MIT license.
Dependencies
~16–27MB
~450K SLoC