Skip to content
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

Add two missing Google domains to Content Security Policy #153

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased

* Add www.googletagmanager.com and www.gstatic.com to Content Security Policy (https://github.com/alphagov/govuk_app_config/pull/153)

# 2.2.1

* Fix linting issues (https://github.com/alphagov/govuk_app_config/pull/149)
Expand Down
7 changes: 6 additions & 1 deletion lib/govuk_app_config/govuk_content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ module GovukContentSecurityPolicy

GOOGLE_ANALYTICS_DOMAINS = %w[www.google-analytics.com
ssl.google-analytics.com
stats.g.doubleclick.net].freeze
stats.g.doubleclick.net
www.googletagmanager.com].freeze

GOOGLE_STATIC_DOMAINS = %w[www.gstatic.com].freeze

def self.build_policy(policy)
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src
Expand All @@ -35,6 +38,7 @@ def self.build_policy(policy)
policy.script_src :self,
*GOVUK_DOMAINS,
*GOOGLE_ANALYTICS_DOMAINS,
*GOOGLE_STATIC_DOMAINS,
# Allow JSONP call to Verify to check whether the user is logged in
"www.signin.service.gov.uk",
# Allow YouTube Embeds (Govspeak turns YouTube links into embeds)
Expand All @@ -51,6 +55,7 @@ def self.build_policy(policy)
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
policy.style_src :self,
*GOVUK_DOMAINS,
*GOOGLE_STATIC_DOMAINS,
# We use the `style=""` attribute on some HTML elements
:unsafe_inline

Expand Down