Skip to content

Commit

Permalink
add CSP
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamfall committed Jan 11, 2024
1 parent df044bc commit bb4c995
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header

# Rails.application.configure do
# 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.configure do
config.content_security_policy do |policy|
policy.default_src :self, :https
policy.font_src :self, :https, :data
policy.img_src :self, :https, :data
policy.connect_src :self, :https, "ws://#{ENV["PUSHER_SOCKET_HOST"]}:#{ENV["PUSHER_WS_PORT"]}" if ENV["PUSHER_SOCKET_HOST"].present?
policy.object_src :none
policy.script_src :self, "cdn.ckeditor.com", "www.clarity.ms", :unsafe_inline, :unsafe_eval, :https
policy.style_src :self, "cdn.ckeditor.com", :https, :unsafe_inline
# Specify URI for violation reports
# policy.report_uri "/csp-violation-report-endpoint"
end
#
# # Generate session nonces for permitted importmap and inline scripts
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src)
#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end
end

0 comments on commit bb4c995

Please sign in to comment.