secure_headers.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # frozen_string_literal: true
  2. # rubocop:disable Style/PercentLiteralDelimiters,Lint/PercentStringArray
  3. SecureHeaders::Configuration.default do |config|
  4. config.cookies = {
  5. secure: SecureHeaders::OPT_OUT, # mark all cookies as "Secure"
  6. httponly: SecureHeaders::OPT_OUT, # mark all cookies as "HttpOnly"
  7. samesite: {
  8. lax: true, # mark all cookies as SameSite=lax
  9. },
  10. }
  11. config.csp = {
  12. # FIXME: only enable localhost for development
  13. default_src: %w('self' http://localhost:3000 ws://localhost:3035 http://localhost:3035 https://kit-free.fontawesome.com),
  14. # FIXME: only enable unsafe-* for development
  15. script_src: %w('self' 'unsafe-eval' 'unsafe-inline' https://kit.fontawesome.com/589a3d92cd.js),
  16. }
  17. end
  18. # SecureHeaders::Configuration.default do |config|
  19. # config.cookies = {
  20. # secure: SecureHeaders::OPT_OUT, # mark all cookies as "Secure"
  21. # httponly: SecureHeaders::OPT_OUT, # mark all cookies as "HttpOnly"
  22. # samesite: {
  23. # lax: true, # mark all cookies as SameSite=lax
  24. # },
  25. # }
  26. # # Add "; preload" and submit the site to hstspreload.org for best protection.
  27. # config.hsts = "max-age=#{1.week.to_i}"
  28. # config.x_frame_options = 'DENY'
  29. # config.x_content_type_options = 'nosniff'
  30. # config.x_xss_protection = '1; mode=block'
  31. # config.x_download_options = 'noopen'
  32. # config.x_permitted_cross_domain_policies = 'none'
  33. # config.referrer_policy = %w(origin-when-cross-origin strict-origin-when-cross-origin)
  34. # config.csp = {
  35. # # "meta" values. these will shape the header, but the values are not included in the header.
  36. # # preserve_schemes: true, # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
  37. # # disable_nonce_backwards_compatibility: true, # default: false. If false, `unsafe-inline` will be added automatically when using nonces. If true, it won't. See #403 for why you'd want this.
  38. # # directive values: these values will directly translate into source directives
  39. # # default_src: %w('none'),
  40. # # FIXME: only enable localhost for development
  41. # default_src: %w('self' http://localhost:3000 ws://localhost:3035 http://localhost:3035),
  42. # # FIXME: only enable unsafe-* for development
  43. # script_src: %w('self' 'unsafe-eval' 'unsafe-inline'),
  44. # base_uri: %w('self'),
  45. # block_all_mixed_content: true, # see http://www.w3.org/TR/mixed-content/
  46. # child_src: %w('self'), # if child-src isn't supported, the value for frame-src will be set.
  47. # connect_src: %w(wss:),
  48. # font_src: %w('self' data:),
  49. # form_action: %w('self'),
  50. # frame_ancestors: %w('none'),
  51. # img_src: %w('self' data:),
  52. # manifest_src: %w('self'),
  53. # media_src: %w(),
  54. # object_src: %w('self'),
  55. # sandbox: true, # true and [] will set a maximally restrictive setting
  56. # plugin_types: %w(),
  57. # # script_src: %w('self'),
  58. # style_src: %w('self' 'unsafe-inline'),
  59. # worker_src: %w('self'),
  60. # upgrade_insecure_requests: true, # see https://www.w3.org/TR/upgrade-insecure-requests/
  61. # report_uri: %w(),
  62. # }
  63. # # This is available only from 3.5.0; use the `report_only: true` setting for 3.4.1 and below.
  64. # # config.csp_report_only = config.csp.merge(
  65. # # img_src: %w(),
  66. # # report_uri: %w(),
  67. # # )
  68. # end