87 lines
2.7 KiB
PHP
87 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Directive;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationCollection;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationMode;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\SourceKeyword;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\SourceScheme;
|
|
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\UriValue;
|
|
use TYPO3\CMS\Core\Type\Map;
|
|
|
|
return Map::fromEntries([
|
|
// Frontend CSP configuration for Action Network widget
|
|
Scope::frontend(),
|
|
new MutationCollection(
|
|
// Base security settings
|
|
new Mutation(
|
|
MutationMode::Set,
|
|
Directive::DefaultSrc,
|
|
SourceKeyword::self,
|
|
),
|
|
// Allow scripts from Action Network
|
|
new Mutation(
|
|
MutationMode::Extend,
|
|
Directive::ScriptSrc,
|
|
SourceKeyword::self,
|
|
new UriValue('https://actionnetwork.org'),
|
|
),
|
|
// Allow styles from Action Network
|
|
new Mutation(
|
|
MutationMode::Extend,
|
|
Directive::StyleSrc,
|
|
SourceKeyword::self,
|
|
new UriValue('https://actionnetwork.org'),
|
|
),
|
|
// Allow images from Action Network
|
|
new Mutation(
|
|
MutationMode::Extend,
|
|
Directive::ImgSrc,
|
|
SourceKeyword::self,
|
|
new UriValue('https://actionnetwork.org'),
|
|
),
|
|
),
|
|
|
|
// Backend configuration
|
|
Scope::backend(),
|
|
new MutationCollection(
|
|
// Results in `default-src 'self'`
|
|
new Mutation(
|
|
MutationMode::Set,
|
|
Directive::DefaultSrc,
|
|
SourceKeyword::self,
|
|
),
|
|
|
|
// Extends the ancestor directive ('default-src'),
|
|
// thus reuses 'self' and adds additional sources
|
|
// Results in `img-src 'self' data: https://*.typo3.org`
|
|
new Mutation(
|
|
MutationMode::Extend,
|
|
Directive::ImgSrc,
|
|
SourceScheme::data,
|
|
new UriValue('https://*.typo3.org'),
|
|
),
|
|
|
|
// Extends the ancestor directive ('default-src'),
|
|
// thus reuses 'self' and adds additional sources
|
|
// Results in `script-src 'self' 'nonce-[random]'`
|
|
new Mutation(
|
|
MutationMode::Extend,
|
|
Directive::ScriptSrc,
|
|
SourceKeyword::nonceProxy,
|
|
),
|
|
|
|
// Sets (overrides) the directive,
|
|
// thus ignores 'self' of the 'default-src' directive
|
|
// Results in `worker-src blob:`
|
|
new Mutation(
|
|
MutationMode::Set,
|
|
Directive::WorkerSrc,
|
|
SourceScheme::blob,
|
|
),
|
|
),
|
|
]);
|