summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-08-21 17:59:27 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-08-22 09:56:39 +0200
commit52e903e99f3b220553e65be7b6034dfbaeef6d81 (patch)
treeb3e33812cf1e49464cb7b46b5ae895c948c9fc12 /config/initializers
parente328668f2950636fe21e69b49d10d6ea1ae12da4 (diff)
downloadgitlab-ce-52e903e99f3b220553e65be7b6034dfbaeef6d81.tar.gz
Change rack attack example.
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/rack_attack.rb.example12
1 files changed, 10 insertions, 2 deletions
diff --git a/config/initializers/rack_attack.rb.example b/config/initializers/rack_attack.rb.example
index bc3234bf0b6..d093666561b 100644
--- a/config/initializers/rack_attack.rb.example
+++ b/config/initializers/rack_attack.rb.example
@@ -8,11 +8,19 @@ paths_to_be_protected = [
"#{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"
+ "#{Rails.application.config.relative_url_root}/users/confirmation",
+ "#{Rails.application.config.relative_url_root}/unsubscribes/*"
+
]
+paths_to_be_protected.map! { |path| Regexp.new(path) }
+
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?
+ if req.post?
+ paths_paths_to_be_protected.each do |protected_path|
+ req.ip if req.path =~ protected_path
+ end
+ end
end
end