sent / think-jwt
This package is abandoned and no longer maintained.
The author suggests using the tensent/think-jwt package instead.
thinkphp jwt auth composer
v1.1
2021-01-23 03:02 UTC
Requires
- php: ^7.0
- lcobucci/jwt: 3.3.3
- topthink/framework: ^5.1.10 || ^6.0.0
This package is not auto-updated.
Last update: 2022-04-28 13:20:25 UTC
README
install
composer require tensent/think-jwt
example
<?php
use JwtAuth\Config;
use JwtAuth\JwtAuth;
$auth = new JwtAuth();
// 用户 id
$id = 1;
// 附带参数
$cliasm = [];
$token = $auth->token($id, $cliams)->toString();
// 生成 token
var_dump($token);
// 验证 token
var_dump($auth->verify($token));
// 验证后 token 对象
var_dump($auth->getVerifyToken());
// 验证获取 id
var_dump($auth->getVerifyToken()->claims()->get('jti'));
// 解析 token
var_dump($auth->parseToken($token));
// 获取效验后的用户模型对象
var_dump($auth->getUser());
TODO
- [ ] phpunit
- [x] manger event handler (login、verify、logout)
- [ ] exceptions