Skip to main content

Module auth

Module auth 

Source
Expand description

API clients and scopes, as the PHP package’s ResolveClient and AuthorizeScopes middleware and ApiKey model provide them.

Each request to an API route is resolved to an ApiClient, or to a guest. With the database feature, Authorization: Bearer fs_live_… and fs_test_… keys from the api_keys table are resolved by the crate itself; Config::client_resolver adds your own authentication, which runs first. A client’s pinned version is used when a request has no Api-Version header. Routes ask for scopes with RequiresScope.

Structs§

ApiClient
Who made a request.
RequiresScope
Route middleware that requires the client to have a scope, as #[RequiresScope] does in PHP. Guests get a 401 unauthenticated, and clients without the scope a 403 insufficient_scope.

Functions§

client
The client a request was authenticated as, or None for a guest.
resolver
Wraps an async function as a ClientResolver.

Type Aliases§

ClientResolver
Your own authentication: given the request’s headers, the client they authenticate, or None to try the next way (the crate’s API keys) and then treat the request as a guest’s.