dmstr/yii2-token-manager

A token manager for jwt tokens

Installs: 6 294

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 5

Forks: 0

Open Issues: 0

Type:yii2-extension

2.0.0 2024-01-26 17:12 UTC

README

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) {
 // ...
}