Skip to main content

Crate laravel_sanctum

Crate laravel_sanctum 

Source
Expand description

Laravel Sanctum for Laravel Rust: API tokens and cookie authentication for first-party SPAs.

A community port of Laravel Sanctum by Rivervo. See the README for installation and usage.

Re-exports§

pub use http::CheckAbilities;
pub use http::CheckForAnyAbility;
pub use http::CheckForAnyScope;
pub use http::CheckScopes;
pub use http::EnsureFrontendRequestsAreStateful;

Modules§

events
The events Sanctum dispatches.
http
Sanctum’s middleware and its CSRF cookie route.

Structs§

Guard
The sanctum guard, for the tokenable model U: Sanctum’s Guard, which Laravel runs as a request guard.
MissingAbility
The current access token is missing an ability a route requires: MissingAbilityException, which renders as a 403 like Laravel’s AuthorizationException.
MissingScope
The current access token is missing a scope a route requires: MissingScopeException, from the deprecated scope middleware.
NewAccessToken
A newly created token, with the plain-text token to give the client. The plain-text token is only available now: the database holds its hash.
PendingToken
A token being created by HasApiTokens::create_token. Await it to store the token.
PersonalAccessToken
A row of the personal_access_tokens table: an API token issued to a tokenable model, such as the application’s User.
Sanctum
Sanctum’s helpers: the Sanctum class.
SanctumConfig
Sanctum’s settings, read from the environment like config/sanctum.php.
SanctumServiceProvider
Registers Sanctum’s configuration, migration, sanctum guards, CSRF cookie route, and sanctum:prune-expired command.
TransientToken
The token of a user whom a first-party session authenticated rather than an API token. It has every ability, so token_can passes for SPA requests.
Unauthenticated
A user without an access token where a route needs one. A guest gets Laravel’s own unauthenticated error, as Authenticate gives one.
prune_expired
Prune tokens expired for more than specified number of hours
publish
Copy Sanctum’s migration into the application, so you can customize it: vendor:publish --tag=sanctum-migrations.

Enums§

AccessToken
The token a request was authenticated with, which current_access_token returns: a PersonalAccessToken for a bearer token, or a TransientToken for a session.

Traits§

HasAbilities
Something that has abilities, such as a token: the HasAbilities contract of Sanctum.
HasApiTokens
A model that can issue API tokens and be authenticated by them, such as the application’s User: the HasApiTokens trait of Sanctum.

Functions§

authenticate
The middleware that lets through only requests that the sanctum guard authenticates as a U: auth:sanctum.
prune_expired
Prune tokens expired for more than specified number of hours
publish
Copy Sanctum’s migration into the application, so you can customize it: vendor:publish --tag=sanctum-migrations.
user
The U that the sanctum guard authenticates the request as, or None for a guest: $request->user('sanctum').