oxygenzsas / composer_lib_jwt
Un middleware minimaliste pour 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: 2025-03-06 17:45:13 UTC
README
Un middleware minimaliste pour firebase/php-jwt basée sur https://github.com/firebase/php-jwt
Installation
Via composer
composer require oxygenzsas/composer_lib_jwt
Utilisation des tokens
$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 ];
Utiliser le router comme un middleware 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);