oxygenzsas / composer_lib_jwt
一个针对 firebase/php-jwt 的最小化中间件
0.0.6
2023-10-06 13:40 UTC
Requires
- firebase/php-jwt: ^6.4
- nyholm/psr7: ^1.3
- psr/http-message: ^1.0
This package is auto-updated.
Last update: 2024-09-06 16:31:54 UTC
README
一个基于 https://github.com/firebase/php-jwt 的针对 firebase/php-jwt 的最小化中间件
安装
通过 composer
composer require oxygenzsas/composer_lib_jwt
使用 token
$data = ['id_user' =>555]; /** @var OxygenzSAS\JWT\JWT $jwt */ $jwt = Container::getInstance()->get('JWT'); $jwtToken = $jwt->getToken($data); $decoded = $jwt->decode($jwtToken); $retour = [ "message" => "Successful login", "jwt" => $jwtToken, "expireAt" => $decoded->exp ];
使用路由器作为 PSR-15 中间件
// creation du dispatcher $Dispatcher = new OxygenzSAS\Dispatcher\Dispatcher(); // creer le jwt $jwt = new \App\classe\JWT( $private, // private_key $public, // public_key 'localhost:8000', // iss 3600, // expire time token -- facultatif default = 3600 'RS256', // algorithm de chiffrement -- facultatif default = RS256 'localhost:8000', // aud -- facultatif default = iss ); // ajout le middlewares $Dispatcher->pipe($jwt);