0 follower

Final Class Yiisoft\Auth\Method\Composite

InheritanceYiisoft\Auth\Method\Composite
ImplementsYiisoft\Auth\AuthenticationMethodInterface

Composite allows multiple authentication methods at the same time.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Auth\AuthenticationMethodInterface[] $methods )
$methods Yiisoft\Auth\AuthenticationMethodInterface[]

                public function __construct(private array $methods)
{
}

            
authenticate() public method

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;
}

            
challenge() public method

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;
}