🚀 Enhance authorization and exception handling across Livewire components and SecurityMonitor

- **SecurityMonitor:** Added logic to record and prevent logging of locked-property exceptions, while ensuring non-security exceptions are properly forwarded.
- **Livewire `Members/Admin`:** Centralized authorization logic in private methods, enforced access control on actions, and moved allowed pubkeys to class constant for maintainability.
- **Livewire `News`:** Enforced authorization for editing and deleting news with guard methods and ensured unauthorized users can't access data.
- **Bootstrap exceptions:** Implemented custom exception handling to record Livewire-related security issues while preventing redundant logs.
- Updated tests with new behavior verification covering access control and exception responses.
This commit is contained in:
HolgerHatGarKeineNode
2026-06-02 19:23:51 +02:00
parent 59bc440a59
commit 5f28bfedd4
6 changed files with 251 additions and 34 deletions
+16 -4
View File
@@ -20,10 +20,22 @@ return Application::configure(basePath: dirname(__DIR__))
ThrottleRequests::class.':api',
]);
})
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
->withExceptions(function (Exceptions $exceptions): void {
// Record Livewire tampering exceptions, then return false to stop them
// reaching Sentry/Nightwatch/log. Must run before Integration::handles()
// (callbacks fire in order; false short-circuits the rest). dontReport()
// is unusable here — it short-circuits before the recording would run.
$exceptions->report(function (Throwable $e): bool {
$monitor = app(SecurityMonitor::class);
$exceptions->report(function (Throwable $e) {
app(SecurityMonitor::class)->recordFromException($e);
if ($monitor->shouldRecord($e)) {
$monitor->recordFromException($e);
return false;
}
return true;
});
Integration::handles($exceptions);
})->create();