Skip to content

Commit

Permalink
CSP: add additional restrictions (#854)
Browse files Browse the repository at this point in the history
object-src none and base-uri none are recommended by https://web.dev/articles/strict-csp

frame-ancestors none can be added since lib-jobs has no reason to be embedded in an iframe.
This is an additional protection, on top of our X-Frame-Options: SameOrigin
  • Loading branch information
sandbergja authored Oct 1, 2024
1 parent babb394 commit 69d764f
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy

# Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
# policy.script_src :self, :https
# policy.style_src :self, :https

# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# end

Rails.application.config.content_security_policy do |policy|
policy.script_src :self, :https, :unsafe_eval
policy.object_src :none
policy.base_uri :none
policy.frame_ancestors :none
end

# If you are using UJS then enable automatic nonce generation
Expand Down

0 comments on commit 69d764f

Please sign in to comment.