diff options
author | Tristan Mahé <gled@remote-shell.net> | 2017-04-29 15:27:49 -0700 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-04-30 00:27:49 +0200 |
commit | 964035b1186a4dd66be0e0fb6cf56959e21c10e4 (patch) | |
tree | 33de5cc092aad77b4fcf5909f47fcd68a94eb763 /config | |
parent | 5135d609b774b177d3d3894b176a822d86b73d3c (diff) |
allow localhost to bypass the ratelimit (#2554)
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/rack_attack.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 67ec7c919..3ebe39462 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -1,6 +1,13 @@ # frozen_string_literal: true class Rack::Attack + # Always allow requests from localhost + # (blocklist & throttles are skipped) + Rack::Attack.safelist('allow from localhost') do |req| + # Requests are allowed if the return value is truthy + '127.0.0.1' == req.ip || '::1' == req.ip + end + # Rate limits for the API throttle('api', limit: 300, period: 5.minutes) do |req| req.ip if req.path =~ /\A\/api\/v/ |