diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-21 16:50:11 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-21 16:52:49 +0100 |
commit | fc4f237864541f5012f9b8cc8e0ec81960377e55 (patch) | |
tree | af89be8dd26fe96044d4b9114f1cea1a4e6910cc /railties | |
parent | 04063393f9392b83cf5ccd0a16f217cc7261e15c (diff) | |
download | rails-fc4f237864541f5012f9b8cc8e0ec81960377e55.tar.gz rails-fc4f237864541f5012f9b8cc8e0ec81960377e55.tar.bz2 rails-fc4f237864541f5012f9b8cc8e0ec81960377e55.zip |
Make filter parameters based on request, so they can be modified for anything in the middleware stack.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/generators/rails/app/templates/config/application.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 7 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 4 |
4 files changed, 6 insertions, 8 deletions
diff --git a/railties/lib/generators/rails/app/templates/config/application.rb b/railties/lib/generators/rails/app/templates/config/application.rb index ecebbc6146..78a355d2f4 100644 --- a/railties/lib/generators/rails/app/templates/config/application.rb +++ b/railties/lib/generators/rails/app/templates/config/application.rb @@ -32,6 +32,6 @@ module <%= app_const_base %> # end # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters :password + config.filter_parameters << :password end end diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 743681359c..5c9892c630 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -110,6 +110,7 @@ module Rails end def call(env) + env["action_dispatch.parameter_filter"] = config.filter_parameters app.call(env) end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index c7331f79c5..7f1783a6b9 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -69,7 +69,7 @@ module Rails class Configuration < Railtie::Configuration attr_accessor :after_initialize_blocks, :cache_classes, :colorize_logging, - :consider_all_requests_local, :dependency_loading, + :consider_all_requests_local, :dependency_loading, :filter_parameters, :load_once_paths, :logger, :metals, :plugins, :preload_frameworks, :reload_plugins, :serve_static_assets, :time_zone, :whiny_nils @@ -83,6 +83,7 @@ module Rails super @load_once_paths = [] @after_initialize_blocks = [] + @filter_parameters = [] @dependency_loading = true @serve_static_assets = true end @@ -252,10 +253,6 @@ module Rails i18n end end - - def filter_parameters(*filter_words, &block) - ActionDispatch::Request.filter_parameters(*filter_words, &block) - end def environment_path "#{root}/config/environments/#{Rails.env}.rb" diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 8c08fe5acc..6968e87986 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -125,9 +125,9 @@ module ApplicationTests test "filter_parameters should be able to set via config.filter_parameters" do add_to_config <<-RUBY - config.filter_parameters :foo, 'bar' do |key, value| + config.filter_parameters += [ :foo, 'bar', lambda { |key, value| value = value.reverse if key =~ /baz/ - end + }] RUBY assert_nothing_raised do |