Skip to content

shield ​

Baseline security response headers (helmet-style)

Cratesova-shield 0.1.1
Plugin idshield
CategoryHTTP

Install ​

bash
cargo add sova --features shield

Features ​

FeatureWhat you get
shieldHelmet-style security response headers.

Overview ​

When: baseline browser security headers (helmet-style). Already on App::web().

Does:

  • Sets X-Frame-Options, X-Content-Type-Options, Referrer-Policy, COOP/CORP, etc.
  • Optional CSP via builder
  • HSTS stays on TLS (sova_core::Tls), not here

Example ​

rust
app.install(Shield::new().frame("DENY"));

Notes ​

  • Install once — duplicate shield id fails at build
  • App::web() already installs Shield; do not reinstall

Quick start ​

App::web() already installs Shield. Do not reinstall — duplicate shield id fails at build.

Custom stack:

rust
use sova::{App, Shield};

let mut app = App::new();
app.install(
    Shield::new()
        .frame("DENY")
        // .csp("default-src 'self'") when you need CSP
);

cors · csrf