mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +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,12 +13,11 @@ module Rack
|
||||||
count = cache.count("#{key_prefix}:count:#{discriminator}", findtime)
|
count = cache.count("#{key_prefix}:count:#{discriminator}", findtime)
|
||||||
if count >= maxretry
|
if count >= maxretry
|
||||||
ban!(discriminator, bantime)
|
ban!(discriminator, bantime)
|
||||||
true
|
end
|
||||||
else
|
# we may not block them this time, but they're banned for next time
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ describe 'Rack::Attack.Allow2Ban' do
|
||||||
get '/?foo=OMGHAX', {}, 'REMOTE_ADDR' => '1.2.3.4'
|
get '/?foo=OMGHAX', {}, 'REMOTE_ADDR' => '1.2.3.4'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails' do
|
it 'succeeds' do
|
||||||
last_response.status.must_equal 401
|
last_response.status.must_equal 200
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'increases fail count' do
|
it 'increases fail count' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue