fix: Use CSP_NONCE env variable in ContentSecurity Header

We should use 'cspNonceManager' for requesting the NONCE value, because it is doing the same as before, except that it honors a CPS_NONCE environment variable if available.

Signed-off-by: Holger Hees <holger.hees@gmail.com>
This commit is contained in:
Holger Hees 2024-02-14 13:32:21 +01:00 committed by Ferdinand Thiessen
parent 21db618174
commit 73397cd759
No known key found for this signature in database
GPG key ID: 45FAE7268762B400

View file

@ -53,7 +53,7 @@ class CSPMiddleware extends Middleware {
$defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy);
if ($this->cspNonceManager->browserSupportsCspV3()) {
$defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue());
$defaultPolicy->useJsNonce($this->cspNonceManager->getNonce());
}
$response->setContentSecurityPolicy($defaultPolicy);