Interface luya\web\GroupUserIdentityInterface
Extends | yii\web\IdentityInterface |
---|---|
Available since version | 1.0.0 |
Source Code | https://github.com/luyadev/luya/blob/master/core/web/GroupUserIdentityInterface.php |
Group User IdentityInterface.
When using the {{luya\web\GroupUser}} component to authorize users, each identity class must implement this Interface.
The GroupUserIdentityInterface extends the {{yii\web\IdentityInterface}} Interface.
class User extends ActiveRecord implements GroupUserIdentityInterface
{
// luya\web\GroupUserIdentityInterface
public function authGroups()
{
return [
'group-a',
];
}
// yii\web\IdentityInterface
public static function findIdentity($id)
{
return static::findOne($id);
}
public static function findIdentityByAccessToken($token, $type = null)
{
return static::findOne(['access_token' => $token]);
}
public function getId()
{
return $this->id;
}
public function getAuthKey()
{
return $this->authKey;
}
public function validateAuthKey($authKey)
{
return $this->authKey === $authKey;
}
}
Public Methods
Method | Description | Defined By |
---|---|---|
authGroups() | Returns an array with group aliases allowed for the current user. | luya\web\GroupUserIdentityInterface |
findIdentity() | Finds an identity by the given ID. | yii\web\IdentityInterface |
findIdentityByAccessToken() | Finds an identity by the given token. | yii\web\IdentityInterface |
getAuthKey() | Returns a key that can be used to check the validity of a given identity ID. | yii\web\IdentityInterface |
getId() | Returns an ID that can uniquely identify a user identity. | yii\web\IdentityInterface |
validateAuthKey() | Validates the given auth key. | yii\web\IdentityInterface |
Method Details
Returns an array with group aliases allowed for the current user.
public function authGroups()
{
return [
'group-a', 'group-c',
];
}
public abstract array authGroups ( ) | ||
return | array |
An array contains the allowed groups for this user. |
---|
public function authGroups();
Defined in: yii\web\IdentityInterface::findIdentity()
Finds an identity by the given ID.
public abstract static yii\web\IdentityInterface|null findIdentity ( $id ) | ||
$id | string|integer |
The ID to be looked for |
return | yii\web\IdentityInterface|null |
The identity object that matches the given ID. Null should be returned if such an identity cannot be found or the identity is not in an active state (disabled, deleted, etc.) |
---|
public static function findIdentity($id);
Defined in: yii\web\IdentityInterface::findIdentityByAccessToken()
Finds an identity by the given token.
public abstract static yii\web\IdentityInterface|null findIdentityByAccessToken ( $token, $type = null ) | ||
$token | mixed |
The token to be looked for |
$type | mixed |
The type of the token. The value of this parameter depends on the implementation.
For example, yii\filters\auth\HttpBearerAuth will set this parameter to be |
return | yii\web\IdentityInterface|null |
The identity object that matches the given token. Null should be returned if such an identity cannot be found or the identity is not in an active state (disabled, deleted, etc.) |
---|
public static function findIdentityByAccessToken($token, $type = null);
Defined in: yii\web\IdentityInterface::getAuthKey()
Returns a key that can be used to check the validity of a given identity ID.
The key should be unique for each individual user, and should be persistent so that it can be used to check the validity of the user identity.
The space of such keys should be big enough to defeat potential identity attacks.
The returned key is used to validate session and auto-login (if yii\web\User::$enableAutoLogin is enabled).
Make sure to invalidate earlier issued authKeys when you implement force user logout, password change and other scenarios, that require forceful access revocation for old sessions.
See also validateAuthKey().
public abstract string|null getAuthKey ( ) | ||
return | string|null |
A key that is used to check the validity of a given identity ID. |
---|
public function getAuthKey();
Defined in: yii\web\IdentityInterface::getId()
Returns an ID that can uniquely identify a user identity.
public abstract string|integer getId ( ) | ||
return | string|integer |
An ID that uniquely identifies a user identity. |
---|
public function getId();
Defined in: yii\web\IdentityInterface::validateAuthKey()
Validates the given auth key.
See also getAuthKey().
public abstract boolean|null validateAuthKey ( $authKey ) | ||
$authKey | string |
The given auth key |
return | boolean|null |
Whether the given auth key is valid. |
---|
public function validateAuthKey($authKey);