mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
Change response body to 'Forbidden'
This commit is contained in:
parent
355a6fbce6
commit
1095f85242
2 changed files with 2 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ module Rack::Attack
|
||||||
|
|
||||||
# Set defaults
|
# Set defaults
|
||||||
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
|
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
|
||||||
@blacklisted_response ||= lambda {|env| [403, {}, ["Unauthorized\n"]] }
|
@blacklisted_response ||= lambda {|env| [403, {}, ["Forbidden\n"]] }
|
||||||
@throttled_response ||= lambda {|env|
|
@throttled_response ||= lambda {|env|
|
||||||
retry_after = env['rack.attack.match_data'][:period] rescue nil
|
retry_after = env['rack.attack.match_data'][:period] rescue nil
|
||||||
[429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
|
[429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]]
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ describe 'Rack::Attack' do
|
||||||
it "should return a blacklist response" do
|
it "should return a blacklist response" do
|
||||||
get '/', {}, 'REMOTE_ADDR' => @bad_ip
|
get '/', {}, 'REMOTE_ADDR' => @bad_ip
|
||||||
last_response.status.must_equal 403
|
last_response.status.must_equal 403
|
||||||
|
last_response.body.must_equal "Forbidden\n"
|
||||||
end
|
end
|
||||||
it "should tag the env" do
|
it "should tag the env" do
|
||||||
last_request.env['rack.attack.matched'].must_equal "ip #{@bad_ip}"
|
last_request.env['rack.attack.matched'].must_equal "ip #{@bad_ip}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue