mirror of https://github.com/rails/rails
Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies`
This commit is contained in:
parent
689b277733
commit
1e70d0f5d3
|
@ -1,3 +1,7 @@
|
|||
* Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Deprecate `config.action_dispatch.return_only_request_media_type_on_content_type`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
|
|
@ -64,9 +64,9 @@ module ActionDispatch
|
|||
elsif custom_proxies.respond_to?(:any?)
|
||||
custom_proxies
|
||||
else
|
||||
ActionDispatch.deprecator.warn(<<~EOM)
|
||||
Setting config.action_dispatch.trusted_proxies to a single value has
|
||||
been deprecated. Please set this to an enumerable instead. For
|
||||
raise(ArgumentError, <<~EOM)
|
||||
Setting config.action_dispatch.trusted_proxies to a single value isn't
|
||||
supported. Please set this to an enumerable instead. For
|
||||
example, instead of:
|
||||
|
||||
config.action_dispatch.trusted_proxies = IPAddr.new("10.0.0.0/8")
|
||||
|
@ -75,10 +75,8 @@ module ActionDispatch
|
|||
|
||||
config.action_dispatch.trusted_proxies = [IPAddr.new("10.0.0.0/8")]
|
||||
|
||||
Note that unlike passing a single argument, passing an enumerable
|
||||
will *replace* the default set of trusted proxies.
|
||||
Note that passing an enumerable will *replace* the default set of trusted proxies.
|
||||
EOM
|
||||
Array(custom_proxies) + TRUSTED_PROXIES
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ Please refer to the [Changelog][action-pack] for detailed changes.
|
|||
|
||||
* Remove deprecated behavior on `Request#content_type`
|
||||
|
||||
* Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies`.
|
||||
|
||||
### Deprecations
|
||||
|
||||
* Deprecate `config.action_dispatch.return_only_request_media_type_on_content_type`.
|
||||
|
|
|
@ -84,14 +84,13 @@ module ApplicationTests
|
|||
end
|
||||
|
||||
test "setting trusted proxies to a single value (deprecated) adds value to default trusted proxies" do
|
||||
make_basic_app do |app|
|
||||
app.config.action_dispatch.trusted_proxies = IPAddr.new("4.2.42.0/24")
|
||||
exception = assert_raises(ArgumentError) do
|
||||
make_basic_app do |app|
|
||||
app.config.action_dispatch.trusted_proxies = IPAddr.new("4.2.42.0/24")
|
||||
end
|
||||
end
|
||||
|
||||
assert_deprecated(/Setting config\.action_dispatch\.trusted_proxies to a single value/, ActionDispatch.deprecator) do
|
||||
assert_equal "1.1.1.1",
|
||||
remote_ip("REMOTE_ADDR" => "1.1.1.1", "HTTP_X_FORWARDED_FOR" => "10.0.0.0,4.2.42.42")
|
||||
end
|
||||
assert_match(/Setting config\.action_dispatch\.trusted_proxies to a single value/, exception.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue