Merge pull request #8284 from demarches-simplifiees/feature/rate_limiting_prefill_api

Add prefill api to rack_attack
This commit is contained in:
LeSim 2023-01-11 16:47:47 +01:00 committed by GitHub
commit 6f2912b4db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,12 @@ class Rack::Attack
end
end
throttle('/api/public/v1/dossiers/ip', limit: 5, period: 20.seconds) do |req|
if req.path == '/api/public/v1/dossiers' && req.post? && rack_attack_enabled?
req.remote_ip
end
end
Rack::Attack.safelist('allow from localhost') do |req|
IPService.ip_trusted?(req.remote_ip)
end