diff options
author | Tim Rogers <tim@gocardless.com> | 2015-12-24 17:39:09 +0000 |
---|---|---|
committer | Tim Rogers <tim@gocardless.com> | 2015-12-29 13:07:51 +0000 |
commit | 32b1c90837570a69841e9ffccff513c74fb7a308 (patch) | |
tree | fe573189f19ecb5dc8e79b4462f264dce62313de /railties | |
parent | 468df261f8a123dec1d36b22136476ae3660e1fa (diff) | |
download | rails-32b1c90837570a69841e9ffccff513c74fb7a308.tar.gz rails-32b1c90837570a69841e9ffccff513c74fb7a308.tar.bz2 rails-32b1c90837570a69841e9ffccff513c74fb7a308.zip |
Flexible configuration for ActionDispatch::SSL
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application/default_middleware_stack.rb | 2 | ||||
-rw-r--r-- | railties/test/application/middleware/session_test.rb | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb index ed6a1f82d3..4f1cc0703d 100644 --- a/railties/lib/rails/application/default_middleware_stack.rb +++ b/railties/lib/rails/application/default_middleware_stack.rb @@ -68,7 +68,7 @@ module Rails middleware.use ::ActionDispatch::Cookies unless config.api_only if !config.api_only && config.session_store - if config.force_ssl && !config.session_options.key?(:secure) + if config.force_ssl && config.ssl_options.fetch(:secure_cookies, true) && !config.session_options.key?(:secure) config.session_options[:secure] = true end middleware.use config.session_store, config.session_options diff --git a/railties/test/application/middleware/session_test.rb b/railties/test/application/middleware/session_test.rb index 25eadfc387..f847e80471 100644 --- a/railties/test/application/middleware/session_test.rb +++ b/railties/test/application/middleware/session_test.rb @@ -20,12 +20,19 @@ module ApplicationTests @app ||= Rails.application end - test "config.force_ssl sets cookie to secure only" do + test "config.force_ssl sets cookie to secure only by default" do add_to_config "config.force_ssl = true" require "#{app_path}/config/environment" assert app.config.session_options[:secure], "Expected session to be marked as secure" end + test "config.force_ssl doesn't set cookie to secure only when changed from default" do + add_to_config "config.force_ssl = true" + add_to_config "config.ssl_options = { secure_cookies: false }" + require "#{app_path}/config/environment" + assert !app.config.session_options[:secure] + end + test "session is not loaded if it's not used" do make_basic_app |