jimtools / jwt-auth
tuupola/slim-jwt-auth 的直接替换方案
1.0.2
2024-09-14 22:04 UTC
Requires
- php: ^7.4|^8.0
- firebase/php-jwt: ^6.0
- psr/http-message: ^1.0|^2.0
- psr/http-server-middleware: ^1.0
- psr/log: ^1.0|^2.0|^3.0
- tuupola/callable-handler: ^1.0
- tuupola/http-factory: ^1.3
Requires (Dev)
- equip/dispatch: ^2.0
- laminas/laminas-diactoros: ^2.0|^3.0
- overtrue/phplint: ^1.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^7.0|^8.5.30|^9.0
- squizlabs/php_codesniffer: ^3.7
Replaces
This package is auto-updated.
Last update: 2024-09-14 22:32:57 UTC
README
本包是一个符合 PSR-15 规范的 JSON Web Token 认证中间件,它可以从头部或 cookies 中获取 JWT。
<?php use JimTools\JwtAuth\Decoder\FirebaseDecoder; use JimTools\JwtAuth\Middleware\JwtAuthentication; use JimTools\JwtAuth\Options; use JimTools\JwtAuth\Secret; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require './vendor/autoload.php'; $app = AppFactory::create(); $middleware = new JwtAuthentication( new Options(), new FirebaseDecoder(new Secret('tooManySecrets', 'HS256')) ); $app->get('/protected', static function (Request $request, Response $response, array $args) { $response->getBody()->write('you will need a token'); return $response; })->addMiddleware($middleware); $app->run();
注意
有关与 tuupola/slim-jwt-auth
兼容的 v1.x 版本文档,请参阅 1.x
安装
推荐通过 composer 安装包。
composer require jimtools/jwt-auth
文档
GitHub 问题仅用于讨论错误和新功能,请使用 GitHub 讨论板寻求支持。
安全
如果您发现任何安全相关的问题,请通过电子邮件 james.read.18@gmail.com 报告,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING。
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。