whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
312 stars 37 forks source link

The script doesnt work when csp is enabled #46

Open Doekos opened 4 months ago

Doekos commented 4 months ago

I would like to have the option to add a nonce to the script tag without having to override classes.

I've tried overriding the CookiesManager getDefaultScriptTag function to add a nonce, however for some reason I keep getting the $this->shouldDisplayNotice() as true when the Cookie is in my Storage with 'consent_at' filled.

But when I make these changes in the vendor file, it's working.

Any ideas/suggestions?

Doekos commented 3 months ago

Update:

I made a workaround; I have extended the CookiesManager class and overriden the getDefaultScriptTag() function with a 'nonce="' . csp_nonce() . '" '. It would've been made easier if this was just a configuration option.