mikefrancis/laravel-secureheaders
mikefrancis/laravel-secureheaders adds configurable security headers to Laravel responses via middleware, with sensible defaults for CSP, HSTS, X-Frame-Options, Referrer-Policy, and related protections. Easily customize headers to harden apps against clickjacking, MIME sniffing, and other common web...
Architecture fit. The package is a thin Laravel middleware wrapper around aidantwoods/secureheaders. It sits in the HTTP kernel's response path and adds a configurable set of security headers (CSP, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, etc.) to outgoing responses. It is stateless — no database, queue, cache, or external service dependency — which makes it trivially composable with any Laravel HTTP application, including those running under Octane. It fits the framework's conventions cleanly (service provider with auto-discovery, publishable config, middleware class).
Integration feasibility. Very high. The expected integration is composer require, publish the config, and register the middleware globally or on a route group. There are no schema changes, no infrastructure changes, and no deployment pipeline changes. A competent Laravel developer can complete first-pass integration in a few hours.
Technical risk. The dominant risk is lifecycle, not code. The last release was May 2021, which almost certainly predates Laravel 10/11/12 and the PHP 8.1+ baseline; Composer constraints may block installation on a current stack, and the underlying aidantwoods/secureheaders dependency is similarly aged. The mitigating factor is that the blast radius is small: this is a ~100-line wrapper over well-understood HTTP semantics, so the package can be forked, vendored, or replaced with hand-written middleware at low cost. Vendor risk here does not translate into delivery risk. The genuine functional risk is policy content rather than the wrapper: a strict CSP can break inline scripts, eval-based libraries, third-party widgets, and Vite/Livewire/Inertia asset loading if misconfigured.
Key questions.
composer require resolve cleanly against our target Laravel and PHP versions, or does it require a fork to loosen constraints?Stack fit. Best suited to customer-facing, HTML-serving Laravel applications where CSP, HSTS, and framing protections carry real value. For pure JSON APIs the marginal benefit is narrower (HSTS, X-Content-Type-Options, Referrer-Policy still apply), so API-only services can be deprioritized.
Migration path. No migration is required — this is additive. If Composer resolution fails on a modern Laravel version, three options exist in ascending cost: (a) fork the package and widen the version constraints, which is cheap given the code size; (b) swap to a maintained equivalent such as bepsvpt/laravel-security-header or a Spatie offering; (c) inline a ~50-line custom middleware, removing the dependency entirely. Recommend a one-day spike to test resolution on the target stack before committing to any path.
Compatibility. Verify three things explicitly: PHP and laravel/framework constraints in the package's composer.json; whether service-provider auto-discovery works on the target major version; and the middleware registration mechanism (the Kernel.php array on Laravel ≤10 versus bootstrap/app.php on Laravel 11+). Also confirm the config publish tag still resolves.
Sequencing.
curl -I.max-age, no includeSubDomains, no preload; ratchet up only after confirming all subdomains are HTTPS-only.Maintenance. Low change volume — HTTP security headers are stable — but elevated abandonment risk given the 2021 last release and 97 stars. Budget for internal ownership: either a maintained fork or a planned replacement. Track OWASP Secure Headers guidance and any CVEs in the underlying dependency, since the wrapper will not surface them.
Support. Community-only, effectively single-maintainer, no SLA or vendor. Any issue found becomes an internal ticket. This is acceptable for a package whose failure mode is "headers absent" rather than "requests broken," but it must be an explicit accepted risk rather than an unstated one.
Scaling. Negligible. Header injection is constant-time per response with no I/O, and the middleware is stateless, so it is safe under Octane's long-lived workers and under horizontal scaling. It will not be a throughput bottleneck at any realistic volume.
Failure modes.
max-age window and can lock out HTTP-only subdomains.Ramp-up. Very low for the mechanics — a Laravel developer is productive within an hour, and the integration surface is small enough that it does not require specialist knowledge. The non-trivial learning curve is CSP policy design and HSTS rollout discipline, which is inherent to the security domain and would exist with any implementation choice, not specific to this package.
How can I help you explore Laravel packages today?