Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
This project is a framework that provides an implementation of:
It also provides:
a Symfony bundle
a standalone console application
This project is release under MIT licence.
The framework has been successfully tested using PHP 7.1
, PHP 7.2
and nightly
with all algorithms.
Tests vectors from the RFC 7520 are fully implemented and all tests pass. Other test vector sources may be used (e.g. new algorithm specifications).
We also track bugs and code quality using Scrutinizer-CI and Sensio Insight.
Coding Standards are verified by StyleCI.
Code coverage is analyzed by Coveralls.io.
JWS or JWE objects support every input that can be encoded into JSON:
string
, array
, integer
, float
...
Objects that implement the \JsonSerializable
interface such as JWK
or JWKSet
The detached payload is supported.
Compact JSON Serialization Syntax for JWS and JWE
Flattened JSON Serialization Syntax for JWS and JWE
General JSON Serialization Syntax for JWS and JWE
Compression Method
Supported
Deflate (DEF
)
YES
Key Type
Supported
Comment
oct
YES
Symmetric keys
RSA
YES
RSA based asymmetric keys
EC
YES
Elliptic Curves based asymmetric keys
OKP
YES
Octet Key Pair based asymmetric keys
JWK objects support JSON Web Key Thumbprint (RFC 7638).
A none
key type for the none
algorithm. It is used to explicitly allow this unsecured algorithm.
JWKSet is fully supported.
Signature Algorithm
Supported
Comment
HS256, HS384 and HS512
YES
ES256, ES384 and ES512
YES
RS256, RS384 and RS512
YES
PS256, PS384 and PS512
YES
none
YES
Please note that this is not a secured algorithm. USE IT WITH CAUTION!
EdDSA with Ed25519 curve
YES
EdDSA with Ed448 curve
NO
No extension or built-in implementation available
Other signature algorithms like RS1
, HS1
or HS256/64
are also available. These algorithms should be used for testing purpose only or for compatibility with old systems
Key Encryption Algorithm
Supported
dir
YES
RSA1_5, RSA-OAEP and RSA-OAEP-256
YES
ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW and ECDH-ES+A256KW
YES
A128KW, A192KW and A256KW
YES
PBES2-HS256+A128KW, PBES2-HS384+A192KW and PBES2-HS512+A256KW
YES
A128GCMKW, A192GCMKW and A256GCMKW
YES
ECDH-ES with X25519 curve
YES
ECDH-ES with X448 curve
NO
Other encryption algorithms like RSA-OEAP-384
or ChaCha20-Poly1305
are also available. These algorithms should be used for testing purpose only or for compatibility with old systems
For the ECDH-ES
with X25519 curve with PHP 7.1, the third party extension highly recommended
The algorithms RSA1_5
and RSA-OAEP
are now deprecated. Please use with caution.
Content Encryption Algorithm
Supported
A128CBC+HS256, A192CBC+HS384 and A256CBC+HS512
YES
A128GCM, A192GCM and A256GCM
YES
Other encryption algorithms like A128CTR
, A192CTR
and A256CTR
are also available. These algorithms should be used for testing purpose only or for compatibility with old systems
This framework needs at least:
,
GMP extension.
MBString extension.
Depending on the algorithms you using, other PHP extensions may be required (e.g. OpenSSL).
Please also consider the following optional requirements:
If you intent to use EdDSA
or ECDH-ES
algorithm with Ed25519
/X25519
curves on PHP 7.1, please install this third party extension
In version 2.1, an "Easy" component will be released. With this component you will be able to produce and consume tokens an easy way.
Step 1: install the package web-token/jwt-easy
Step 2: install the or algorithms you want to use. e.g., web-token/jwt-signature-algorithm-rsa
. if you do not, you may encounter an error like "The algorithm "ES256" is not supported."
Step 3: create your scripts.
In the following example, we will create a signed token (JWS) with a set of standard and custom claims and headers.
A token you receive can be read and verified. Verification is done on the signature and the claims or header parameters you want.
If everything is ok, the variable $jwt
contains a Jose\Easy\JWT
object. This object has 2 properties: header
and claims
containing the loaded values.
The JWE creation and loading is very similar to the JWS process as they use common methods. In the following example, we will create an encrypted token (JWE) with a set of standard and custom claims and headers.
The encrypted tokens can be decrypted the same way as the signed ones.
If everything is ok, the variable $jwt
contains a Jose\Easy\JWT
object.
You can create a JWKSet object using three static methods:
new JWKSet(array $keys)
: creates a JWKSet using a list of JWK objects.
JWKSet::createFromJson(string $json)
: creates a JWKSet using a JSON object.
JWKSet::createFromKeyData(array $values)
: creates a JWKSet using a decoded JSON object.
Hereafter all methods available for a JWKSet object. The variable $jwkset
is a valid JWKSet object.
Please note a JWKSet object is an immutable object
Requests for new features, bug fixed and all other ideas to make this framework useful are welcome. If you feel comfortable writing code, you could try to fix or .
Do not forget to .
If you think you have found a security issue, DO NOT open an issue. .