gielfeldt / jwt-middleware
Jwt middleware for lcobucci jwt
0.2.2
2021-07-16 04:56 UTC
Requires
- php: >=7.4.0
- lcobucci/jwt: ^4.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-server-middleware: ^1.0
- psr/simple-cache: ^1.0
Requires (Dev)
- nyholm/psr7: ^1.4
- phpmd/phpmd: ^2.10
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.6
README
Installation
composer require gielfeldt/jwt-middleware
Usage
<?php use Gielfeldt\JwtMiddleware\HeaderTokenProvider; use Gielfeldt\JwtMiddleware\JwtMiddleware; use Lcobucci\Clock\SystemClock; use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Validation\Constraint\StrictValidAt; use Nyholm\Psr7\Factory\Psr17Factory; require './vendor/autoload.php'; $config = Configuration::forUnsecuredSigner(); $clock = new SystemClock(new DateTimeZone('UTC')); $constraint = new StrictValidAt($clock); $config->setValidationConstraints($constraint); $tokenProvider = new HeaderTokenProvider(); $responseFactory = new Psr17Factory(); $middleware = new JwtMiddleware($responseFactory, $config, $tokenProvider);