gielfeldt/jwt-middleware

Jwt middleware for lcobucci jwt

0.2.2 2021-07-16 04:56 UTC

This package is auto-updated.

Last update: 2024-03-16 10:50:22 UTC


README

Build Status Test Coverage

Latest Stable Version Latest Unstable Version License Total Downloads

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);