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 committed Feb 21, 2024
1 parent 68667fe commit b9cf748
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 b9cf748

Please sign in to comment.