2023-08-29 11:55:12 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Mcp\Middleware;
|
|
|
|
|
2023-09-15 17:19:45 +00:00
|
|
|
/**
|
|
|
|
* Middleware implementations can be registered for a RequestHandler.
|
|
|
|
*
|
|
|
|
* If this is done, request processing continues only if Middleware::canAccess() returns true.
|
|
|
|
*/
|
2023-08-29 11:55:12 +00:00
|
|
|
interface Middleware
|
|
|
|
{
|
2023-09-15 17:19:45 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the request should be processed, i.e. if the client has permissionn to perform this request.
|
|
|
|
*/
|
2023-08-29 11:55:12 +00:00
|
|
|
public function canAccess(): bool;
|
2023-09-15 17:19:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when canAcces() returns false, e.g. to redirect unauthorized users.
|
|
|
|
*/
|
2023-08-29 11:55:12 +00:00
|
|
|
public function handleUnauthorized(): void;
|
2023-09-15 17:19:45 +00:00
|
|
|
}
|