Skip to main content

Authenticator

Trait Authenticator 

Source
pub trait Authenticator: Send + Sync {
    // Required method
    fn authenticate(&self, bearer: &str) -> Result<Principal, AuthError>;
}
Expand description

Turns a presented bearer token into a Principal, or rejects it.

Implementations must deny by default: an empty or unrecognised bearer is an error, never an anonymous pass. A transport calls this before it routes to a handler, so an unauthenticated request never reaches business logic with a forged identity.

Required Methods§

Source

fn authenticate(&self, bearer: &str) -> Result<Principal, AuthError>

Authenticate bearer (the raw token, the Bearer scheme already stripped). Return the Principal on success, or the reason it failed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§