Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 1014 Bytes

README.md

File metadata and controls

57 lines (38 loc) · 1014 Bytes

Token Manager

A token manager for jwt tokens

Installation

The preferred way to install this extension is through composer.

Either run

composer require dmstr/yii2-token-manager

or add

"dmstr/yii2-token-manager": "dev-master"

to the require section of your composer.json file.

Configuration

Add the component to your config

use dmstr\tokenManager\components\TokenManager;

return [
    'components' => [
        'tokenManager' => [
            'class' => TokenManager::class
        ]
    ]
];

Usage

Once the extension is installed and configurated, simply use it in your code by:

For more infos about Yii2 and JWT check out lcobucci/jwt

use dmstr\tokenManager\exceptions\LoadTokenException;

$token = ...; // valid Jwt token

Yii::$app->tokenManager->setToken($token);

try {
    $roles = Yii::$app->tokenManager->getRoles();
} catch (LoadTokenException $exception) {
 // ...
}