1
0

rack_attack_logging.rb 374 B

123456789
  1. # frozen_string_literal: true
  2. ActiveSupport::Notifications.subscribe(/rack_attack/) do |_name, _start, _finish, _request_id, payload|
  3. req = payload[:request]
  4. next unless [:throttle, :blacklist].include? req.env['rack.attack.match_type']
  5. Rails.logger.info("Rate limit hit (#{req.env['rack.attack.match_type']}): #{req.ip} #{req.request_method} #{req.fullpath}")
  6. end