*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| Your private key content.
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
| Note: This value must be encoded by base64.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
问题:
$this->auth->guard('api')->checkOrFail();
不能拦截,并且后续打印当前用户为空流程:
// throw new \Exception($e->getMessage()); }
// throw new \Exception($exception->getMessage());
declare(strict_types=1); /**
php bin/hyperf.php gen:jwt-secret
*/
'secret' => env('JWT_SECRET'),
JWT_SECRET
) or using thephp bin/hyperf.php gen:jwt-keypair
JWT_SECRET
.*/
],
*/
'ttl' => env('JWT_TTL', 1000000),
*/
'refresh_ttl' => env('JWT_REFRESH_TTL', 3600 24 14),
*/
'algo' => env('JWT_ALGO', 'HS512'),
*/
'required_claims' => [ 'iss', 'iat', // 'exp', 'nbf', 'sub', 'jti', ],
sub
andiat
will automatically be persisted, in*/
'persistent_claims' => [ // 'foo', // 'bar', ],
prv
claim is automatically added toApp\User
&App\OtherPerson
, then we*/
'lock_subject' => true,
iat
,nbf
andexp
.*/
'leeway' => env('JWT_LEEWAY', 0),
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
*/
'blacklist_storage' => HyperfExt\Jwt\Storage\HyperfCache::class, ];
bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkucm9hLmppYWJhb2xlc2hvcC5jb21cL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE2MTU1MzcyMzgsImV4cCI6MTYxNjUzNzIzOCwibmJmIjoxNjE1NTM3MjM4LCJqdGkiOiJuSWR2UWNmMEhweUxxWmp5Iiwic3ViIjoxMDAwNTU1LCJwcnYiOiJmNmI3MTU0OWRiOGMyYzQyYjc1ODI3YWE0NGYwMmI3ZWU1MjlkMjRkIn0.GFCOnwmiq-YzD2F8877yr0IIyzyY_OIXIAQELRG6Ceu_FYPNd2PfdCWqm7Zw-oWGkFCNOPB2g43_XYh_uFfEug
问题发现
这个token应该是前n天生成的,今天偶然测试,发现
checkOrFail
不能拦截了其他
我在 链接 中补充了常用使用方式,然后
$this->auth->guard('api')->checkOrFail();
是大佬帮我补充的我的.env