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

Enable Rails 5 content_security_policy for js snippet #809

Merged
merged 4 commits into from
Jan 30, 2019

Conversation

waltjones
Copy link
Contributor

@waltjones waltjones commented Jan 23, 2019

Issue #698

Rails 5.2 has built in support for CSP: https://edgeguides.rubyonrails.org/security.html#content-security-policy

Apps that want to enable CSP have two choices for inline JS, such as the rollbar js snippet:

  1. Set the 'unsafe-inline' policy, which is global and removes security for inline JS, or
  2. Use a nonce, which Rails CSP supports, but requires the snippet to use the nonce.

This PR supports both options by only including the nonce when expected.

Copy link
Contributor

@rokob rokob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@waltjones waltjones merged commit 1411068 into master Jan 30, 2019
@waltjones waltjones deleted the wj-rails5-csp branch March 8, 2019 18:44
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