kingsoft / csp-builder
Content Security Policy builder for PHP
1.1.0
2023-03-31 08:54 UTC
This package is auto-updated.
Last update: 2024-11-06 20:20:53 UTC
README
Generate a CSP header
Installation
This project using composer.
composer require kingsoft/csp-builder
Usage
<?php use CSP\CspBuilder; $csp = (new CspBuilder()) ->addCspPolicy('script-src', CspBuilder::SELF) ->addCspPolicy('script-src', CspBuilder::NONCE) ->addCspPolicyNonce('script-src') ->setCspHeader(); define('NONCE', $csp-> getNonce()); <script nonce="<?= NONCE ?>"> </script>