class Sanctum

Constants

protected DEFAULT_PERSONAL_ACCESS_TOKEN_MODEL

Properties

static TToken> $personalAccessTokenModel

The personal access client model class name.

static null|callable $accessTokenRetrievalCallback

A callback that can get the token from the request.

static null|callable $accessTokenAuthenticationCallback

A callback that can add to the validation of the access token.

static string $currentRequestHostPlaceholder

A placeholder to instruct Sanctum to include the current request host in the list of stateful domains.

Methods

static string
currentApplicationUrlWithPort()

Get the current application URL from the "APP_URL" environment variable - with port.

static string
currentRequestHost()

Get a fixed token instructing Sanctum to include the current request host in the list of stateful domains.

static mixed
actingAs(HasApiTokens $user, array $abilities = [], string $guard = 'sanctum')

Set the current user for the application with the given abilities.

static void
usePersonalAccessTokenModel(string $model)

Set the personal access token model name.

static void
getAccessTokenFromRequestUsing(callable|null $callback)

Specify a callback that should be used to fetch the access token from the request.

static void
authenticateAccessTokensUsing(callable $callback)

Specify a callback that should be used to authenticate access tokens.

static string
personalAccessTokenModel()

Get the token model class name.

static void
flushState()

Flush all static state.

Details

at line 48
static string currentApplicationUrlWithPort()

Get the current application URL from the "APP_URL" environment variable - with port.

Return Value

string

at line 58
static string currentRequestHost()

Get a fixed token instructing Sanctum to include the current request host in the list of stateful domains.

Return Value

string

at line 69
static mixed actingAs(HasApiTokens $user, array $abilities = [], string $guard = 'sanctum')

Set the current user for the application with the given abilities.

Parameters

HasApiTokens $user
array $abilities
string $guard

Return Value

mixed

at line 105
static void usePersonalAccessTokenModel(string $model)

Set the personal access token model name.

Boot-only. The model class name persists in a static property for the worker lifetime and is used for every token resolution across all coroutines.

Parameters

string $model

Return Value

void

at line 116
static void getAccessTokenFromRequestUsing(callable|null $callback)

Specify a callback that should be used to fetch the access token from the request.

Boot-only. The callback persists in a static property for the worker lifetime and runs on every token retrieval across all coroutines.

Parameters

callable|null $callback

Return Value

void

at line 127
static void authenticateAccessTokensUsing(callable $callback)

Specify a callback that should be used to authenticate access tokens.

Boot-only. The callback persists in a static property for the worker lifetime and runs on every token authentication across all coroutines.

Parameters

callable $callback

Return Value

void

at line 137
static string personalAccessTokenModel()

Get the token model class name.

Return Value

string

at line 145
static void flushState()

Flush all static state.

Return Value

void