jimtools / jwt-auth
Drop in replacement for tuupola/slim-jwt-auth
Installs: 10 704
Dependents: 2
Suggesters: 0
Security: 0
Stars: 6
Watchers: 4
Forks: 141
Open Issues: 0
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
This package is a PSR-15 compliant JSON Web Token authentication middleware, which take a JWT from the headers or cookies.
<?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();
Note
For documentation on v1.x which is conpatiable with tuupola/slim-jwt-auth
see 1.x
Install
The recommended way to install packages is through composer.
composer require jimtools/jwt-auth
Documentation
GitHub issues are used for only to discuss bugs and new features, for support please use GitHub discussions.
Security
If you discover any security-related issues, please email james.read.18@gmail.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.