diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /config/initializers/rack_attack_logging.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'config/initializers/rack_attack_logging.rb')
-rw-r--r-- | config/initializers/rack_attack_logging.rb | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/config/initializers/rack_attack_logging.rb b/config/initializers/rack_attack_logging.rb deleted file mode 100644 index 7b0a8f0d7dd..00000000000 --- a/config/initializers/rack_attack_logging.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true -# -# Adds logging for all Rack Attack blocks and throttling events. - -ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, request_id, payload| - req = payload[:request] - - case req.env['rack.attack.match_type'] - when :throttle, :blocklist, :track - rack_attack_info = { - message: 'Rack_Attack', - env: req.env['rack.attack.match_type'], - remote_ip: req.ip, - request_method: req.request_method, - path: req.fullpath, - matched: req.env['rack.attack.matched'] - } - - throttles_with_user_information = [ - :throttle_authenticated_api, - :throttle_authenticated_web, - :throttle_authenticated_protected_paths_api, - :throttle_authenticated_protected_paths_web - ] - - if throttles_with_user_information.include? req.env['rack.attack.matched'].to_sym - user_id = req.env['rack.attack.match_discriminator'] - user = User.find_by(id: user_id) - - rack_attack_info[:user_id] = user_id - rack_attack_info['meta.user'] = user.username unless user.nil? - end - - Gitlab::AuthLogger.error(rack_attack_info) - when :safelist - Gitlab::Instrumentation::Throttle.safelist = req.env['rack.attack.matched'] - end -end |