nelmio / NelmioSecurityBundle

Adds extra security-related features in your Symfony application

Home Page:https://symfony.com/bundles/NelmioSecurityBundle/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nonce is empty unless dump using twig

vdeville opened this issue · comments

Hello,

Today i tested to add inline-nonce to all scripts. In Production mode no problem, but in dev mode if i not do {% dump(csp_nonce('script')) %} all the script have empty nonce

Do you have any idea about this problem ?

Thanks

Example in html:
Capture d’écran 2024-03-08 à 16 12 08
Incode:

<script type="text/javascript" nonce="{{ csp_nonce('script') }}" nonceTest="{{ csp_nonce('script') }}">

Do dump before this script in twig:

        {{ dump(csp_nonce('script')) }}
        <script type="text/javascript" nonce="{{ csp_nonce('script') }}" nonceTest="{{ csp_nonce('script') }}">

Result:
Capture d’écran 2024-03-08 à 16 14 02

This is normal https://stackoverflow.com/a/55673767/6512

You can check the view-source of the page to verify nonces, do not use the web inspector.

Thanks for your reply, i don't really understand why in dev or prod env some scripts was not loaded or loaded, for example in dev mode googlemap put eval error in javascript, not in production (same config, same loaded url etc)
Thanks