diff options
author | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-11-10 21:22:11 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-11-10 21:22:11 -0200 |
commit | 99dccf1aae31520b701fc37e62542db1e6c0994f (patch) | |
tree | 8150e2fcc49c7b1a778164aaf71fe584b0136fa1 /railties/lib | |
parent | 0ed6ebcf9095c65330d3950cfb6b75ba7ea78853 (diff) | |
parent | bda93b2bb272c34e46a5454d4658a0139b135e93 (diff) | |
download | rails-99dccf1aae31520b701fc37e62542db1e6c0994f.tar.gz rails-99dccf1aae31520b701fc37e62542db1e6c0994f.tar.bz2 rails-99dccf1aae31520b701fc37e62542db1e6c0994f.zip |
Merge branch 'rm-fix-secret-token-fallback'
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 18d9cb72d6..f8bd6096f2 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -178,7 +178,7 @@ module Rails key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000) ActiveSupport::CachingKeyGenerator.new(key_generator) else - ActiveSupport::LegacyKeyGenerator.new(config.secret_token) + ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token) end end @@ -248,7 +248,7 @@ module Rails super.merge({ "action_dispatch.parameter_filter" => config.filter_parameters, "action_dispatch.redirect_filter" => config.filter_redirect, - "action_dispatch.secret_token" => config.secret_token, + "action_dispatch.secret_token" => secrets.secret_token, "action_dispatch.secret_key_base" => secrets.secret_key_base, "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions, "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local, @@ -381,6 +381,8 @@ module Rails # Fallback to config.secret_key_base if secrets.secret_key_base isn't set secrets.secret_key_base ||= config.secret_key_base + # Fallback to config.secret_token if secrets.secret_token isn't set + secrets.secret_token ||= config.secret_token secrets end @@ -510,8 +512,13 @@ module Rails end def validate_secret_key_config! #:nodoc: - if secrets.secret_key_base.blank? && config.secret_token.blank? - raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`" + if secrets.secret_key_base.blank? + ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " + + "Read the upgrade documentation to learn more about this new config option." + + if secrets.secret_token.blank? + raise "Missing `secret_token` and `secret_key_base` for '#{Rails.env}' environment, set these values in `config/secrets.yml`" + end end end end |