mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
version 2.3.0, update changelog, copy tweaks
This commit is contained in:
parent
b7ebb58bd9
commit
1d367f5acd
4 changed files with 10 additions and 7 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
# Changlog
|
# Changlog
|
||||||
|
|
||||||
|
## v2.3.0 - unlreleased (master)
|
||||||
|
* Allow throttle `limit` argument to be a proc. (thanks @lunks)
|
||||||
|
|
||||||
## v2.2.1 - 13 August 2013
|
## v2.2.1 - 13 August 2013
|
||||||
* Add license to gemspec
|
* Add license to gemspec
|
||||||
* Support ruby version 1.9.2
|
* Support ruby version 1.9.2
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ how the parameters work.
|
||||||
|
|
||||||
# You can also set a limit using a proc instead of a number. For
|
# You can also set a limit using a proc instead of a number. For
|
||||||
# instance, after Rack::Auth::Basic has authenticated the user:
|
# instance, after Rack::Auth::Basic has authenticated the user:
|
||||||
limit_based_on_proc = proc {|req| req.env["REMOTE_USER"] == "god" ? 100 : 1}
|
limit_based_on_proc = proc {|req| req.env["REMOTE_USER"] == "admin" ? 100 : 1}
|
||||||
Rack::Attack.throttle('req/ip', :limit => limit_based_on_proc, :period => 1.second) do |req|
|
Rack::Attack.throttle('req/ip', :limit => limit_based_on_proc, :period => 1.second) do |req|
|
||||||
req.ip
|
req.ip
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
module Rack
|
module Rack
|
||||||
module Attack
|
module Attack
|
||||||
VERSION = '2.2.1'
|
VERSION = '2.3.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ describe 'Rack::Attack.throttle with limit as proc' do
|
||||||
before do
|
before do
|
||||||
@period = 60 # Use a long period; failures due to cache key rotation less likely
|
@period = 60 # Use a long period; failures due to cache key rotation less likely
|
||||||
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
|
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
|
||||||
Rack::Attack.throttle('ip/sec', :limit => lambda {|env| 1}, :period => @period) { |req| req.ip }
|
Rack::Attack.throttle('ip/sec', :limit => lambda {|req| 1}, :period => @period) { |req| req.ip }
|
||||||
end
|
end
|
||||||
|
|
||||||
allow_ok_requests
|
allow_ok_requests
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue