A security token generator based on the branca token specification.
A security token contains signed and encrypted data which only the generator can decode. It is used for various purposes, such as:
The payload of the token is a JSON object with the following keys defined:
i - a random generated identifier for the tokeno - token options, consisting of the sum of the OPTION_
constants defined by this classp - the payloads (optional) - the session ID| Methods | ||
|---|---|---|
public
|
__construct(string $key = null)
|
# |
public
|
getPayload(string $token, int $ttl = null): mixed
|
# |
public
|
verify(string $token, string $expected, int $ttl = null): bool
|
# |
public
|
generate(mixed $payload, int $options = self::OPTION_DEFAULT): string
|
# |
| Constants | |||
|---|---|---|---|
public
|
OPTION_DEFAULT = 0
|
# | |
public
|
OPTION_BIND_SESSION = 1
|
# | |
public
|
OPTION_NONCE = 2
|
# | |