|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Neuron\Mvc\Events; |
| 4 | + |
| 5 | +use Neuron\Events\IEvent; |
| 6 | + |
| 7 | +/** |
| 8 | + * Event fired when a request exceeds rate limit thresholds. |
| 9 | + * |
| 10 | + * This event is triggered by the RateLimitFilter when a client (identified |
| 11 | + * by IP address or other key) exceeds the configured rate limit for a route |
| 12 | + * or API endpoint. |
| 13 | + * |
| 14 | + * Use cases: |
| 15 | + * - Security monitoring and abuse detection |
| 16 | + * - Automatically block or throttle abusive IPs |
| 17 | + * - Alert administrators of potential DDoS attacks |
| 18 | + * - Track rate limit patterns and adjust thresholds |
| 19 | + * - Generate security reports for compliance |
| 20 | + * - Trigger CAPTCHA challenges for suspicious traffic |
| 21 | + * |
| 22 | + * @package Neuron\Mvc\Events |
| 23 | + */ |
| 24 | +class RateLimitExceededEvent implements IEvent |
| 25 | +{ |
| 26 | + /** |
| 27 | + * @param string $ip Client IP address that exceeded the limit |
| 28 | + * @param string $route Route or endpoint that was rate limited |
| 29 | + * @param int $limit Maximum requests allowed |
| 30 | + * @param int $window Time window in seconds |
| 31 | + * @param int $attempts Number of requests made in the window |
| 32 | + */ |
| 33 | + public function __construct( |
| 34 | + public readonly string $ip, |
| 35 | + public readonly string $route, |
| 36 | + public readonly int $limit, |
| 37 | + public readonly int $window, |
| 38 | + public readonly int $attempts |
| 39 | + ) |
| 40 | + { |
| 41 | + } |
| 42 | + |
| 43 | + public function getName(): string |
| 44 | + { |
| 45 | + return 'rate_limit.exceeded'; |
| 46 | + } |
| 47 | +} |
0 commit comments