annotate config/initializers/content_security_policy.rb @ 506:b5c6fd96100b default tip

Readd the field error proc config
author nanaya <me@nanaya.net>
date Mon, 16 Dec 2024 01:46:09 +0900
parents 92929378413e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
459
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
1 # Be sure to restart your server when you modify this file.
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
2
495
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
3 # Define an application-wide content security policy.
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
4 # See the Securing Rails Applications Guide for more information:
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
5 # https://guides.rubyonrails.org/security.html#content-security-policy-header
459
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
6
485
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
7 # Rails.application.configure do
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
8 # config.content_security_policy do |policy|
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
9 # policy.default_src :self, :https
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
10 # policy.font_src :self, :https, :data
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
11 # policy.img_src :self, :https, :data
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
12 # policy.object_src :none
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
13 # policy.script_src :self, :https
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
14 # policy.style_src :self, :https
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
15 # # Specify URI for violation reports
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
16 # # policy.report_uri "/csp-violation-report-endpoint"
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
17 # end
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
18 #
495
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
19 # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
485
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
20 # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
495
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
21 # config.content_security_policy_nonce_directives = %w(script-src style-src)
485
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
22 #
495
92929378413e Update to latest rails
nanaya <me@nanaya.net>
parents: 485
diff changeset
23 # # Report violations without enforcing the policy.
485
6cac8fcf8164 Update to rails 7 (and ruby 3.1)
nanaya <me@nanaya.pro>
parents: 467
diff changeset
24 # # config.content_security_policy_report_only = true
459
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
25 # end