From d3b24b8e66c659c46f3c7a6c6c53fc0b013c7eeb Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 14 Dec 2018 04:58:11 +0500 Subject: [PATCH] Configure Rack::Attack --- config/initializers/rack_attack.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index fa943c7..a3f3445 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -2,4 +2,8 @@ # Be sure to restart your server when you modify this file. -Rack::Attack.throttle 'requests by IP', limit: 10, period: 1, &:ip +Rack::Attack.throttle 'req/ip', limit: 120, period: 60, &:ip + +Rack::Attack.throttle 'user/email', limit: 20, period: 60 do |req| + req.params['email'].presence if req.post? && req.path.start_with?('/users') +end