Skip to content

Commit

Permalink
Fixed #14664 - allow additional urls in env for CSP
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed May 16, 2024
1 parent 7fdbbc8 commit ca1555d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Http/Middleware/SecurityHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public function handle($request, Closure $next)
$csp_policy[] = "connect-src 'self'";
$csp_policy[] = "object-src 'none'";
$csp_policy[] = "font-src 'self' data:";
$csp_policy[] = "img-src 'self' data: ".config('app.url').' '.env('PUBLIC_AWS_URL').' https://secure.gravatar.com http://gravatar.com maps.google.com maps.gstatic.com *.googleapis.com';
$csp_policy[] = "img-src 'self' data: ".config('app.url').' '.config('app.additional_csp_urls').' '.env('PUBLIC_AWS_URL').' https://secure.gravatar.com http://gravatar.com maps.google.com maps.gstatic.com *.googleapis.com';

if (config('filesystems.disks.public.driver') == 's3') {
$csp_policy[] = "img-src 'self' data: ".config('filesystems.disks.public.url');
}
$csp_policy = join(';', $csp_policy);

$response->headers->set('Content-Security-Policy', $csp_policy);
}

Expand Down
3 changes: 3 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@

'enable_csp' => env('ENABLE_CSP', true),

'additional_csp_urls' => env('ADDITIONAL_CSP_URLS', ''),



/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit ca1555d

Please sign in to comment.