Skip to content

Commit

Permalink
StyleWithNonce: Don't use nonce for cli commands
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab authored and nilmerg committed Apr 9, 2024
1 parent 68667fe commit a414129
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Compat/StyleWithNonce.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ipl\Web\Compat;

use Icinga\Application\Icinga;
use Icinga\Application\Version;
use Icinga\Util\Csp;
use ipl\Web\Style;
Expand All @@ -15,9 +16,10 @@ class StyleWithNonce extends Style
public function getNonce(): ?string
{
if ($this->nonce === null) {
$this->nonce = version_compare(Version::VERSION, '2.12.0', '>=')
? Csp::getStyleNonce() ?? ''
: '';
$this->nonce = '';
if (version_compare(Version::VERSION, '2.12.0', '>=') && Icinga::app()->isWeb()) {
$this->nonce = Csp::getStyleNonce() ?? '';
}
}

return parent::getNonce();
Expand Down

0 comments on commit a414129

Please sign in to comment.