aracoool / yii2-jwt
JWT for Yii2
v0.3
2017-08-03 13:26 UTC
Requires
- firebase/php-jwt: ^5.0
- yiisoft/yii2: ^2.0
This package is auto-updated.
Last update: 2024-11-29 04:58:01 UTC
README
JWT implementation for Yii2 Authorization process
For details see JWT official website.
Installation
To install (only master is available now) run:
composer require aracoool/yii2-jwt
Usage
Configured components
...
'jwt' => [
'class' => JsonWebToken::class,
'jwtKey' => 'key_for_signature'
],
'user' => [
'class' => \JWT\User::class,
'identityClass' => \app\models\User::class,
'enableAutoLogin' => true,
],
...
Usage of component
Encode data
\Yii::$app->jwt->encode([
'name' => 'Username'
]);
Decode hash
\Yii::$app->jwt->decode('jwt.hash.string');
Configure controller
...
'authenticator' => [
'class' => \JWT\HttpJwtAuth::class,
'except' => ['login', 'error']
]
...