baywa-re-lusy / jwt-authentication
BayWa r.e. LUSY JWT Authentication
Package info
github.com/baywa-re-lusy/jwt-authentication
pkg:composer/baywa-re-lusy/jwt-authentication
5.0.1
2026-11-24 13:30 UTC
Requires
- php: >=8.4
- ext-mbstring: *
- firebase/php-jwt: ^7.0
- laminas/laminas-hydrator: ^4.3
- laminas/laminas-permissions-acl: ^2.10
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
- symfony/security-core: ^7.4
Requires (Dev)
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^9.5
- rector/rector: ^2.8
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Installation
To install the JWT Authentication service, you will need Composer in your project:
composer require baywa-re-lusy/jwt-authentication
Usage example code for Laminas projects
In Module.php:
use BayWaReLusy\JwtAuthentication\TokenService; use Laminas\Cache\Psr\CacheItemPool\CacheItemPoolDecorator; use BayWaReLusy\JwtAuthentication\Token; public function onAuthentication(MvcAuthEvent $e): IdentityInterface { $jwt = ...; // The JSON Web Token $laminasCacheStorageInterface = ...; // Instance of Laminas\Cache\Storage\StorageInterface $jwksUrl = ...; // URL from where to get JWKs $cache = new CacheItemPoolDecorator($laminasCacheStorageInterface); $tokenService = new TokenService( <PSR-compliant HTTP Client>, <PSR-compliant HTTP RequestFactory> ); try { $token = $tokenService->validateToken($jwt, $cache, $jwksUrl); } catch (\BayWaReLusy\JwtAuthentication\InvalidTokenException $e) { return new GuestIdentity(); } ... }