Skip to content

Releases: firebase/php-jwt

v6.1.0

23 Mar 18:28
fbb2967

Choose a tag to compare

Note: There should be no issues with backwards compatibility unless types were being used incorrectly

  • This version is compatible with PHP >= 7.1
  • Drop support for PHP 5.3, 5.4, 5.5, 5.6, and 7.0
  • Add parameter typing and return types
  • Better PHPDoc / IDE support

v6.0.0

24 Jan 15:19
0541cba

Choose a tag to compare

Note: This version is compatible with PHP >= 5.3

Backwards Compatibility Breaking Changes

  • The second argument of JWT::decode now must be Firebase\JWT\Key or array<string, Firebase\JWT\Key> (see #376)
  • The return type of Firebase\JWT\JWK::parseKey is now Firebase\JWT\Key (see #392)
  • The return type of Firebase\JWT\JWK::parseKeySet is now array<string, Firebase\JWT\Key> (see #376)
  • The "alg" parameter is required to be set for all JWKS parsed using Firebase\JWT\JWK::parseKeySet (see #376)
  • The flag JSON_UNESCAPED_SLASHES is now used for JSON decoding (see #376)
  • Constants ASN1_INTEGER, ASN1_SEQUENCE, and ASN1_BIT_STRING have been removed (see #376)
  • JWT::encode requires third argument $alg (see #377)
  • JWT::sign requires third argument $alg (see #377)

Using Firebase\JWT\Key

Using the Key object in JWT::decode

As a security fix, to avoid key type confusion (see #351), use of Firebase\JWT\Key is now required when decoding:

use Firebase\JWT\JWT;

// previous (v5.5.1 and below)
$decoded = JWT::decode($jwt, $publicKey, 'RS256');

// new (v6.0.0)
use Firebase\JWT\Key;
$decoded = JWT::decode($jwt, new Key($publicKey, 'RS256'));

And when you have more than one key, the second argument can be an array of Key objects:

use Firebase\JWT\JWT;

// previous (v5.5.1 and below)
$decoded = JWT::decode($jwt, [$publicKey1, $publicKey2], 'RS256');

// new (v6.0.0)
use Firebase\JWT\Key;
$decoded = JWT::decode($jwt, [
    'kid1' => new Key($publicKey1, 'RS256'),
    'kid2' => new Key($publicKey2, 'RS256')
]);  

Note: When providing multiple keys, you must provide the matching $kid as the fourth parameter
to the JWT::encode function

Using the Key object in JWK::parseKey and JWK::parseKeySet

Calls to JWK::parseKey and JWK::parseKeySet now return a Key object and an array
of Key objects respectively.

use Firebase\JWT\JWK;

// previous (v5.5.1 and below)
$key = JWK::parseKey($jwk); // $key is a resource
$keys = JWK::parseKeySet($jwks); // $keys is an associative array key ID to resources

// new (v6.0.0)
$key = JWK::parseKey($jwk); // $key is a Key object
$keys = JWK::parseKeySet($jwks); // $keys is an associative array of key ID to Key objects

If the keys in your JWKS do not contain the "alg", you need to set it manually to the expected algorithm, for it to be able to parse successfully:

// new (v6.0.0) for JWKS which do not contain "alg"
foreach ($jwks as $k => $jwks) {
    $jwks[$k]['alg'] = 'RS256'; // the expected alg of your JWKS
}
$keys = JWK::parseKeySet($jwks); // $keys is an associative array of key ID to Key objects

v5.5.1

08 Nov 20:21
83b6090

Choose a tag to compare

Bug Fixes

This release fixes BC issues caused by the changes in 5.5.0:

  • Updates PHPDoc for static analyzers (#371)
  • Ensures exceptions are not thrown for keys of type resource or OpenSSLAsymmetricKey (#371)

v5.5.0

04 Nov 16:28
cf81444

Choose a tag to compare

!!IMPORTANT!!

The recommended usage of this library has changed.
A Key object should now be used as the second argument to JWT::decode instead of using the
allowed_algs array. This will prevent key/algorithm type confusion:

// Previous way to call "decode"
Firebase\JWT\JWT::decode($jwt, $publicKey, ['RS256']);

// New (safer) way to call "decode"
$key = new Firebase\JWT\Key($publicKey, 'RS256');
Firebase\JWT\JWT::decode($jwt, $key);

Please see #351 for more information on the issue, and #365 for the merged changes.
The README has also been updated to reflect the new usage.

v5.4.0

23 Jun 19:04
d2113d9

Choose a tag to compare

Features

  • add Ed25519 support to JWT (#343)
  • make JWK::parseKey public (#337)

Bug Fixes

  • export-ignore github dir (#338)

v5.3.0

31 May 17:21
3c2d70f

Choose a tag to compare

Features

  • add ES384 support (#324)

Bug Fixes

  • allow for null d values in RSA JWK (#330)

v5.2.1

12 Feb 00:03
f42c911

Choose a tag to compare

Bug Fixes

  • fix: add missing use statement in JWK (#303)

v5.2.0

25 Mar 18:52
feb0e82

Choose a tag to compare

Features

  • JWK support (#273)

Bug Fixes

  • Backslashes for native function invocations (#284)

v5.1.0

24 Feb 23:51
4566062

Choose a tag to compare

Features

  • Support for ES256 (#239)

Bug Fixes

  • Remove unnecessary check for json_last_error (#263)

v5.0.0 / 2017-06-27

27 Jun 22:20

Choose a tag to compare

Changelog: