diff options
Diffstat (limited to 'app/controllers/concerns/one_trust_csp.rb')
-rw-r--r-- | app/controllers/concerns/one_trust_csp.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/controllers/concerns/one_trust_csp.rb b/app/controllers/concerns/one_trust_csp.rb new file mode 100644 index 00000000000..4e98ec586ca --- /dev/null +++ b/app/controllers/concerns/one_trust_csp.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module OneTrustCSP + extend ActiveSupport::Concern + + included do + content_security_policy do |policy| + next if policy.directives.blank? + + default_script_src = policy.directives['script-src'] || policy.directives['default-src'] + script_src_values = Array.wrap(default_script_src) | ["'unsafe-eval'", 'https://cdn.cookielaw.org https://*.onetrust.com'] + policy.script_src(*script_src_values) + + default_connect_src = policy.directives['connect-src'] || policy.directives['default-src'] + connect_src_values = Array.wrap(default_connect_src) | ['https://cdn.cookielaw.org'] + policy.connect_src(*connect_src_values) + end + end +end |