[deploy] Track Client IPs to Help Block Bad Actors (#7730)
This commit is contained in:
parent
64f584fffd
commit
f190f4c6c0
2 changed files with 15 additions and 0 deletions
|
|
@ -28,4 +28,10 @@ class Rack::Attack
|
|||
request.env["HTTP_FASTLY_CLIENT_IP"].to_s
|
||||
end
|
||||
end
|
||||
|
||||
track("request_tracking") do |request|
|
||||
if request.env["HTTP_FASTLY_CLIENT_IP"].present?
|
||||
Honeycomb.add_field("fastly_client_ip", request.env["HTTP_FASTLY_CLIENT_IP"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -96,4 +96,13 @@ describe Rack::Attack, type: :request, throttle: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "request_tracking" do
|
||||
it "adds fastly client IP to Honeycomb span" do
|
||||
allow(Honeycomb).to receive(:add_field)
|
||||
get api_articles_path, headers: { "HTTP_FASTLY_CLIENT_IP" => "5.6.7.8" }
|
||||
|
||||
expect(Honeycomb).to have_received(:add_field).with("fastly_client_ip", "5.6.7.8")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue