Download the PHP package bretto36/csp-reporting without Composer
On this page you can find all versions of the php package bretto36/csp-reporting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bretto36/csp-reporting
More information about bretto36/csp-reporting
Files in bretto36/csp-reporting
Package csp-reporting
Short Description CSP Reporting for Laravel Applications
License MIT
Informations about the package csp-reporting
CSP Reporting Engine
This project is a Content Security Policy (CSP) Reporting engine built to work with Laravel. It receives CSP Violation reports from a report-uri and logs them using Laravel Exceptions.
Installation
-
Clone the repository:
-
Publish the configuration file:
-
Configure the package Add the following environment variables to your
.env
file:The default route for the CSP Reporting engine is
/csp-reporting/report
.To adjust the route suffix
report
you can add an environment variable:If you'd like to customise the route prefix or middleware you can do so in the configuration file.
-
If using Spatie's Laravel CSP package, you can add the following to the
report-uri
directive in your CSP header: -
Make sure to include the route in the VerifyCsrfToken middleware as excluded - 'csp-reporting/*',
-
To silence some CSP Reports you can add a Laravel Event Listener to listen to the CspViolationReportReceived Event
or for Laravel 11, with auto event discovery simply create a listener
Configuration
The configuration file is located at config/csp-reporting.php
. You can customize the route prefix and middleware in this file.
Usage
To send a CSP violation report, make a POST request to the configured URI (default is /csp-reporting/report). The report should be in JSON format. Example:
All versions of csp-reporting with dependencies
illuminate/routing Version ^9|^10|^11
illuminate/support Version ^9|^10|^11