|
static | constantTimeEquals (string $left, string $right) |
|
static static | decode (string $jwt, $keyOrKeyArray) |
| Decodes a JWT string into a PHP object.
|
|
static | encode (array $payload, $key, string $alg, string $keyId=null, array $head=null) |
| Converts and signs a PHP array into a JWT string.
|
|
static | jsonDecode (string $input) |
| Decode a JSON string into a PHP object.
|
|
static | jsonEncode (array $input) |
| Encode a PHP array into a JSON string.
|
|
static | sign (string $msg, $key, string $alg) |
| Sign a string with a given key and algorithm.
|
|
static | urlsafeB64Decode (string $input) |
| Decode a string with URL-safe Base64.
|
|
static | urlsafeB64Encode (string $input) |
| Encode a string with URL-safe Base64.
|
|
|
static int | $leeway = 0 |
| When checking nbf, iat or expiration times, we want to provide some extra leeway time to account for clock skew.
|
|
static int | $timestamp = null |
| Allow the current timestamp to be specified.
|
|
static | array< string, $supported_algs=['ES384'=> ['openssl', 'SHA384'] |
| string[]>
|
|
◆ constantTimeEquals()
static JWT::constantTimeEquals |
( |
string | $left, |
|
|
string | $right ) |
|
static |
- Parameters
-
string | $left | The string of known length to compare against |
string | $right | The user-supplied string |
- Return values
-
◆ decode()
static static JWT::decode |
( |
string | $jwt, |
|
|
| $keyOrKeyArray ) |
|
static |
Decodes a JWT string into a PHP object.
- Parameters
-
string | $jwt | The JWT |
| Key|array<string,Key> | $keyOrKeyArray The Key or associative array of key IDs (kid) to Key objects. If the algorithm used is asymmetric, this is the public key Each Key object contains an algorithm and matching key. Supported algorithms are 'ES384','ES256', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', and 'RS512' |
- Return values
-
stdClass | The JWT's payload as a PHP object |
- Exceptions
-
InvalidArgumentException | Provided key/key-array was empty or malformed |
DomainException | Provided JWT is malformed |
UnexpectedValueException | Provided JWT was invalid |
SignatureInvalidException | Provided JWT was invalid because the signature verification failed |
BeforeValidException | Provided JWT is trying to be used before it's eligible as defined by 'nbf' |
BeforeValidException | Provided JWT is trying to be used before it's been created as defined by 'iat' |
ExpiredException | Provided JWT has since expired, as defined by the 'exp' claim |
@uses jsonDecode @uses urlsafeB64Decode
◆ encode()
static JWT::encode |
( |
array | $payload, |
|
|
| $key, |
|
|
string | $alg, |
|
|
string | $keyId = null, |
|
|
array | $head = null ) |
|
static |
Converts and signs a PHP array into a JWT string.
- Parameters
-
| array<mixed> | $payload PHP array |
string | resource | OpenSSLAsymmetricKey | OpenSSLCertificate | $key | The secret key. |
string | $alg | Supported algorithms are 'ES384','ES256', 'ES256K', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', and 'RS512' |
string | $keyId | |
| array<string,string> | $head An array with header elements to attach |
- Return values
-
@uses jsonEncode @uses urlsafeB64Encode
◆ jsonDecode()
static JWT::jsonDecode |
( |
string | $input | ) |
|
|
static |
Decode a JSON string into a PHP object.
- Parameters
-
- Return values
-
mixed | The decoded JSON string |
- Exceptions
-
DomainException | Provided string was invalid JSON |
◆ jsonEncode()
static JWT::jsonEncode |
( |
array | $input | ) |
|
|
static |
Encode a PHP array into a JSON string.
- Parameters
-
array<mixed> | $input A PHP array |
- Return values
-
string | JSON representation of the PHP array |
- Exceptions
-
DomainException | Provided object could not be encoded to valid JSON |
◆ sign()
static JWT::sign |
( |
string | $msg, |
|
|
| $key, |
|
|
string | $alg ) |
|
static |
Sign a string with a given key and algorithm.
- Parameters
-
string | $msg | The message to sign |
string | resource | OpenSSLAsymmetricKey | OpenSSLCertificate | $key | The secret key. |
string | $alg | Supported algorithms are 'ES384','ES256', 'ES256K', 'HS256', 'HS384', 'HS512', 'RS256', 'RS384', and 'RS512' |
- Return values
-
string | An encrypted message |
- Exceptions
-
DomainException | Unsupported algorithm or bad key was specified |
◆ urlsafeB64Decode()
static JWT::urlsafeB64Decode |
( |
string | $input | ) |
|
|
static |
Decode a string with URL-safe Base64.
- Parameters
-
string | $input | A Base64 encoded string |
- Return values
-
- Exceptions
-
InvalidArgumentException | invalid base64 characters |
◆ urlsafeB64Encode()
static JWT::urlsafeB64Encode |
( |
string | $input | ) |
|
|
static |
Encode a string with URL-safe Base64.
- Parameters
-
string | $input | The string you want encoded |
- Return values
-
string | The base64 encode of what you passed in |
◆ $timestamp
int JWT::$timestamp = null |
|
static |
Allow the current timestamp to be specified.
Useful for fixing a value within unit testing. Will default to PHP time() value if null.
The documentation for this class was generated from the following file: