class Lcobucci extends Provider implements ProviderContract

Constants

ALGO_HS256

ALGO_HS384

ALGO_HS512

ALGO_RS256

ALGO_RS384

ALGO_RS512

ALGO_ES256

ALGO_ES384

ALGO_ES512

Properties

protected Signer $signer \Lcobucci\JWT\Signer.
protected Configuration|null $config

The configuration that signs and verifies tokens.

protected bool $verifiesOnly

Whether the provider has no private key, so it can only verify tokens.

protected array $signers

Signers that this provider supports.

Methods

__construct(string $secret, string $algo, array $keys, Configuration|null $config = null)

Create the Lcobucci provider.

setAlgo(string $algo)

Set the algorithm used to sign the token.

from  Provider
string
getAlgo()

Get the algorithm used to sign the token.

from  Provider
setSecret(string $secret)

Set the secret used to sign the token.

from  Provider
string
getSecret()

Get the secret used to sign the token.

from  Provider
setKeys(array $keys)

Set the keys used to sign the token.

from  Provider
array
getKeys()

Get the array of keys used to sign tokens with an asymmetric algorithm.

from  Provider
string|null
getPublicKey()

Get the public key used to sign tokens with an asymmetric algorithm.

from  Provider
string|null
getPrivateKey()

Get the private key used to sign tokens with an asymmetric algorithm.

from  Provider
string|null
getPassphrase()

Get the passphrase used to sign tokens with an asymmetric algorithm.

from  Provider
mixed
getSigningKey()

Get the key used to sign the tokens.

mixed
getVerificationKey()

Get the key used to verify the tokens.

bool
isAsymmetric()

Determine if the algorithm is asymmetric, and thus requires a public/private key combo.

void
onConfigurationChanged()

Discard the configuration after a setting changes.

string
encode(array $payload)

Create a JSON Web Token.

array
decode(string $token)

Decode a JSON Web Token.

Builder
getBuilderFromClaims(array $payload)

Create an instance of the builder with all of the claims applied.

getDateFromClaim(int|string|DateTimeInterface|DateInterval $value)

Convert a date claim value to a date with whole-second precision.

Configuration
config()

Get the configuration, rebuilding it if the algorithm or keys have changed.

resetConfig()

Discard the configuration so it and the signer are rebuilt on next use.

Configuration
buildConfig()

Build the configuration.

Configuration
configure(Configuration|null $config = null)

Build the signer, and the configuration unless one is given.

Signer
getSigner()

Get the signer instance.

Key
getKey(string $contents, string $passphrase = '')

Get the signing key instance.

Details

at line 54
__construct(string $secret, string $algo, array $keys, Configuration|null $config = null)

Create the Lcobucci provider.

A given configuration signs and verifies tokens instead of one built from the secret and keys.

Parameters

string $secret
string $algo
array $keys
Configuration|null $config

in Provider at line 51
Provider setAlgo(string $algo)

Set the algorithm used to sign the token.

On a provider cached by the shared JwtManager, runtime mutation affects every subsequent request and races across coroutines.

Parameters

string $algo

Return Value

Provider

in Provider at line 63
string getAlgo()

Get the algorithm used to sign the token.

Return Value

string

in Provider at line 76
Provider setSecret(string $secret)

Set the secret used to sign the token.

On a provider cached by the shared JwtManager, runtime mutation affects every subsequent request and races across coroutines.

Parameters

string $secret

Return Value

Provider

in Provider at line 88
string getSecret()

Get the secret used to sign the token.

Return Value

string

in Provider at line 101
Provider setKeys(array $keys)

Set the keys used to sign the token.

On a provider cached by the shared JwtManager, runtime mutation affects every subsequent request and races across coroutines.

Parameters

array $keys

Return Value

Provider

in Provider at line 113
array getKeys()

Get the array of keys used to sign tokens with an asymmetric algorithm.

Return Value

array

in Provider at line 121
string|null getPublicKey()

Get the public key used to sign tokens with an asymmetric algorithm.

Return Value

string|null

in Provider at line 129
string|null getPrivateKey()

Get the private key used to sign tokens with an asymmetric algorithm.

Return Value

string|null

in Provider at line 138
string|null getPassphrase()

Get the passphrase used to sign tokens with an asymmetric algorithm.

Return Value

string|null

at line 297
protected mixed getSigningKey()

Get the key used to sign the tokens.

Return Value

mixed

Exceptions

JwtException

at line 323
protected mixed getVerificationKey()

Get the key used to verify the tokens.

Return Value

mixed

Exceptions

JwtException

at line 285
protected bool isAsymmetric()

Determine if the algorithm is asymmetric, and thus requires a public/private key combo.

Return Value

bool

at line 261
protected void onConfigurationChanged()

Discard the configuration after a setting changes.

A configuration given to the constructor is replaced by one built from the new settings on next use, when invalid settings also raise their configuration error.

Return Value

void

at line 87
string encode(array $payload)

Create a JSON Web Token.

Parameters

array $payload

Return Value

string

Exceptions

JwtException

at line 111
array decode(string $token)

Decode a JSON Web Token.

Parameters

string $token

Return Value

array

Exceptions

JwtException

at line 146
protected Builder getBuilderFromClaims(array $payload)

Create an instance of the builder with all of the claims applied.

Parameters

array $payload

Return Value

Builder

at line 186
protected DateTimeImmutable getDateFromClaim(int|string|DateTimeInterface|DateInterval $value)

Convert a date claim value to a date with whole-second precision.

Parameters

int|string|DateTimeInterface|DateInterval $value

Return Value

DateTimeImmutable

at line 202
protected Configuration config()

Get the configuration, rebuilding it if the algorithm or keys have changed.

Return Value

Configuration

at line 212
protected Lcobucci resetConfig()

Discard the configuration so it and the signer are rebuilt on next use.

Return Value

Lcobucci

at line 223
protected Configuration buildConfig()

Build the configuration.

Return Value

Configuration

at line 246
protected Configuration configure(Configuration|null $config = null)

Build the signer, and the configuration unless one is given.

Parameters

Configuration|null $config

Return Value

Configuration

Exceptions

JwtException

at line 271
protected Signer getSigner()

Get the signer instance.

Return Value

Signer

Exceptions

JwtException

at line 347
protected Key getKey(string $contents, string $passphrase = '')

Get the signing key instance.

Parameters

string $contents
string $passphrase

Return Value

Key