ideationnet / jwt-middleware
PSR-15 compatible JWT Authentication middleware
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-11-04 15:25:45 UTC
README
A simple PSR-15 compatible JWT authentication middleware.
Install
Via Composer
$ composer require ideationnet/jwt-middleware
Usage
Use with your favourite PSR-15 middleware dispatcher,
like Stack Runner.
Example configuration (using PHP-DI) where the options
are changed to add /token
as a public path:
return [ JwtMiddleware::class => object() ->constructorParameter('options', ['public' => ['/token']]), ];
Options:
key
is the JWT secret key, defaults toJWT_SECRET
environment variablealgorithms
is the array of supported algorithms, defaults to['HS512']
public
is an array of paths that bypass authenticationattribute
is the name of the attribute into which the decoded token is stored, defaults tojwt-token
The token is available in the $request
object in middleware further
down the stack:
$token = $request->getAttribute('jwt-token');
Security
If you discover any security related issues, please email darren@darrenmothersele.com instead of using the issue tracker.
Credits
License
The MIT License. Please see License File for more information.