Umbral
Back to plugin directory
US

Umbral Security

Official by Umbral contributors

CSRF, HSTS, secure headers, template escaping

official stable

About

The security features you forget to add are the ones that bite you. Umbral Security ships them on by default — CSRF protection on every POST, HSTS, clickjacking headers, and template auto-escaping — so a fresh app is hardened before you write a line of security code. When a default is genuinely too tight (a JSON API that authenticates by bearer token, say), the escape hatches are explicit and narrow, not a global off switch.

Install

cargo add umbral-security

Wire it up

The defaults need no configuration — just mount it.

use umbral::prelude::*;
use umbral_security::SecurityPlugin;

let app = App::builder()
    .database("default", pool)
    .plugin(SecurityPlugin::new())
    .build()?;

Target: exempt a token-authed API from CSRF

CSRF protects cookie-authenticated form posts; a bearer-token API doesn't need it. Exempt the prefix without weakening the rest of the site.

use umbral_security::{SecurityPlugin, SecurityConfig};

SecurityPlugin::with_config(SecurityConfig {
    csrf_exempt_paths: vec!["/api".into()],
    ..Default::default()
})
.with_hsts(true);

What you get

  • Double-submit CSRF token enforced on every POST
  • HSTS + a full set of secure response headers
  • Clickjacking protection (X-Frame-Options / frame-ancestors)
  • Template output auto-escaped by default; opt out explicitly
  • Per-path escape hatches instead of a global kill switch

Usage

Mount `SecurityPlugin::new()` for hardened defaults, or `SecurityPlugin::with_config(...)` to narrow a single default — e.g. `csrf_exempt_paths` for a bearer-token API. Exemptions are per-path, never a global off switch.

plugin setup
cargo add umbral-security

Feature tracker

Per-feature shipping status, recorded in the directory.

7 of 7 shipped
CSRF protection shipped Stable

Signed double-submit token enforced on unsafe methods.

Template CSRF helpers shipped Stable

csrf_token and hidden input helpers are injected into templates.

HSTS and secure headers shipped Stable

Strict-Transport-Security and modern security headers.

Clickjacking protection shipped Stable

X-Frame-Options and frame-ancestors headers.

Template auto-escaping shipped Stable

Output escaped by default; opt out explicitly.

Production hardening preset shipped Beta

One preset flips HSTS, secure CSRF cookies, and stricter headers.

Request body limit shipped Beta

Optional request body cap for DoS hardening.

Compatibility

Declared support per Umbral version and database backend.

No compatibility rows declared yet.

Community notes

0 notes in the discussion thread.

No notes yet. Be the first to share how this plugin works for you.

Reported issues

Bugs and abuse reports filed against this plugin.

Report an issue

No open issues

No issues have been reported against this plugin. Track upstream bugs on the maintainer's tracker, or report a directory problem to the Umbral team.