Skip to main content

Authenticatable

Trait Authenticatable 

Source
pub trait Authenticatable:
    Send
    + Sync
    + 'static {
    // Required methods
    fn auth_identifier(&self) -> String;
    fn auth_password_hash(&self) -> Option<&str>;

    // Provided methods
    fn auth_username_column() -> &'static str
       where Self: Sized { ... }
    fn auth_token_column() -> &'static str
       where Self: Sized { ... }
}
Expand description

A model that can be authenticated.

Implemented on the application’s user model. The framework only ever needs these three facts about it, which is what keeps the guards independent of whatever else a user row holds.

Required Methods§

Source

fn auth_identifier(&self) -> String

The value that identifies this user in a session or a token subject.

Source

fn auth_password_hash(&self) -> Option<&str>

The stored password hash, or None for a user who cannot log in with a password (an SSO-only or machine account).

Provided Methods§

Source

fn auth_username_column() -> &'static str
where Self: Sized,

The column credentials are looked up by — usually email.

Source

fn auth_token_column() -> &'static str
where Self: Sized,

The column holding an API token, when the application issues them.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§