CSP remove unrequired policies

This commit is contained in:
Jérémy Munsch 2023-02-22 14:46:02 +01:00
parent 74dc29781b
commit cdd69b66d0
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -32,7 +32,7 @@ class SecureHeaders
{
View::share('nonce', $nonce = \uniqid());
// * For VueJS dev tool to execute
$jsDev = config('app.debug') ? "'unsafe-eval' 'unsafe-inline'" : '';
$jsDev = config('app.debug') ? "'unsafe-eval' 'unsafe-inline'" : "'nonce-{$nonce}' 'strict-dynamic'";
$scheme = config('app.env') === 'local' ? 'http' : 'https';
$reportUri = Route::has('cspReportUri') ?
\sprintf(' report-uri %s ;', \parse_url(route('cspReportUri'), \PHP_URL_PATH)) : '';
@ -68,9 +68,8 @@ class SecureHeaders
// ! If you dont use ckeditor use this
// "style-src 'self' 'nonce-$nonce';",
// phpcs:ignore Generic.Files.LineLength.TooLong
"script-src 'self' {$jsDev} 'nonce-{$nonce}' " . \implode(' ', [
// '\'strict-dynamic\' https: blob:',
'\'strict-dynamic\' https: blob: \'unsafe-eval\'',
"script-src 'self' {$jsDev} " . \implode(' ', [
'https: blob:',
'https://www.googletagmanager.com',
'https://cdnjs.cloudflare.com',
"$scheme://www.google-analytics.com",