mikejw / elib-jwt
JWT Support for empathy
Requires
- firebase/php-jwt: ^6.0
- mikejw/elib-base: ^4.2.7
This package is auto-updated.
Last update: 2026-07-19 07:06:14 UTC
README
JWT Support for Empathy Applications using https://github.com/firebase/php-jwt.
This extension depends on elib-base.
The JWT service will automatically be enabled for your application.
(See services.php).
The two methods available with this extension are:
<php
$token = DI::getContainer()->get('JWT')->generate();
generate() uses a one-hour lifetime by default. Pass a lifetime in seconds
when a different expiry is required:
<php
$ttl = 60 * 60 * 24 * 30;
$token = DI::getContainer()->get('JWT')->generate($ttl);
The default can be configured with the ELIB_JWT_TTL environment variable or
the ELib JWT_TTL setting. getTTL() returns the resolved lifetime, which is
useful when setting a browser cookie to the same expiry:
<php
$jwt = DI::getContainer()->get('JWT');
$ttl = $jwt->getTTL();
$token = $jwt->generate($ttl);
and
<php
$token = DI::getContainer()->get('JWT')->tryAuthenticate();
Licence
Empathy and officially released extension libraries are now distributed under an MIT license. See LICENSE.