shelf_helmet
2.3.0, released 3 years ago by jxstxn.dev
Secure Dart Shelf and Dart Frog apps by setting HTTP security headers
What it does
Port of the NodeJS helmet package to Dart, providing middleware for Shelf and Dart Frog that automatically sets various HTTP security headers like Content-Security-Policy, X-Frame-Options, and Strict-Transport-Security.
AI-written summary of version 2.3.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building a backend or web application using Dart Shelf or Dart Frog.
- You need to protect your web endpoints with standard HTTP security headers.
Skip it when
- Your application does not use Dart Shelf, Dart Frog, or compatible middleware frameworks.
- You prefer to manually construct and assign all security response headers yourself.
Strengths
- Wraps 13 individual security header middlewares into a single easy-to-use call.
- Highly configurable options for individual headers and policies.
- Out-of-the-box support for popular frameworks like Shelf, Dart Frog, and Pharaoh.
Weaknesses
- Not a silver bullet for overall application security.
- Requires careful tuning of options like CSP to avoid breaking legitimate web page resources.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add the package via `dart pub add shelf_helmet` and integrate it into your middleware pipeline.
import 'package:shelf_helmet/shelf_helmet.dart';
var handler = const Pipeline()
.addMiddleware(helmet())
.addMiddleware(logRequests())
.addHandler(_echoRequest);Alternatives
Packages that do the same job and could replace shelf_helmet.
- shelf_cors_headers
CORS headers middleware for Shelf.
47Compare - shelf_proxy
A shelf handler for proxying HTTP requests to another server.
86Compare - dart_frog
A minimalistic Dart backend framework with a built‑in dev server and Docker support.
80Compare - shelf_letsencrypt
Let's Encrypt support and automatic HTTPS certificate management for the shelf package.
71Compare
Works with
Packages commonly used together with shelf_helmet: ones it builds on, ones built on it, and its own family.