-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CSP] Conflict between bundles #1366
Comments
As far as I can tell there is an agreement to use a single value for nonce - style and script. Just browsing the code public function getNonce(string $usage): string
{
$nonce = $this->doGetNonce();
if ('script' === $usage) {
$this->scriptNonce = $nonce;
} elseif ('style' === $usage) {
$this->styleNonce = $nonce;
} else {
throw new \InvalidArgumentException('Invalid usage provided');
}
return $nonce;
} the only difference is that it sets the corresponding value in the header, something like this:
Since Turbo and Vite both use the same meta tag name for nonce, could you call both functions and use just one value: {# sets script-src in CSP header #}
{% csp_nonce('script') %}
{# sets style-src in CSP header #}
{# turbo and vite use this for script or style #}
<meta name="csp-nonce" content="{{ csp_nonce('style') }}"> |
You're a genius! But... this solved the issue only partially. So I investigated further and found this was wrong:
because this is only satisfying Turbo. In order to also satisfy Vite:
Since nobody noticed this in the description of my issue (symfony/symfony#59754), then maybe there should be some improvements made: |
Please see: symfony/symfony#59754
The text was updated successfully, but these errors were encountered: