about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-04-10 01:20:18 +0200
committerGitHub <noreply@github.com>2018-04-10 01:20:18 +0200
commit80a944c882ddbca4d546d03503f0ccff15703484 (patch)
treee9ad0a59512b9bdb0059fdcf29cb7282574d705a
parent0c52654b5275fd0e7a0b544d3c6f895825e4a266 (diff)
Log rate limit hits (#7096)
Fix #7095
-rw-r--r--config/initializers/rack_attack_logging.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/config/initializers/rack_attack_logging.rb b/config/initializers/rack_attack_logging.rb
new file mode 100644
index 000000000..2ddbfb99c
--- /dev/null
+++ b/config/initializers/rack_attack_logging.rb
@@ -0,0 +1,4 @@
+ActiveSupport::Notifications.subscribe('rack.attack') do |_name, _start, _finish, _request_id, req|
+  next unless [:throttle, :blacklist].include? req.env['rack.attack.match_type']
+  Rails.logger.info("Rate limit hit (#{req.env['rack.attack.match_type']}): #{req.ip} #{req.request_method} #{req.fullpath}")
+end