annotate config/initializers/content_security_policy.rb @ 467:fd3078b4d355

Update to latest rails
author nanaya <me@nanaya.pro>
date Tue, 22 Oct 2019 16:17:30 +0900
parents 07d6c6639adf
children 6cac8fcf8164
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
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
3 # Define an application-wide content security policy
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
4 # For further information see the following documentation
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
5 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
6
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
7 # Rails.application.config.content_security_policy do |policy|
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
8 # policy.default_src :self, :https
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
9 # policy.font_src :self, :https, :data
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
10 # policy.img_src :self, :https, :data
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
11 # policy.object_src :none
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
12 # policy.script_src :self, :https
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
13 # policy.style_src :self, :https
467
fd3078b4d355 Update to latest rails
nanaya <me@nanaya.pro>
parents: 459
diff changeset
14 # # If you are using webpack-dev-server then specify webpack-dev-server host
fd3078b4d355 Update to latest rails
nanaya <me@nanaya.pro>
parents: 459
diff changeset
15 # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
459
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
16
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
17 # # Specify URI for violation reports
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
18 # # policy.report_uri "/csp-violation-report-endpoint"
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
19 # end
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
20
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
21 # If you are using UJS then enable automatic nonce generation
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
22 # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
23
467
fd3078b4d355 Update to latest rails
nanaya <me@nanaya.pro>
parents: 459
diff changeset
24 # Set the nonce only to specific directives
fd3078b4d355 Update to latest rails
nanaya <me@nanaya.pro>
parents: 459
diff changeset
25 # Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
fd3078b4d355 Update to latest rails
nanaya <me@nanaya.pro>
parents: 459
diff changeset
26
459
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
27 # Report CSP violations to a specified URI
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
28 # For further information see the following documentation:
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
29 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
07d6c6639adf Upgrade to rails 5.2. RIP code style.
nanaya <me@nanaya.pro>
parents:
diff changeset
30 # Rails.application.config.content_security_policy_report_only = true