Skip to content

Commit

Permalink
Disable CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed Nov 18, 2024
1 parent 3d7ba56 commit 9e60869
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ PROXY_FOR_OUTGOING_REQUESTS=null
# This is mainly used as a defense against cross-site scripting (XSS) attacks, in which
# an attacker is able to inject malicious code into the web app

CONTENT_SECURITY_POLICY=true
CONTENT_SECURITY_POLICY=false


# Leave the following configuration vars as is.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ ENV \
# CSP helps to prevent or minimize the risk of certain types of security threats.
# This is mainly used as a defense against cross-site scripting (XSS) attacks, in which
# an attacker is able to inject malicious code into the web app
CONTENT_SECURITY_POLICY=true \
CONTENT_SECURITY_POLICY=false \
# Leave the following configuration vars as is.
# Unless you like to tinker and know what you're doing.
BROADCAST_DRIVER=log \
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Middleware/AddContentSecurityPolicyHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class AddContentSecurityPolicyHeaders
*/
public function handle(Request $request, Closure $next) : Response
{
if (config('2fauth.config.contentSecurityPolicy')) {
Vite::useCspNonce();
// if (config('2fauth.config.contentSecurityPolicy')) {
// Vite::useCspNonce();

return $next($request)->withHeaders([
'Content-Security-Policy' => "script-src 'nonce-" . Vite::cspNonce() . "';style-src 'self' 'unsafe-inline';connect-src 'self';img-src 'self' data:;object-src 'none';",
]);
}
// return $next($request)->withHeaders([
// 'Content-Security-Policy' => "script-src 'nonce-" . Vite::cspNonce() . "';style-src 'self' 'unsafe-inline';connect-src 'self';img-src 'self' data:;object-src 'none';",
// ]);
// }

return $next($request);
}
Expand Down
2 changes: 1 addition & 1 deletion config/2fauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'proxyLogoutUrl' => env('PROXY_LOGOUT_URL', null),
'appSubdirectory' => env('APP_SUBDIRECTORY', ''),
'authLogRetentionTime' => envUnlessEmpty('AUTHENTICATION_LOG_RETENTION', 365),
'contentSecurityPolicy' => envUnlessEmpty('CONTENT_SECURITY_POLICY', true),
'contentSecurityPolicy' => envUnlessEmpty('CONTENT_SECURITY_POLICY', false),
],

/*
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ services:
# CSP helps to prevent or minimize the risk of certain types of security threats.
# This is mainly used as a defense against cross-site scripting (XSS) attacks, in which
# an attacker is able to inject malicious code into the web app
- CONTENT_SECURITY_POLICY=true
- CONTENT_SECURITY_POLICY=false
# Leave the following configuration vars as is.
# Unless you like to tinker and know what you're doing.
- BROADCAST_DRIVER=log
Expand Down

0 comments on commit 9e60869

Please sign in to comment.