aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-02-25 21:59:36 -0300
committerRafael França <rafaelmfranca@gmail.com>2016-02-25 21:59:36 -0300
commit0e24fcc5eb9591edb0236d33602445f6c0fc90ff (patch)
treec6a261508772e64a934ebfe12b299a350507768f /actionpack/lib/action_dispatch
parent1cc96c2e5fe08bc69bd768febbb5e3150343aa30 (diff)
parent4e92fb2097073ba788acbca00a232d07c8b14633 (diff)
downloadrails-0e24fcc5eb9591edb0236d33602445f6c0fc90ff.tar.gz
rails-0e24fcc5eb9591edb0236d33602445f6c0fc90ff.tar.bz2
rails-0e24fcc5eb9591edb0236d33602445f6c0fc90ff.zip
Merge pull request #23852 from prathamesh-sonpatki/hsts-subdomains
Enable HSTS with IncludeSubdomains header by default for new apps
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
index 735b5939dd..d6a0fe650c 100644
--- a/actionpack/lib/action_dispatch/middleware/ssl.rb
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -23,7 +23,7 @@ module ActionDispatch
# preload lists is `18.weeks`.
# * `subdomains`: Set to `true` to tell the browser to apply these settings
# to all subdomains. This protects your cookies from interception by a
- # vulnerable site on a subdomain. Defaults to `false`.
+ # vulnerable site on a subdomain. Defaults to `true`.
# * `preload`: Advertise that this site may be included in browsers'
# preloaded HSTS lists. HSTS protects your site on every visit *except the
# first visit* since it hasn't seen your HSTS header yet. To close this
@@ -57,6 +57,17 @@ module ActionDispatch
end
@secure_cookies = secure_cookies
+
+ if hsts != true && hsts != false && hsts[:subdomains].nil?
+ hsts[:subdomains] = false
+
+ ActiveSupport::Deprecation.warn <<-end_warning.strip_heredoc
+ In Rails 5.1, The `:subdomains` option of HSTS config will be treated as true if
+ unspecified. Set `config.ssl_options = { hsts: { subdomains: false }}` to opt out
+ of this behavior.
+ end_warning
+ end
+
@hsts_header = build_hsts_header(normalize_hsts_options(hsts))
end