Add Google Analytics

https://www.pivotaltracker.com/story/show/115861923

Makes some changes to the content security policy, to allow
the Google Analytics JS and trakcing image to be loaded,
copied from @alexmuller’s excellent work on GOV.UK:

https://gdstechnology.blog.gov.uk/2015/02/12/experimenting-with-content-security-policy-on-gov-uk/
https://github.com/alphagov/frontend/pull/733
This commit is contained in:
Chris Hill-Scott
2016-03-18 14:49:53 +00:00
parent b8db00d4d9
commit 0cda624657
3 changed files with 10 additions and 2 deletions

View File

@@ -161,7 +161,7 @@ def useful_headers_after_request(response):
response.headers.add('X-Content-Type-Options', 'nosniff')
response.headers.add('X-XSS-Protection', '1; mode=block')
response.headers.add('Content-Security-Policy',
"default-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data:;") # noqa
"default-src 'self' 'unsafe-inline'; script-src 'self' *.google-analytics.com 'unsafe-inline' data:; object-src 'self'; font-src 'self' data:; img-src 'self' *.google-analytics.com data:;") # noqa
if 'Cache-Control' in response.headers:
del response.headers['Cache-Control']
response.headers.add(