removeUnwantedHeaders($this->unwantedHeaderList); $response = $next($request); $response->headers->set('Referrer-Policy', 'no-referrer-when-downgrade'); $response->headers->set('X-Content-Type-Options', 'nosniff'); $response->headers->set('X-XSS-Protection', '1; mode=block'); $response->headers->set('X-Frame-Options', 'SAMEORIGIN'); $response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;'); $cspPolicies = [ "default-src 'none';", "manifest-src 'self';", // * CKEDITOR Specific https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html "connect-src 'self' blob: " . implode(' ', [ // * VITE DEV config('app.debug') ? "wss://{$host}:4443" : '', config('app.debug') ? "https://{$host}:4443" : '', 'https://yl.s-web.fr' ]) . ';', "img-src 'self' data: blob: " . implode(' ', [ 'https://yl.s-web.fr', 'https://i3.ytimg.com/', // * VITE DEV config('app.debug') ? "https://{$host}:4443" : '', // * MESBR 'https://dev.mesbr.eu', 'https://www.mesbr.eu' ]) . ';', "object-src 'self' " . implode(' ', []) . ';', "frame-src 'self' " . implode(' ', [ 'https://www.youtube-nocookie.com', 'https://www.google.com/recaptcha/', 'https://recaptcha.google.com/recaptcha/', 'https://www.google.com/maps/', 'blob:' ]) . ';', "font-src 'self' data: " . \implode(' ', [ // * VITE DEV config('app.debug') ? "https://{$host}:4443" : '', 'https://fonts.gstatic.com;' ]) . ';', // ! Using CKEditor will must have unsafe-inline style // phpcs:ignore Generic.Files.LineLength.TooLong "style-src 'self' 'unsafe-inline' " . \implode(' ', [ 'https://cdnjs.cloudflare.com', // * File Manager 'https://fonts.googleapis.com', 'https://cdn.jsdelivr.net', 'https://use.fontawesome.com', 'https://fonts.googleapis.com', // * VITE DEV config('app.debug') ? "https://{$host}:4443" : '', ]) . ';', // ! If you dont use ckeditor use this // "style-src 'self' 'nonce-$nonce';", // phpcs:ignore Generic.Files.LineLength.TooLong "script-src 'self' {$jsDev} " . \implode(' ', [ 'https: blob:', 'https://www.googletagmanager.com', 'https://cdnjs.cloudflare.com', // * VITE DEV config('app.debug') ? "https://{$host}:4443" : '', ]) . ';' ]; $response->headers->set( 'Content-Security-Policy', implode(' ', $cspPolicies) . $reportUri ); $response->headers->set('Feature-Policy', 'fullscreen \'self\';'); return $response; } /** * Remove unwanted headers * * @param array $headerList * @return void */ private function removeUnwantedHeaders(array $headerList): void { foreach ($headerList as $header) { header_remove($header); } } }