Download the PHP package gitsindonesia/php-jwt without Composer
On this page you can find all versions of the php package gitsindonesia/php-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gitsindonesia/php-jwt
More information about gitsindonesia/php-jwt
Files in gitsindonesia/php-jwt
Package php-jwt
Short Description A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Forked from firebase/php-jwt to include patches for version 5.5.1.
License
Homepage https://github.com/gitsindonesia/php-jwt
Informations about the package php-jwt
PHP-JWT ( Forked from firebase/php-jwt to include patches for version 5.5.1 )
Forked from firebase/php-jwt to include patches for version 5.5.1.
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to RFC 7519.
PHP-JWT (GITS Indonesia Patched Version)
⚠️ Security Patch for Version 5.5.1
This repository is a fork of firebase/php-jwt specifically providing a security-patched version of the 5.5.1 release.
Why is this Fork Necessary?
Many legacy Laravel projects or those utilizing Laravel Passport (v7 and below) have dependency constraints where firebase/php-jwt is locked to version ^5.0.
Since official security fixes are primarily released for version 6.x and above, these projects often remain flagged as vulnerable during security audits (e.g., via composer audit), yet they cannot upgrade to version 6.x due to strict dependency conflicts with other packages.
This fork allows you to:
- Fix Vulnerabilities: Stay secure while remaining on the 5.x version line.
- Avoid Dependency Conflicts: Fully compatible with Laravel Passport or Google API Client that requires
firebase/php-jwt: ~5.0. - Zero Code Changes: Uses the original
Firebase\JWTnamespace, meaning no changes are required in your existing application code.
Installation ( Patched Version 5.5.1 )
Since this package is published on Packagist, you can install it directly without additional configuration.
1. Install the Patched Version
Run the following command to replace the original library with the GITS patched version:
2. Verification
To ensure the original firebase/php-jwt has been successfully replaced by this fork, run:
The output should indicate that the package is being replaced by gitsindonesia/php-jwt.
Technical Details
- Base Version: 5.5.1
- Patch Version: 5.5.1-p1
- Namespace: Firebase\JWT (Identical to original)
- License: BSD-3-Clause (Identical to original)
- Compatibility: Tested with Laravel Passport (v7) and Google API PHP Client.
Installation ( Please refer to original firebase/php-jwt documentation )
Use composer to manage your dependencies and download PHP-JWT:
Optionally, install the paragonie/sodium_compat package from composer if your
php env does not have libsodium installed:
Example
Example encode/decode headers
Decoding the JWT headers without verifying the JWT first is NOT recommended, and is not supported by
this library. This is because without verifying the JWT, the header values could have been tampered with.
Any value pulled from an unverified header should be treated as if it could be any string sent in from an
attacker. If this is something you still want to do in your application for whatever reason, it's possible to
decode the header values manually simply by calling json_decode and base64_decode on the JWT
header part:
Example with RS256 (openssl)
Example with a passphrase
Example with EdDSA (libsodium and Ed25519 signature)
`
Example with multiple keys
Using JWKs
Using Cached Key Sets
The CachedKeySet class can be used to fetch and cache JWKS (JSON Web Key Sets) from a public URI.
This has the following advantages:
- The results are cached for performance.
- If an unrecognized key is requested, the cache is refreshed, to accomodate for key rotation.
- If rate limiting is enabled, the JWKS URI will not make more than 10 requests a second.
Miscellaneous
Exception Handling
When a call to JWT::decode is invalid, it will throw one of the following exceptions:
All exceptions in the Firebase\JWT namespace extend UnexpectedValueException, and can be simplified
like this:
Casting to array
The return value of JWT::decode is the generic PHP object stdClass. If you'd like to handle with arrays
instead, you can do the following:
Tests
Run the tests using phpunit:
New Lines in private keys
If your private key contains \n characters, be sure to wrap it in double quotes ""
and not single quotes '' in order to properly interpret the escaped characters.