Remove deprecated ability to assign a single value to config.action_dispatch.trusted_proxies

This commit is contained in:
Rafael Mendonça França 2023-01-16 23:06:39 +00:00
parent 689b277733
commit 1e70d0f5d3
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
4 changed files with 15 additions and 12 deletions

@ -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 @@ def initialize(app, ip_spoofing_check = true, custom_proxies = nil)
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 @@ def initialize(app, ip_spoofing_check = true, custom_proxies = nil)
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 @@ def remote_ip(env = {})
end
test "setting trusted proxies to a single value (deprecated) adds value to default trusted proxies" do
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