class JwtManager extends Manager implements ManagerContract

Traits

Properties

protected Repository $config

The configuration repository instance.

from  Manager
protected Closure> $customCreators

The registered custom driver creators.

from  Manager
protected array<array-key, mixed> $drivers

The array of created "drivers".

from  Manager
protected BlacklistContract|null $blacklist
protected bool $blacklistEnabled
protected array $validations

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

__construct(Container $container, ClaimFactory $claimFactory)

Create a new manager instance.

string|null
getDefaultDriver()

Get the default driver name.

mixed
driver(UnitEnum|string|null $driver = null)

Get a driver instance.

from  Manager
mixed
createDriver(string $driver)

Create a new driver instance.

from  Manager
string|null
getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

from  Manager
mixed
callCustomCreator(string $driver)

Call a custom driver creator.

from  Manager
extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

from  Manager
array
getDrivers()

Get all of the created "drivers".

from  Manager
getContainer()

Get the container instance used by the manager.

from  Manager
setContainer(Container $container)

Set the container instance used by the manager.

from  Manager
forgetDrivers()

Forget all of the resolved driver instances.

from  Manager
mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

from  Manager
createLcobucciDriver()

Create an instance of the Lcobucci JWT Driver.

string
encode(array $payload)

Encode a payload into a token.

array
decode(string $token, bool $validate = true, bool $checkBlacklist = true)

Decode a token into its payload.

void
validatePayload(array $payload, bool $refresh = false)

Run the configured validations against a decoded payload.

getValidation(string $class)

Get the cached validation instance for the given class.

string
refresh(string $token, bool $forceForever = false, bool $resetClaims = false, array $customClaims = [], int|false|null $ttl = false)

Refresh a token.

array
decodeForRefresh(string $token)

Decode a token for refresh.

bool
invalidate(string $token, bool $forceForever = false)

Invalidate a token.

void
validateRefreshWindow(array $payload)

Validate that the token is still refreshable.

bool
hasBlacklistEnabled()

Determine if the blacklist is enabled.

blacklist()

Get the blacklist instance.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

at line 33
__construct(Container $container, ClaimFactory $claimFactory)

Create a new manager instance.

Parameters

Container $container
ClaimFactory $claimFactory

at line 57
string|null getDefaultDriver()

Get the default driver name.

Return Value

string|null

in Manager at line 60
mixed driver(UnitEnum|string|null $driver = null)

Get a driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 92
protected mixed createDriver(string $driver)

Create a new driver instance.

Parameters

string $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 113
protected string|null getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

Parameters

string $driver

Return Value

string|null

in Manager at line 124
protected mixed callCustomCreator(string $driver)

Call a custom driver creator.

Parameters

string $driver

Return Value

mixed

in Manager at line 140
Manager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Anonymous closures run in this manager's class scope; non-static closures also receive the manager as $this.

The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent driver resolution.

Parameters

string $driver
Closure $callback

Return Value

Manager

in Manager at line 160
array getDrivers()

Get all of the created "drivers".

Return Value

array

in Manager at line 168
Container getContainer()

Get the container instance used by the manager.

Return Value

Container

in Manager at line 182
Manager setContainer(Container $container)

Set the container instance used by the manager.

Swaps the singleton's container and configuration references; per-request use races across coroutines and breaks every concurrent driver resolution through this manager.

Parameters

Container $container

Return Value

Manager

in Manager at line 199
Manager forgetDrivers()

Forget all of the resolved driver instances.

Clears the singleton's driver cache; concurrent coroutines may already hold references that next resolution will not share.

Return Value

Manager

in Manager at line 210
mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed

at line 45
Lcobucci createLcobucciDriver()

Create an instance of the Lcobucci JWT Driver.

Return Value

Lcobucci

at line 65
string encode(array $payload)

Encode a payload into a token.

Parameters

array $payload

Return Value

string

at line 77
array decode(string $token, bool $validate = true, bool $checkBlacklist = true)

Decode a token into its payload.

Parameters

string $token
bool $validate
bool $checkBlacklist

Return Value

array

at line 95
protected void validatePayload(array $payload, bool $refresh = false)

Run the configured validations against a decoded payload.

Parameters

array $payload
bool $refresh

Return Value

void

at line 111
protected ValidationContract getValidation(string $class)

Get the cached validation instance for the given class.

Parameters

string $class

Return Value

ValidationContract

at line 123
string refresh(string $token, bool $forceForever = false, bool $resetClaims = false, array $customClaims = [], int|false|null $ttl = false)

Refresh a token.

Parameters

string $token
bool $forceForever
bool $resetClaims
array $customClaims
int|false|null $ttl

Return Value

string

at line 160
protected array decodeForRefresh(string $token)

Decode a token for refresh.

Parameters

string $token

Return Value

array

at line 176
bool invalidate(string $token, bool $forceForever = false)

Invalidate a token.

Parameters

string $token
bool $forceForever

Return Value

bool

at line 197
protected void validateRefreshWindow(array $payload)

Validate that the token is still refreshable.

Parameters

array $payload

Return Value

void

at line 228
bool hasBlacklistEnabled()

Determine if the blacklist is enabled.

Return Value

bool

at line 236
BlacklistContract blacklist()

Get the blacklist instance.

Return Value

BlacklistContract