CryptoJwt
extends AutoService
in package
The "Crypto JWT" service supports a token format suitable for exchanging/transmitting with external consumers (e.g. web-browsers).
It integrates with the CryptoRegistry (which is a source of valid signing keys).
By default, tokens are signed and validated using any 'SIGN'ing keys (ie 'CIVICRM_SIGN_KEYS').
Tags
Table of Contents
Properties
Methods
- decode() : array<string|int, mixed>
- encode() : string
- getRegistry() : CryptoRegistry
- suiteToAlg() : string
Properties
$registry
protected
CryptoRegistry
$registry
Methods
decode()
public
decode(string $token[, string $keyTag = 'SIGN' ]) : array<string|int, mixed>
Parameters
- $token : string
-
The JWT token.
- $keyTag : string = 'SIGN'
-
Lookup valid keys from the CryptoRegistry using $keyTag.
Tags
Return values
array<string|int, mixed> —List of validated JWT claims.
encode()
public
encode(array<string|int, mixed> $payload[, string $keyIdOrTag = 'SIGN' ]) : string
Parameters
- $payload : array<string|int, mixed>
-
List of JWT claims. See IANA link below.
- $keyIdOrTag : string = 'SIGN'
-
Choose a valid key from the CryptoRegistry using $keyIdOrTag.
Tags
Return values
stringgetRegistry()
protected
getRegistry() : CryptoRegistry
Return values
CryptoRegistrysuiteToAlg()
protected
static suiteToAlg(string $suite) : string
Parameters
- $suite : string
-
Ex: 'jwt-hs256', 'jwt-hs384'
Return values
string —Ex: 'HS256', 'HS384'