mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-27 09:45:50 +00:00
fix edge case, if maxretry is 1, let them get 1 request in
This commit is contained in:
parent
ef59c5182a
commit
273e045f10
2 changed files with 4 additions and 5 deletions
|
|
@ -13,10 +13,9 @@ module Rack
|
|||
count = cache.count("#{key_prefix}:count:#{discriminator}", findtime)
|
||||
if count >= maxretry
|
||||
ban!(discriminator, bantime)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
# we may not block them this time, but they're banned for next time
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ describe 'Rack::Attack.Allow2Ban' do
|
|||
get '/?foo=OMGHAX', {}, 'REMOTE_ADDR' => '1.2.3.4'
|
||||
end
|
||||
|
||||
it 'fails' do
|
||||
last_response.status.must_equal 401
|
||||
it 'succeeds' do
|
||||
last_response.status.must_equal 200
|
||||
end
|
||||
|
||||
it 'increases fail count' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue