Skip to content

Instantly share code, notes, and snippets.

@joachimesque
joachimesque / config.php
Created January 4, 2018 15:19
CSP headers with a script-src nonce directive for Kirby
<?php
/*
---------------------------------------
CSP
---------------------------------------
*/
$csp_nonce = base64_encode(random_bytes(20));
$csp_header = "Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-" . $csp_nonce . "';";
// set `csp-nonce` so it's accessable