Hi all.
Can someone point me in the right direction for creating a Content Security Policy on one of my C5 sites? I am able to do the basics of adding Google Fonts and that kind of stuff but where I get stuck is the inline styles and scripts. I was able to create a Nonce by doing this…
<?php $nonce = bin2hex(random_bytes(16)); // Generate a 32-character random hexadecimal nonce
$csp = "default-src 'self'; ";
$csp .= "script-src 'self' 'nonce-$nonce' https://www.googletagmanager.com; ";
$csp .= "style-src 'self' https://fonts.googleapis.com https://cdn.jsdelivr.net; ";
$csp .= "img-src 'self'; ";
$csp .= "font-src 'self' https://fonts.gstatic.com; ";
$csp .= "connect-src 'self' https://www.google-analytics.com; ";
header("Content-Security-Policy: $csp"); ?>
and then…
<script nonce="<?=$nonce?>">
...whatever
</script>
but there is this C5 created script right in the header that I am not sure how to add the nonce to…
<script type="text/javascript">
var CCM_DISPATCHER_FILENAME = "/index.php";
var CCM_CID = 1;
var CCM_EDIT_MODE = false;
var CCM_ARRANGE_MODE = false;
var CCM_IMAGE_PATH = "/concrete/images";
var CCM_APPLICATION_URL = "https://domain.com";
var CCM_REL = "";
var CCM_ACTIVE_LOCALE = "en_US";
var CCM_USER_REGISTERED = false;
</script>
additionally adding nonce=“<?=$nonce?>” within a custom block gives me an undefined variable error.
Any insight would be greatly appreciated.
C