class AuthToken

Class AuthToken

The token-based authentication feature allows you to limit the validity of the asset delivery URL to a specific time frame. An authentication token is added as query parameters to the delivery URL, and is used to validate authentication before delivering the asset.

Properties

AuthTokenConfig $config

Methods

__construct(Configuration|string|array|null $configuration = null)

AuthToken constructor.

fromJson(Configuration|string|array|null $configuration = null)

AuthToken named constructor.

isEnabled()

Indicates whether according to the current configuration, AuthToken is enabled or not

configuration(mixed $configuration)

Sets the configuration.

generate(null|string $path = null)

Generates an authorization token.

Details

__construct(Configuration|string|array|null $configuration = null)

AuthToken constructor.

Parameters

Name Type Description
$configuration Configuration|string|array|null The Configuration source.

static AuthToken fromJson(Configuration|string|array|null $configuration = null)

AuthToken named constructor.

Parameters

Name Type Description
$configuration Configuration|string|array|null The Configuration source.

Return Value

AuthToken

bool isEnabled()

Indicates whether according to the current configuration, AuthToken is enabled or not

Return Value

bool

AuthToken configuration(mixed $configuration)

Sets the configuration.

Parameters

Name Type Description
$configuration mixed The configuration to set.

Return Value

AuthToken

string generate(null|string $path = null)

Generates an authorization token.

Options: number start_time - the start time of the token in seconds from epoch. string expiration - the expiration time of the token in seconds from epoch. string duration - the duration of the token (from start_time). string ip - the IP address of the client. string acl - the ACL for the token. string url - the URL to authentication in case of a URL token.

Parameters

Name Type Description
$path null|string url path to sign. Ignored if acl is set.

Return Value

string The authorization token.

Exceptions

UnexpectedValueException if neither expiration nor duration nor one of acl or url were provided.

Constants

UNSAFE

AUTH_TOKEN_NAME

TOKEN_SEPARATOR

TOKEN_INNER_SEPARATOR

TOKEN_ACL_SEPARATOR