Skip to content

Commit

Permalink
CSP different policies per controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex committed Feb 21, 2016
1 parent cb913a3 commit 38c2d67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/FreshRSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@ private function loadStylesAndScripts() {
}

public static function preLayout() {
if (Minz_Request::controllerName() === 'stats') {
header("Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'");
} else {
header("Content-Security-Policy: default-src 'self'; child-src *; img-src * data:; media-src *");
switch (Minz_Request::controllerName()) {
case 'index':
header("Content-Security-Policy: default-src 'self'; child-src *; img-src * data:; media-src *");
break;
case 'stats':
header("Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'");
break;
default:
header("Content-Security-Policy: default-src 'self'");
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions app/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
if (function_exists('opcache_reset')) {
opcache_reset();
}
header("Content-Security-Policy: default-src 'self'");

define('BCRYPT_COST', 9);

Expand Down

0 comments on commit 38c2d67

Please sign in to comment.