eBooru/config/initializers/content_security_policy.rb

34 lines
1.6 KiB
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
2022-10-10 07:22:35 -04:00
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
2022-10-10 07:22:35 -04:00
Rails.application.configure do
config.content_security_policy do |policy|
policy.default_src :self
policy.script_src :self, "ads.dragonfru.it", "https://www.google.com/recaptcha/", "https://www.gstatic.com/recaptcha/", "https://www.recaptcha.net/"
2022-10-10 07:22:35 -04:00
policy.style_src :self, :unsafe_inline
policy.connect_src :self, "ads.dragonfru.it", "plausible.dragonfru.it"
2022-10-10 07:22:35 -04:00
policy.object_src :self, 'static1.e621.net', 'static1.e926.net'
policy.media_src :self, 'static1.e621.net', 'static1.e926.net'
policy.frame_ancestors :none
policy.frame_src 'https://www.google.com/recaptcha/', 'https://www.recaptcha.net/'
policy.font_src :self
policy.img_src :self, :data, 'static1.e621.net', 'static1.e926.net', 'ads.dragonfru.it'
policy.child_src :none
2024-11-06 23:14:25 -05:00
policy.form_action :self, 'discord.e621.net', 'discord.com'
2022-10-10 07:22:35 -04:00
# Specify URI for violation reports
# policy.report_uri "/csp-violation-report-endpoint"
end
2022-10-10 07:22:35 -04:00
# Generate session nonces for permitted importmap and inline scripts
config.content_security_policy_nonce_generator = ->(request) { SecureRandom.base64(16) }
config.content_security_policy_nonce_directives = %w(script-src)
2022-10-10 07:22:35 -04:00
# Report violations without enforcing the policy.
config.content_security_policy_report_only = false
end