5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-17 05:46:23 +00:00
panel/config/initializers/content_security_policy.rb
2020-11-05 19:19:02 -03:00

39 lines
1.6 KiB
Ruby

# 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
# XXX: Varios scripts generan estilos en línea
policy.style_src :self, :unsafe_inline
# Repetimos la default para poder saber cuál es la política en falta
policy.script_src :self
policy.font_src :self
# XXX: Los íconos de Trix se cargan vía data:
policy.img_src :self, :data, :https, :blob
# Ya no usamos applets!
policy.object_src :none
if Rails.env.development?
policy.connect_src :self,
'http://localhost:3035',
'ws://localhost:3035'
end
# Specify URI for violation reports
policy.report_uri "https://api.#{ENV.fetch('SUTTY_WITH_PORT', 'sutty.nl')}/v1/csp_reports.json"
end
# If you are using UJS then enable automatic nonce generation
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
# Set the nonce only to specific directives
# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
# Report CSP violations to a specified URI
# For further information see the following documentation:
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
Rails.application.config.content_security_policy_report_only = false