asignua/filament-csp-nonce
CSP nonce support for Filament: generates a per-request nonce and applies it to Filament's inline scripts and styles, so your admin panel runs under a strict Content Security Policy without unsafe-inline. Simple Laravel/Filament integration with minimal configuration.
unsafe-inline. The package's core value is injecting a per-request nonce and rewriting inline <script>/<style> so script-src 'nonce-…' can be enforced. That is the prerequisite that clears most security-review, pen-test, and compliance-questionnaire findings around missing or permissive CSP.report-uri, report-to, and Reporting-Endpoints, this package is a reporting producer, not just a header setter. That makes "collect and dashboard CSP violations" a shippable follow-on epic rather than a separate integration project.report-to group is no longer overwritten, and null keeps report-uri/report-to removed. This means you can point reporting at Sentry, an internal collector, or a commercial CSP reporter without forking — a real build-vs-buy lever on the observability side.report-uri and Reporting-Endpoints now include the app base path, which unblocks path-prefixed/subdirectory deployments. If your roadmap includes multi-tenant or path-segmented Laravel installs, this was previously a blocker for trustworthy reporting.^1.0.1.Adopt when most of the following hold:
unsafe-inline. This is the sweet spot; the package's nonce injection and attribute rewriting assume server-rendered markup.report-to group or deliberately disable reporting via null; both are now respected.composer update with no API changes.Look elsewhere — or plan to configure around it — when:
strict-dynamic configurations — a Blade nonce injector is the wrong tool.resources/views/errors pages and want them untouched. Error views are now rewritten by default — verify your custom error pages survive, and confirm the opt-out if not.composer.json, and whether your CSP needs exceed what the package's config surface exposes. We have no dependency metadata in hand for this review.For executives (one paragraph): This is a small, single-purpose dependency that closes a recurring security finding — our Content Security Policy is currently permissive or absent — and, unlike a hand-rolled header, it also produces the violation telemetry we need to prove the policy is working. The release under review, v1.0.1, is a patch release with no API changes: a composer update, no migration, no feature work. It is nonetheless the first version I would ship, because it fixes three issues in v1.0.0 that would have surfaced as production incidents — unstyled 403/404/419/500 pages in the admin panel, CSP violation batches silently discarded instead of reported, and reporting endpoints generated incorrectly for subdirectory installs. Recommendation: adopt, run in report-only for one week in staging, then enforce.
For engineering (the honest tradeoffs):
^1.0.1.resources/views/errors are now rewritten by default. If we have custom error templates with their own inline styles, confirm they render correctly or opt out. This is the only item that can affect us without a code change.src="{{ asset('nonce.js') }}") previously counted as an existing nonce, so those scripts were treated as already-sanctioned and then blocked. Nonce detection is now accurate — expect fewer "mystery blocked script" reports, and expect our violation counts to change on upgrade (they were previously undercounted in two independent ways).report-to groups survive, and null keeps report-uri/report-to removed. Our endpoint choice is no longer fighting the package.blade.paths; Filament's ->font() pulls Bunny Fonts, so font-src must allow it or typography will silently fall back.Ask: approve the dependency, standardize on ^1.0.1, and schedule one staging week in report-only mode before flipping to enforcement. Budget a short task to re-baseline violation metrics post-upgrade, since the previous numbers were not trustworthy.
How can I help you explore Laravel packages today?