final class ApiAuthorizationMiddleware implements MiddlewareInterface (View source)

Enforces endpoint access, authenticated trust and scopes before API controller dispatch.

Non-API routes pass through unchanged. API routes receive the canonical RouteMatch only after their registry binding is verified; protected routes additionally receive an authorized identity.

Methods

__construct(ApiEndpointRequestResolver $endpointResolver, ApiAuthenticatorInterface $authenticator, ScopeVoter $scopeVoter, ProblemDetailsFactory $problems, AppConfig $appConfig, Router $router)

Binds authorization to endpoint resolution, authentication, scope policy and Problem Details responses.

ResponseInterface
process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Matches once, fails closed for the API namespace, and dispatches only authorized endpoints.

ResponseInterface

Details

__construct

__construct(ApiEndpointRequestResolver $endpointResolver, ApiAuthenticatorInterface $authenticator, ScopeVoter $scopeVoter, ProblemDetailsFactory $problems, AppConfig $appConfig, Router $router)

Binds authorization to endpoint resolution, authentication, scope policy and Problem Details responses.

Parameters

ApiEndpointRequestResolver $endpointResolver
ApiAuthenticatorInterface $authenticator
ScopeVoter $scopeVoter
ProblemDetailsFactory $problems
AppConfig $appConfig
Router $router

process

ResponseInterface process(ServerRequestInterface $request, RequestHandlerInterface $handler)

Matches once, fails closed for the API namespace, and dispatches only authorized endpoints.

Parameters

ServerRequestInterface $request
RequestHandlerInterface $handler

Return Value

ResponseInterface