Disable Rack Attack throttling if admin disables it in config file
This commit is contained in:
parent
e7f6ab503a
commit
631511f80e
|
@ -20,8 +20,9 @@ paths_to_be_protected = [
|
|||
# Create one big regular expression that matches strings starting with any of
|
||||
# the paths_to_be_protected.
|
||||
paths_regex = Regexp.union(paths_to_be_protected.map { |path| /\A#{Regexp.escape(path)}/ })
|
||||
rack_attack_enabled = Gitlab.config.rack_attack.git_basic_auth['enabled']
|
||||
|
||||
unless Rails.env.test?
|
||||
unless Rails.env.test? || !rack_attack_enabled?
|
||||
Rack::Attack.throttle('protected paths', limit: <%= @rate_limit_requests_per_period %>, period: <%= @rate_limit_period %>.seconds) do |req|
|
||||
if req.post? && req.path =~ paths_regex
|
||||
req.ip
|
||||
|
|
Loading…
Reference in New Issue