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 sri #1233

Merged
merged 3 commits into from
Aug 9, 2017
Merged

Add sri #1233

merged 3 commits into from
Aug 9, 2017

Conversation

h-lame
Copy link
Contributor

@h-lame h-lame commented May 17, 2017

For: https://trello.com/c/b3FnLalV/148-enable-subresource-integrity-sri-on-frontend-s

This only adds SRI attributes to the assets delivered as part of frontend itself; JS and CSS delivered by templates included from static require SRI to be added by static itself (see: alphagov/static#1008 for work in this area).

Local testing can be achieved by setting config.assets.debug = false in config/development.rb as sprockets-rails doesn't do integrity calculations in dev mode otherwise.

@h-lame
Copy link
Contributor Author

h-lame commented May 19, 2017

Flagging as DNM while we investigate an issue with older versions of firefox (see https://github.com/alphagov/government-frontend#368)

@h-lame h-lame changed the title Add sri [DO NOT MERGE] Add sri May 19, 2017
@h-lame
Copy link
Contributor Author

h-lame commented May 22, 2017

See alphagov/govuk_template#308 and alphagov/govuk_template#301 for discussion on impact. We're holding off on SRI until there are fewer users using the version of Firefox that has an issue with calculating SRI.

h-lame added 3 commits August 8, 2017 15:43
We want a version that targets sprockets 3 and also provides support for
calculating sub-resource integrity (SRI) attributes on linked assets.
We rely on sprockets-rails to do the heavy lifting for us here and
calculate the integrity sha for these assets.  We also add th ecrossorigin
attribute set to 'anonymous' because our assets are served from a
different domain to the main application (assets.publishing.service.gov.uk
vs www.gov.uk in most cases) and so to avoid dealing with CORS we tell the
browser to not send CORS headers with the request for the asset.
This brings with it sprockets-rails 3.x compatibility by adding hogan.js
to assets.precompile.  This may only be a problem on development as we
only make the render_mustache call in that rails env.
@h-lame h-lame changed the title [DO NOT MERGE] Add sri Add sri Aug 8, 2017
@h-lame
Copy link
Contributor Author

h-lame commented Aug 8, 2017

Removed DNM and rebased, this is ready to go now as we've solved the issue with SRI on firefox (see https://trello.com/c/UcJJBH0k/183-investigate-bom-issue-with-asset-compilation) and are slowly rolling SRI out across our apps.

@h-lame h-lame merged commit 45bb23b into master Aug 9, 2017
@h-lame h-lame deleted the add-sri branch August 9, 2017 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants