]> git.openstreetmap.org Git - rails.git/blob - config/initializers/secure_headers.rb
Localisation updates from https://translatewiki.net.
[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     :img_src => %w['self' data: www.gravatar.com *.wp.com *.tile.openstreetmap.org *.tile.thunderforest.com *.openstreetmap.fr],
10     :media_src => %w['none'],
11     :object_src => %w['self'],
12     :plugin_types => %w[],
13     :script_src => %w['self'],
14     :style_src => %w['self' 'unsafe-inline'],
15     :report_uri => [CSP_REPORT_URL]
16   }
17
18   csp_policy[:img_src] << PIWIK["location"] if defined?(PIWIK)
19   csp_policy[:script_src] << PIWIK["location"] if defined?(PIWIK)
20 else
21   csp_policy = SecureHeaders::OPT_OUT
22 end
23
24 cookie_policy = {
25   :secure => SecureHeaders::OPT_OUT,
26   :httponly => SecureHeaders::OPT_OUT
27 }
28
29 SecureHeaders::Configuration.default do |config|
30   config.hsts = "max-age=0"
31   config.csp = SecureHeaders::OPT_OUT
32   config.csp_report_only = csp_policy
33   config.cookies = cookie_policy
34 end