Skip to content

Commit

Permalink
Enable rack attack and add a throttle.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlazio committed Sep 25, 2013
1 parent 66c7eed commit c562d29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,8 @@ class Application < Rails::Application
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT']
#
# config.relative_url_root = "/gitlab"

# Enable rack attack middleware
config.middleware.use Rack::Attack
end
end
3 changes: 3 additions & 0 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rack::Attack.throttle('user logins, registration and password reset', limit: 6, period: 60.seconds) do |req|
req.ip if ["/users/password", "/users/sign_in", "/users"].include?(req.path) && req.post?
end

0 comments on commit c562d29

Please sign in to comment.