-
Notifications
You must be signed in to change notification settings - Fork 95
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
How to add nonce for CSP? gtm4wp_get_the_gtm_tag filter is deprecated. #351
Comments
This filter was removed because it introduced some security risks. If you want to alter the container code in any way, you should turn off the container code in plugin options and add your own container code using the GTM4WP_WPACTION_AFTER_CONTAINER_CODE / gtm4wp_after_container_code filter which fires regardless of whether container code is turned on or off in plugin settings. Just make sure to output the full header script. |
Datalayer script is making it impossible to add to CSP as hash, as it is dynamically created and it's different on every page:
It is not the container itself, as it can be added to CSP as hash. |
I can of course. What about adding a filter like gtm4wp_get_csp_nonce and what is returned is added to the <script> tag? |
That would be great! |
I tried to help, so created a pull request here: #352 |
Please review this branch: 7faf339 |
Looking good @duracelltomi ! Thank you for your effort, this is indeed an improvement and a huge help to anyone who's using your plugin and dealing with CSP setup. |
@duracelltomi what's the status, would you like to release this update soon? |
I'm just finishing my vacation time, will do the release next week |
@duracelltomi just wanted to follow up, will the release be public soon? |
If nothing extreme happens, tomorrow. |
Something extreme must have happened! :) @duracelltomi |
Indeed, however 1.21 beta1 is now out, you can test it: |
Hello,
given the fact gtm4wp_get_the_gtm_tag filter is deprecated, we cannot add nonce to gtm4wp scripts and include in website Content Security Policy.
Why is this filter deprecated, do you plan to get it back in future releases, or do you recommend some other way of adding the gtm4wp scripts to CSP, apart from creating a hash for every single (dynamic) script?
The text was updated successfully, but these errors were encountered: