From 68dbda3d6afa942f567f31a24922ceb3d353c8cc Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 6 Feb 2014 13:54:11 +0100 Subject: [PATCH] Import rack_attack.rb template from GitLab --- files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.example | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+), 0 deletions(-) create mode 100644 files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.example diff --git a/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.example b/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.example new file mode 100644 index 0000000..bc3234b --- /dev/null +++ b/files/gitlab-cookbooks/gitlab/templates/default/rack_attack.rb.example @@ -0,0 +1,18 @@ +# 1. Rename this file to rack_attack.rb +# 2. Review the paths_to_be_protected and add any other path you need protecting +# + +paths_to_be_protected = [ + "#{Rails.application.config.relative_url_root}/users/password", + "#{Rails.application.config.relative_url_root}/users/sign_in", + "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session.json", + "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session", + "#{Rails.application.config.relative_url_root}/users", + "#{Rails.application.config.relative_url_root}/users/confirmation" +] + +unless Rails.env.test? + Rack::Attack.throttle('protected paths', limit: 10, period: 60.seconds) do |req| + req.ip if paths_to_be_protected.include?(req.path) && req.post? + end +end -- libgit2 0.21.2