add Gem rack_attack for prevent attack brute-force
This commit is contained in:
parent
cab5b5cd9b
commit
fc8cebd78d
4 changed files with 26 additions and 0 deletions
21
config/initializers/rack_attack.rb
Normal file
21
config/initializers/rack_attack.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
if ENV['RAILS_ENV'] != 'test'
|
||||
class Rack::Attack
|
||||
throttle('logins/ip', limit: 5, period: 20.seconds) do |req|
|
||||
if req.path == '/users/sign_in' && req.post?
|
||||
req.ip
|
||||
end
|
||||
end
|
||||
|
||||
throttle('stats/ip', limit: 5, period: 20.seconds) do |req|
|
||||
if req.path == '/stats'
|
||||
req.ip
|
||||
end
|
||||
end
|
||||
|
||||
throttle('contact/ip', limit: 5, period: 20.seconds) do |req|
|
||||
if req.path == '/contact' && req.post?
|
||||
req.ip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue