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§
Structs§
- Guard
- The
sanctumguard, for the tokenable modelU: Sanctum’sGuard, which Laravel runs as a request guard. - Missing
Ability - The current access token is missing an ability a route requires:
MissingAbilityException, which renders as a403like Laravel’sAuthorizationException. - Missing
Scope - The current access token is missing a scope a route requires:
MissingScopeException, from the deprecated scope middleware. - NewAccess
Token - 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.
- Pending
Token - A token being created by
HasApiTokens::create_token. Await it to store the token. - Personal
Access Token - A row of the
personal_access_tokenstable: an API token issued to a tokenable model, such as the application’sUser. - Sanctum
- Sanctum’s helpers: the
Sanctumclass. - Sanctum
Config - Sanctum’s settings, read from the environment like
config/sanctum.php. - Sanctum
Service Provider - Registers Sanctum’s configuration, migration,
sanctumguards, CSRF cookie route, andsanctum:prune-expiredcommand. - Transient
Token - The token of a user whom a first-party session authenticated rather than an API token. It
has every ability, so
token_canpasses for SPA requests. - Unauthenticated
- A user without an access token where a route needs one. A guest gets Laravel’s own
unauthenticated error, as
Authenticategives 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§
- Access
Token - The token a request was authenticated with, which
current_access_tokenreturns: aPersonalAccessTokenfor a bearer token, or aTransientTokenfor a session.
Traits§
- HasAbilities
- Something that has abilities, such as a token: the
HasAbilitiescontract of Sanctum. - HasApi
Tokens - A model that can issue API tokens and be authenticated by them, such as the application’s
User: theHasApiTokenstrait of Sanctum.
Functions§
- authenticate
- The middleware that lets through only requests that the
sanctumguard authenticates as aU: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
Uthat thesanctumguard authenticates the request as, orNonefor a guest:$request->user('sanctum').