Download the PHP package emarref/jwt without Composer
On this page you can find all versions of the php package emarref/jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jwt
An implementation of the JSON Web Token (JWT) draft in PHP. See jwt.io for more information on JWT.
Features include:
- Token serialization
- Token deserialization
- Token verification
aud
,exp
,iss
,nbf
,sub
claims are verified
- Symmetric Encryption
NONE
,HS256
,HS384
,HS512
algorithms supported
- Asymmetric Encryption
RS256
,RS384
,RS512
algorithms supportedES256
,ES384
,ES512
,PS256
,PS384
,PS512
algorithms are planned
:warning: Versions of this library up to and including v1.0.2 are susceptible to timing attacks when using Symmetric encryption. See #20 for more information. Please update to >= v1.0.3 as soon as possible to address this vulnerability.
This library is not susceptible to a common encryption vulnerability.
Installation
Usage
Create an instance of the Emarref\Jwt\Token
class, then configure it.
To use a token, create a JWT instance.
To retrieve the encoded token for transfer, call the serialize()
method.
The $serializedToken
variable now contains the unencrypted base64 encoded string representation of your token. To encrypt a token, pass an instance of Emarref\Jwt\Encryption\EncryptionInterface
to the serialize()
method as the second argument.
An example of using Rs256 encryption with a key pair can be found in the wiki - Using RS256 Encryption.
To use a serialized token, first deserialize it into a Emarref\Jwt\Token
object using a Jwt
instance.
To verify a token's claims, first set up the context that should be used to verify the token against. Encryption is the only required verification.
Then use the verify()
method on a Jwt
instance.
Testing
This library uses PHPUnit for unit testing. Make sure you've run composer install
then call: