Skip to content

AuthenticatorInterface

Generalizes Quiote\Mcp\Auth\McpAuthenticatorInterface into a framework-wide contract: one implementation per credential mechanism (form login, HTTP Basic, bearer/JWT, OIDC).

A firewall runs its ordered authenticator chain, calling supports() to pick the first match, then authenticate().

interface AuthenticatorInterface

Implemented byFormLoginAuthenticator, HttpBasicAuthenticator, BearerTokenAuthenticator, OidcAuthenticator
Since1.0.0
SourceSecurity/Auth/AuthenticatorInterface.php
MethodDescription
authenticate(ServerRequestInterface $request): PassportExtract and validate this authenticator’s credential from $request and resolve it to an identity.
onFailure(AuthenticationException $exception): ?ResponseInterfaceOptional authenticator-specific failure response (e.g.
supports(ServerRequestInterface $request): boolWhether this authenticator can attempt to extract a credential from $request (e.g.

abstract public function authenticate(ServerRequestInterface $request): Passport

Extract and validate this authenticator’s credential from $request and resolve it to an identity.

The incoming request. Only ever called after supports() returned true for it.

ParameterTypeDescription
$requestServerRequestInterfaceThe incoming request. Only ever called after supports() returned true for it.

Returns Passport — The resolved identity, credentials/roles, and statelessness flag.

ThrowsWhen
AuthenticationExceptionIf the presented credential is absent, malformed, or invalid.

abstract public function onFailure(AuthenticationException $exception): ?ResponseInterface

Optional authenticator-specific failure response (e.g.

The exception thrown by authenticate().

ParameterTypeDescription
$exceptionAuthenticationExceptionThe exception thrown by authenticate().

Returns ?ResponseInterface — A response to short-circuit with, or null to defer to the firewall’s entry point.

abstract public function supports(ServerRequestInterface $request): bool

Whether this authenticator can attempt to extract a credential from $request (e.g.

The incoming request.

ParameterTypeDescription
$requestServerRequestInterfaceThe incoming request.

Returns bool — True if this authenticator should attempt authenticate(), otherwise false.