Skip to content

Commit e14bb16

Browse files
committed
Add logging for rack attack events
1 parent 0e0f1de commit e14bb16

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Add logging for rack attack events to production.log
3+
merge_request:
4+
author:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Adds logging for all Rack Attack blocks and throttling events.
2+
3+
ActiveSupport::Notifications.subscribe('rack.attack') do |name, start, finish, request_id, req|
4+
if [:throttle, :blacklist].include? req.env['rack.attack.match_type']
5+
Rails.logger.info("Rack_Attack: #{req.env['rack.attack.match_type']} #{req.ip} #{req.request_method} #{req.fullpath}")
6+
end
7+
end

0 commit comments

Comments
 (0)