]> git.openstreetmap.org Git - rails.git/blob - config/initializers/secure_headers.rb
bb901e3759430cb365f8bcd44407776ec199cf06
[rails.git] / config / initializers / secure_headers.rb
1 if defined?(CSP_REPORT_URL)
2   csp_policy = {
3     :default_src => %w['self'],
4     :child_src => %w['self'],
5     :connect_src => %w['self'],
6     :font_src => %w['none'],
7     :form_action => %w['self'],
8     :frame_ancestors => %w['self'],
9     :frame_src => %w['self'],
10     :img_src => %w['self' data: www.gravatar.com *.wp.com *.tile.openstreetmap.org *.tile.thunderforest.com *.openstreetmap.fr],
11     :media_src => %w['none'],
12     :object_src => %w['self'],
13     :plugin_types => %w[],
14     :script_src => %w['self'],
15     :style_src => %w['self'],
16     :report_uri => [CSP_REPORT_URL]
17   }
18
19   csp_policy[:connect_src] << PIWIK["location"] if defined?(PIWIK)
20   csp_policy[:img_src] << PIWIK["location"] if defined?(PIWIK)
21   csp_policy[:script_src] << PIWIK["location"] if defined?(PIWIK)
22 else
23   csp_policy = SecureHeaders::OPT_OUT
24 end
25
26 cookie_policy = {
27   :secure => SecureHeaders::OPT_OUT,
28   :httponly => SecureHeaders::OPT_OUT
29 }
30
31 SecureHeaders::Configuration.default do |config|
32   config.hsts = SecureHeaders::OPT_OUT
33   config.csp = SecureHeaders::OPT_OUT
34   config.csp_report_only = csp_policy
35   config.cookies = cookie_policy
36 end