Add logging for rack attack events

This commit is contained in:
Brian Neel 2016-11-18 13:45:52 -05:00
parent 0e0f1dea08
commit e14bb160ac
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
title: Add logging for rack attack events to production.log
merge_request:
author:

View File

@ -0,0 +1,7 @@
# Adds logging for all Rack Attack blocks and throttling events.
ActiveSupport::Notifications.subscribe('rack.attack') do |name, start, finish, request_id, req|
if [:throttle, :blacklist].include? req.env['rack.attack.match_type']
Rails.logger.info("Rack_Attack: #{req.env['rack.attack.match_type']} #{req.ip} #{req.request_method} #{req.fullpath}")
end
end