PHP code example of silverstripeltd / silverstripe-csp
1. Go to this page and download the library: Download silverstripeltd/silverstripe-csp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silverstripeltd / silverstripe-csp example snippets
class ContentSecurityPolicy extends Basic
{
public function configure(): void
{
parent::configure();
}
}
class YouTube implements Fragment
{
public static function addTo(Policy $policy): void
{
$policy
->addDirective(Directive::SCRIPT, [
'www.youtube.com',
's.ytimg.com',
])
->addDirective(Directive::FRAME, "*.youtube.com");
}
}
public function configure(): void
{
parent::configure();
$this->addFragments([YouTube::class]);
}
public function configure(): void
{
parent::configure();
if (Director::isDev()) {
$this->reportOnly();
}
}