scaffoldeducation/jwt-manager-php
Composer 安装命令:
composer require scaffoldeducation/jwt-manager-php
包简介
PHP library to manage JWT authentication
README 文档
README
PHP library to manage JWT authentication
Installation
Requires PHP 7.1.
- Original source and doc: Kiwfy - JWT Manager PHP
The recommended way to install is through Composer.
composer require scaffoldeducation/jwt-manager-php
Migration
To execute migration on a Lumen system, you will need import JwtManagerServiceProvider in you application:
Open .\bootstrap\app.php and add this line:
$app->register(JwtManager\JwtManagerServiceProvider::class);
You can custom blacklist table name at your .env file (default: oauth_jwt_blacklist):
OAUTH_TABLE_BLACKLIST=oauth_jwt_blacklist
Now execute on your terminal this command: php artisan migratre
Usage
Import this library in your application and use:
// expire and renew is seconds (900 = 15 minutes) $jwt = new JwtManager(string $appSecret, string $context, int $expire, int $renew); // generete a new token $token = $jwt->generate(string $audience, string $subject, array $payload); // to invalid this token, use: $jwt->turnInvalid($token);
Sample
it's a good idea to look in the sample folder to understand how it works.
First verify if all dependencies is installed (if need anyelse)
composer install --no-dev --prefer-dist
and run
php sample/jwtManager-sample.php
统计信息
- 总下载量: 409
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2020-07-23