mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: Don't reuse CSP nonce between anonymous requests
This commit is contained in:
committed by
David Taylor
parent
672f3e7e41
commit
0976c8fad6
@@ -64,8 +64,10 @@ module ApplicationHelper
|
||||
google_universal_analytics_json
|
||||
end
|
||||
|
||||
def self.google_tag_manager_nonce(env)
|
||||
env[:discourse_content_security_policy_nonce] ||= SecureRandom.hex
|
||||
def google_tag_manager_nonce_placeholder
|
||||
placeholder = "[[csp_nonce_placeholder_#{SecureRandom.hex}]]"
|
||||
response.headers["Discourse-GTM-Nonce-Placeholder"] = placeholder
|
||||
placeholder
|
||||
end
|
||||
|
||||
def shared_session_key
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<meta id="data-google-tag-manager"
|
||||
data-data-layer="<%= google_tag_manager_json %>"
|
||||
data-nonce="<%= ApplicationHelper.google_tag_manager_nonce(request.env) %>"
|
||||
data-nonce="<%= google_tag_manager_nonce_placeholder %>"
|
||||
data-container-id="<%= SiteSetting.gtm_container_id %>" />
|
||||
|
||||
<%= preload_script 'google-tag-manager' %>
|
||||
|
Reference in New Issue
Block a user