Final Class Yiisoft\Auth\Method\Composite
| Inheritance | Yiisoft\Auth\Method\Composite |
|---|---|
| Implements | Yiisoft\Auth\AuthenticationMethodInterface |
Composite allows multiple authentication methods at the same time.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Auth\Method\Composite | |
| authenticate() | Yiisoft\Auth\Method\Composite | |
| challenge() | Yiisoft\Auth\Method\Composite |
Method Details
| public __construct( Yiisoft\Auth\AuthenticationMethodInterface[] $methods ): mixed | ||
| $methods | Yiisoft\Auth\AuthenticationMethodInterface[] | |
public function __construct(
private readonly array $methods,
) {}
| public authenticate( \Psr\Http\Message\ServerRequestInterface $request ): Yiisoft\Auth\IdentityInterface|null | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
public function authenticate(ServerRequestInterface $request): ?IdentityInterface
{
foreach ($this->methods as $method) {
if (!$method instanceof AuthenticationMethodInterface) {
throw new RuntimeException('Authentication method must be an instance of ' . AuthenticationMethodInterface::class . '.');
}
$identity = $method->authenticate($request);
if ($identity !== null) {
return $identity;
}
}
return null;
}
| public challenge( \Psr\Http\Message\ResponseInterface $response ): \Psr\Http\Message\ResponseInterface | ||
| $response | \Psr\Http\Message\ResponseInterface | |
public function challenge(ResponseInterface $response): ResponseInterface
{
foreach ($this->methods as $method) {
$response = $method->challenge($response);
}
return $response;
}
Signup or Login in order to comment.