-
Notifications
You must be signed in to change notification settings - Fork 253
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
Set two csp headers (enforced and report only) #256
Comments
header = ContentSecurityPolicy.new(config, user_agent)
response.headers[header.name] = header.value I think doing this in config alone would be great addition. |
I think adding something like this would work well: SecureHeaders::Configuration.default do |config|
config.csp = { default_src: 'self' ... }
config.csp_report_only = { default_src: 'none' ... }
end |
I was just thinking about this. Specifically, should there be a flag to indicate which policy the override is meant for (that defaults to both)? SecureHeaders::Configuration.default do |config|
config.csp = {
default_src: ['none'],
script_src: %w(example.com anotherexample.com)
}
config.csp_report_only = config.csp.merge {
script_src: %w(example.com) # more restrictive, fewer hosts
}
end Somewhere in a controller... append_content_security_policy_directives(:script_src, ['thirdparty.com'], :enforced)
override_content_security_policy_directives(:script_src, ['none'], :report_only) Would result in
|
fyi there's a PR for this #281 |
Is there a way using secure headers, to set both an enforced and report only header? A lot of people might want to do this in order to experiment with a different policy configuration and see what violation may occur before actually enforcing it.
The text was updated successfully, but these errors were encountered: