]> cat aescling's git repositories - mastodon.git/commitdiff
Override Rack::Request to use the same trusted proxy settings as Rails
authorEugen Rochko <eugen@zeonfederated.com>
Sun, 22 Jan 2017 20:01:28 +0000 (21:01 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 22 Jan 2017 20:01:28 +0000 (21:01 +0100)
config/initializers/trusted_proxies.rb [new file with mode: 0644]

diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb
new file mode 100644 (file)
index 0000000..27e9ee0
--- /dev/null
@@ -0,0 +1,7 @@
+module Rack
+  class Request
+    def trusted_proxy?(ip)
+      Rails.application.config.action_dispatch.trusted_proxies.any? { |proxy| proxy === ip }
+    end
+  end
+end