Remove the 'ResponseFactoryInterface $responseFactory' parameter from the 'Authentication' constructor
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 39
- Forks
- 17
- Avg merge
- 1h 9m
- Merged PRs (30d)
- 1
Description
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
];
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Authentication constructor and the config/di-web.php entry shown in the issue, then trace how AuthenticationFailureHandler and RequestHandlerInterface are wired and used. Done means Authentication no longer accepts ResponseFactoryInterface, its failure handler is supplied through the handler dependency, and the existing authentication-failure behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- authentication
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100