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 mixed __construct ( Yiisoft\Auth\AuthenticationMethodInterface[] $methods ) | ||
| $methods | Yiisoft\Auth\AuthenticationMethodInterface[] | |
public function __construct(private array $methods)
{
}
| public Yiisoft\Auth\IdentityInterface|null authenticate ( \Psr\Http\Message\ServerRequestInterface $request ) | ||
| $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 \Psr\Http\Message\ResponseInterface challenge ( \Psr\Http\Message\ResponseInterface $response ) | ||
| $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.