Enable strict CSP if configured
This commit is contained in:
parent
1cd1b500b3
commit
e3ebe109eb
|
@ -6,6 +6,7 @@ namespace Icinga\Web\Controller;
|
|||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Common\PdfExport;
|
||||
use Icinga\File\Pdf;
|
||||
use Icinga\Util\Csp;
|
||||
use Icinga\Web\View;
|
||||
use ipl\I18n\Translation;
|
||||
use Zend_Controller_Action;
|
||||
|
@ -171,6 +172,10 @@ class ActionController extends Zend_Controller_Action
|
|||
$this->redirectToLogin(Url::fromRequest());
|
||||
}
|
||||
|
||||
if (! $this->isXhr() && $this->Config()->get('security', 'use_strict_csp', false)) {
|
||||
Csp::createNonce();
|
||||
}
|
||||
|
||||
$this->view->tabs = new Tabs();
|
||||
$this->prepareInit();
|
||||
$this->init();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Util\Csp;
|
||||
use Zend_Controller_Response_Http;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Response\JsonResponse;
|
||||
|
@ -370,6 +372,10 @@ class Response extends Zend_Controller_Response_Http
|
|||
if ($redirectUrl !== null) {
|
||||
$this->setRedirect($redirectUrl->getAbsoluteUrl());
|
||||
}
|
||||
|
||||
if (Csp::getStyleNonce() && Config::app()->get('security', 'use_strict_csp', false)) {
|
||||
Csp::addHeader($this);
|
||||
}
|
||||
}
|
||||
|
||||
if (! $this->getHeader('Content-Type', true)) {
|
||||
|
|
Loading…
Reference in New Issue