$leeway
$leeway :
When checking nbf, iat or expiration times, we want to provide some extra leeway time to account for clock skew.
JSON Web Token implementation, based on this spec: https://tools.ietf.org/html/rfc7519
PHP version 5
decode(string $jwt, string|array $key, array $allowed_algs = array()) : object
Decodes a JWT string into a PHP object.
string | $jwt | The JWT |
string|array | $key | The key, or map of keys. If the algorithm used is asymmetric, this is the public key |
array | $allowed_algs | List of supported verification algorithms Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
Provided JWT was invalid
Provided JWT was invalid because the signature verification failed
Provided JWT is trying to be used before it's eligible as defined by 'nbf'
Provided JWT is trying to be used before it's been created as defined by 'iat'
Provided JWT has since expired, as defined by the 'exp' claim
The JWT's payload as a PHP object
encode(object|array $payload, string $key, string $alg = 'HS256', mixed $keyId = null, array $head = null) : string
Converts and signs a PHP object or array into a JWT string.
object|array | $payload | PHP object or array |
string | $key | The secret key. If the algorithm used is asymmetric, this is the private key |
string | $alg | The signing algorithm. Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
mixed | $keyId | |
array | $head | An array with header elements to attach |
A signed JWT
sign(string $msg, string|resource $key, string $alg = 'HS256') : string
Sign a string with a given key and algorithm.
string | $msg | The message to sign |
string|resource | $key | The secret key |
string | $alg | The signing algorithm. Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
Unsupported algorithm was specified
An encrypted message
verify(string $msg, string $signature, string|resource $key, string $alg) : boolean
Verify a signature with the message, key and method. Not all methods are symmetric, so we must have a separate verify and sign method.
string | $msg | The original message (header and body) |
string | $signature | The original signature |
string|resource | $key | For HS, a string key works. for RS, must be a resource of an openssl public key |
string | $alg | The algorithm |
Invalid Algorithm or OpenSSL failure