TenantAtlas/apps/platform/app/Http/Middleware/SuppressDebugbarForSmokeRequests.php
ahmido acc8947384 feat: harden governance action semantics (#229)
## Summary
- add the Spec 194 governance action catalog, friction classes, reason policies, and regression guards
- align exception, review, evidence, finding, tenant, provider connection, and system run actions to the shared semantics model
- add focused feature, RBAC, audit, unit, and browser coverage, including the tenant detail triage header consistency update

## Verification
- ran the focused Spec 194 verification pack from the quickstart and task plan
- ran targeted tenant triage coverage after the detail-header update
- ran `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`

## Filament Notes
- Filament v5 / Livewire v4 compliance preserved
- provider registration remains in `apps/platform/bootstrap/providers.php`
- globally searchable resources were not changed
- destructive actions remain confirmation-gated and server-authorized
- no new Filament assets were introduced; the existing `cd apps/platform && php artisan filament:assets` deploy step stays unchanged

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #229
2026-04-12 21:21:44 +00:00

52 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Barryvdh\Debugbar\LaravelDebugbar;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class SuppressDebugbarForSmokeRequests
{
public const COOKIE_NAME = 'tp_smoke_test';
public const COOKIE_VALUE = 'ok';
public const SESSION_KEY = 'tp_smoke_test';
/**
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (! $this->shouldSuppressDebugbar($request)) {
return $next($request);
}
$debugbar = app()->bound('debugbar') ? app('debugbar') : null;
config(['debugbar.enabled' => false]);
if ($debugbar instanceof LaravelDebugbar && $debugbar->isEnabled()) {
$debugbar->disable();
}
return $next($request);
}
private function shouldSuppressDebugbar(Request $request): bool
{
if ($request->cookie(self::COOKIE_NAME) === self::COOKIE_VALUE) {
return true;
}
if (! $request->hasSession()) {
return false;
}
return $request->session()->get(self::SESSION_KEY) === self::COOKIE_VALUE;
}
}