Proposed new feature or change
The 'ResponseFactoryInterface $responseFactory' parameter is proposed for removal from the 'Authentication' constructor in order to simplify the 'Authentication' configuration, while retaining the same logic.
Current:
final class Authentication implements MiddlewareInterface
{
// ...
public function __construct(
private AuthenticatorInterface|AuthenticationMethodInterface $authenticationMethod,
ResponseFactoryInterface $responseFactory,
?RequestHandlerInterface $authenticationFailureHandler = null,
) {
$this->failureHandler = $authenticationFailureHandler ?? new AuthenticationFailureHandler(
$responseFactory,
);
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// ...
if ($identity === null && !$this->isOptional($request)) {
$response = $this->failureHandler->handle($request);
// ...
}
// ...
}
// ...
}
Proposed:
final class Authentication implements MiddlewareInterface
{
// ...
public function __construct(
private AuthenticatorInterface|AuthenticationMethodInterface $authenticationMethod,
private RequestHandlerInterface $authenticationFailureHandler
) {}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// ...
if ($identity === null && !$this->isOptional($request)) {
$response = $this->authenticationFailureHandler->handle($request);
// ...
}
// ...
}
// ...
}
//config/di-web.php
use App\Web\Auth\AuthenticationFailureHandler;
use Psr\Http\Server\RequestHandlerInterface;
return [
RequestHandlerInterface::class => AuthenticationFailureHandler::class
];
Proposed new feature or change
The 'ResponseFactoryInterface $responseFactory' parameter is proposed for removal from the 'Authentication' constructor in order to simplify the 'Authentication' configuration, while retaining the same logic.
Current:
Proposed: