Skip to main content

Authenticate

Trait Authenticate 

Source
pub trait Authenticate:
    Sized
    + Send
    + 'static {
    type Credentials: FromRequestParts;

    // Required method
    fn authenticate(
        credentials: Self::Credentials,
        required: &[&'static str],
        parts: &Parts,
    ) -> impl Future<Output = Result<Self, ApiError>> + Send;
}
Expand description

User-defined principal built from a scheme’s credentials.

authenticate receives the scopes the endpoint requires and the request [Parts]; application state set with App::with_state is reachable through parts.extensions. Return 401 for invalid credentials and 403 (see check_scopes) for missing scopes.

Required Associated Types§

Source

type Credentials: FromRequestParts

The scheme that supplies the credentials.

Required Methods§

Source

fn authenticate( credentials: Self::Credentials, required: &[&'static str], parts: &Parts, ) -> impl Future<Output = Result<Self, ApiError>> + Send

Validate credentials and build the principal.

§Errors

An ApiError, typically 401 or 403.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§