*/ private array $csrfIgnore = [ "cover", "download", "getpagination", "getlastread", "getinfo", "list", "healthz" ]; public function process(Request $request, callable $next): Response { if (empty($_SESSION['owner'])) { return $next($request); } $op = $request->getString('op'); $csrfToken = $request->fromBody()->getString('csrf_token', ''); if (!in_array($op, $this->csrfIgnore) && !validate_csrf($csrfToken)) { $response = (new Response()) ->withStatus(401) ->withBody(json_encode(["error" => "Unauthorized (CSRF)"])); $response->send(); exit; } return $next($request); } }