mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-06-04 02:05:35 +00:00
🚀 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:
+16
-4
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user