helmet-core 1.0.0

HTTP security headers middleware core for various web frameworks
Documentation
  • Coverage
  • 45%
    54 out of 120 items documented17 out of 88 items with examples
  • Size
  • Source code size: 55.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.77 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • danielkov/rust-helmet
    19 4 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • danielkov

helmet-core - Security Middleware for popular Rust web frameworks

crate docs

  • ntex-helmet is a security middleware for the ntex web framework.
  • actix-web-helmet is a security middleware for the actix-web web framework. Coming Soon
  • rocket-helmet is a security middleware for the rocket web framework. Coming Soon
  • warp-helmet is a security middleware for the warp web framework. Coming Soon
  • axum-helmet is a security middleware for the axum web framework.

It works by setting HTTP headers for you. These headers can help protect your app from some well-known web vulnerabilities:

Usage

Add this to your Cargo.toml:

[dependencies]
helmet-core = "0.1"

Implementing the middleware is different for each framework. See the README for your framework of choice to see how to use it.

Example

use helmet_core::Helmet;

let helmet = Helmet::default();

struct MyCustomFrameworkMiddleware(Helmet);

// Imagine this is a middleware for your favorite framework
impl<S, B> Middleware<S, B> for MyCustomFrameworkMiddleware {
    fn start(&self, req: &mut Request<S>) -> Result<Started> {
        self.0.headers.iter().for_each(|(k, v)| {
            req.headers_mut().insert(k, v.clone());
        });
        Ok(Started::Done)
    }
}

License

This project is licensed under the MIT license.