mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-06-05 01:15:36 +00:00
🛡️ **Add robust Livewire payload validation and throttling**
- ✅ Implemented handling for `CorruptComponentPayloadException` to prevent logging noise and improve exception management. - 🛠️ Added IP-based throttling (120 requests/min) for the `/livewire/update` endpoint with middleware integration for better traffic control. - ✅ Introduced unit tests to validate throttle settings and middleware application. - 🧪 Enhanced tests for ensuring silent handling of corrupt payload scenarios and reduced log noise.
This commit is contained in:
@@ -43,7 +43,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
Livewire::setUpdateRoute(function ($handle) {
|
||||
return Route::post('/livewire/update', $handle)
|
||||
->middleware(['web', Sample::rate(0)]);
|
||||
->middleware(['web', 'throttle:livewire', Sample::rate(0)]);
|
||||
});
|
||||
|
||||
Nightwatch::user(fn (Authenticatable $user) => [
|
||||
@@ -65,5 +65,15 @@ class AppServiceProvider extends ServiceProvider
|
||||
RateLimiter::for('calendar', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->ip());
|
||||
});
|
||||
|
||||
// Generous backstop for the shared `/livewire/update` endpoint. A single
|
||||
// active user stays far below this: the only sustained generator is the
|
||||
// login page's `wire:poll.4s` at ~15 req/min, plus interaction bursts.
|
||||
// 120/min leaves headroom for several users behind one NAT while still
|
||||
// capping abusive replay/scan traffic. Keyed by the real client IP
|
||||
// (trustProxies('*') resolves X-Forwarded-For).
|
||||
RateLimiter::for('livewire', function (Request $request) {
|
||||
return Limit::perMinute(120)->by($request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user