[deploy] Add Back Tracking API-keys in Honeycomb (#7868)
This commit is contained in:
parent
203e8e1ae7
commit
7dd249ac21
2 changed files with 3 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ class Rack::Attack
|
|||
return if request.env["HTTP_FASTLY_CLIENT_IP"].blank?
|
||||
|
||||
if request.path.starts_with?("/api/") && (request.put? || request.post? || request.delete?)
|
||||
Honeycomb.add_field("user_api_key", request.env["HTTP_API_KEY"])
|
||||
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ describe Rack::Attack, type: :request, throttle: true do
|
|||
expect(new_api_response).not_to eq(429)
|
||||
expect(Honeycomb).to have_received(:add_field).with("fastly_client_ip", "5.6.7.8").exactly(3).times
|
||||
expect(Honeycomb).to have_received(:add_field).with("fastly_client_ip", "1.1.1.1").exactly(2).times
|
||||
expect(Honeycomb).to have_received(:add_field).with("user_api_key", api_secret.secret).exactly(2).times
|
||||
expect(Honeycomb).to have_received(:add_field).with("user_api_key", another_api_secret.secret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue