Skip to content
PHP Ecosystem
Explore

AuthInterface

API reference › yii › filters › auth › AuthInterface

interfaceyii\filters\auth\AuthInterface
Since2.0
Sourceframework/filters/auth/AuthInterface.php
Implemented by 1 type

AuthInterface is the interface that should be implemented by auth method classes.

MethodDescriptionDefined by
authenticate() abstractAuthenticates the current user.AuthInterface
challenge() abstractGenerates challenges upon authentication failure.AuthInterface
handleFailure() abstractHandles authentication failure.AuthInterface
abstract public function authenticate(yii\web\User $user, yii\web\Request $request, yii\web\Response $response): yii\web\IdentityInterface|null

Authenticates the current user.

Parameters

ParameterTypeDescription
$useryii\web\User
$requestyii\web\Request
$responseyii\web\Response

Returns

yii\web\IdentityInterface|null: The authenticated user identity. If authentication information is not provided, null will be returned.

Throws

abstract public function challenge(yii\web\Response $response): mixed

Generates challenges upon authentication failure.

For example, some appropriate HTTP headers may be generated.

Parameters

ParameterTypeDescription
$responseyii\web\Response

Returns

mixed

abstract public function handleFailure(yii\web\Response $response): mixed

Handles authentication failure.

The implementation should normally throw UnauthorizedHttpException to indicate authentication failure.

Parameters

ParameterTypeDescription
$responseyii\web\Response

Returns

mixed

Throws