JWT
class JWT
This class provides a set of functions related to Json Web Token
A JSON Web Token (JWT) includes three sections:
- 0: Header
- 1: Payload
- 2: Signature
They are encoded as Base64url strings, and are separated by dot "." characters.
Methods
Decodes a section of the JSON Web Token and returns it.
Decodes a string encoded in url-safe base64 and returns it.
Encodes a length according to ASN.1 encoding rules
Extracts the JSON Web Key (JWK) for RSA signature from a JSON Web Key Set (JWKS) and the header of a JSON Web Token
Creates a public key in PEM format from the given key which is extracted from a JSON Web Key Set (JWKS)
Verifies the signature of a JSON Web Token using an RSA algorithm.
Verifies the signature of a JSON Web Token using an HMAC algorithm.
Details
at line 31
static object|string
decode(string $jwt, int $section = 0, bool $object = true)
Decodes a section of the JSON Web Token and returns it.
at line 45
static private string
safeBase64Decode(string $part)
Decodes a string encoded in url-safe base64 and returns it.
at line 61
static private string
encodeASNLength(int $length)
Encodes a length according to ASN.1 encoding rules
at line 79
static private object
extractRSAKey(object $keys, object $header)
Extracts the JSON Web Key (JWK) for RSA signature from a JSON Web Key Set (JWKS) and the header of a JSON Web Token
at line 103
static private string
createPemPublicKey(object $key)
Creates a public key in PEM format from the given key which is extracted from a JSON Web Key Set (JWKS)
at line 141
static bool
verifyRSASignature(object $header, object $keys, string $jwt)
Verifies the signature of a JSON Web Token using an RSA algorithm.
at line 176
static bool
verifyHMACsignature(object $header, string $jwt, string $key)
Verifies the signature of a JSON Web Token using an HMAC algorithm.