Simplify Rack::Attack (#18403)

This commit is contained in:
Mac Siri 2022-08-31 16:58:34 -04:00 committed by GitHub
parent 560bff9403
commit 05f0e72c24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -43,11 +43,8 @@ module Rack
end
def self.track_and_return_ip(req)
ip_address = if ApplicationConfig["FASTLY_API_KEY"].present?
req.env["HTTP_FASTLY_CLIENT_IP"]
else
req.remote_ip
end
ip_address = req.env["HTTP_FASTLY_CLIENT_IP"] || req.remote_ip
return if ip_address.blank?
Honeycomb.add_field("fastly_client_ip", req.env["HTTP_FASTLY_CLIENT_IP"])

View file

@ -1,6 +1,6 @@
require "rails_helper"
describe Rack, ".attack", type: :request, throttle: true do
describe Rack::Attack, type: :request, throttle: true do
before do
cache_db = ActiveSupport::Cache.lookup_store(:redis_cache_store)
allow(Rails).to receive(:cache) { cache_db }