mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-06-04 02:05:35 +00:00
5f28bfedd4
- **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.
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Services\SecurityMonitor;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
use Sentry\Laravel\Integration;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
web: __DIR__.'/../routes/web.php',
|
|
api: __DIR__.'/../routes/api.php',
|
|
commands: __DIR__.'/../routes/console.php',
|
|
channels: __DIR__.'/../routes/channels.php',
|
|
health: '/up',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware) {
|
|
$middleware->api(prepend: [
|
|
ThrottleRequests::class.':api',
|
|
]);
|
|
})
|
|
->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);
|
|
|
|
if ($monitor->shouldRecord($e)) {
|
|
$monitor->recordFromException($e);
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
Integration::handles($exceptions);
|
|
})->create();
|