ideationnet / jwt-middleware
PSR-15 兼容的 JWT 认证中间件
dev-master / 1.0.x-dev
2016-11-29 17:22 UTC
Requires
- php: ~7.0
- firebase/php-jwt: ^4.0
- http-interop/http-factory: ^0.2.0
- http-interop/http-middleware: ^0.3.0
This package is not auto-updated.
Last update: 2024-09-23 14:53:15 UTC
README
一个简单的 PSR-15 兼容的 JWT 认证中间件。
安装
通过 Composer
$ composer require ideationnet/jwt-middleware
使用方法
使用您喜欢的 PSR-15 中间件分发器,例如 Stack Runner。 示例配置(使用 PHP-DI),其中选项更改以添加 /token
作为公开路径
return [ JwtMiddleware::class => object() ->constructorParameter('options', ['public' => ['/token']]), ];
选项
key
是 JWT 秘钥,默认为JWT_SECRET
环境变量algorithms
是支持算法的数组,默认为['HS512']
public
是绕过认证的路径数组attribute
是存储解码令牌的属性的名称,默认为jwt-token
令牌在中间件栈中更低的 $request
对象中可用
$token = $request->getAttribute('jwt-token');
安全
如果您发现任何安全相关的问题,请通过电子邮件 darren@darrenmothersele.com 而不是使用问题跟踪器。
鸣谢
许可
MIT 许可。请参阅 许可文件 获取更多信息。