0 follower

Final Class Yiisoft\Auth\Method\QueryParameter

InheritanceYiisoft\Auth\Method\QueryParameter
ImplementsYiisoft\Auth\AuthenticationMethodInterface

QueryParameter supports the authentication based on the access token passed through a query parameter.

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Auth\IdentityWithTokenRepositoryInterface $identityRepository )
$identityRepository Yiisoft\Auth\IdentityWithTokenRepositoryInterface

                public function __construct(private IdentityWithTokenRepositoryInterface $identityRepository)
{
}

            
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
{
    $accessToken = $request->getQueryParams()[$this->parameterName] ?? null;
    if (is_string($accessToken)) {
        return $this->identityRepository->findIdentityByToken($accessToken, $this->tokenType);
    }
    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
{
    return $response;
}

            
withParameterName() public method

public $this withParameterName ( string $name )
$name string

The parameter name for passing the access token.

                public function withParameterName(string $name): self
{
    $new = clone $this;
    $new->parameterName = $name;
    return $new;
}

            
withTokenType() public method

public $this withTokenType ( string|null $type )
$type string|null

Identity token type

                public function withTokenType(?string $type): self
{
    $new = clone $this;
    $new->tokenType = $type;
    return $new;
}