Skip to main content

UserProvider

Trait UserProvider 

Source
pub trait UserProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn authenticate<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        id: Identity<'life1>,
        password: Password<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn authorize<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        catalog: &'life1 str,
        schema: &'life2 str,
        user_info: &'life3 UserInfoRef,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided methods
    fn auth<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        id: Identity<'life1>,
        password: Password<'life2>,
        catalog: &'life3 str,
        schema: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait { ... }
    fn authenticate_bearer_token<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _token: &'life1 str,
        _catalog: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn auth_bearer_token<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        token: &'life1 str,
        catalog: &'life2 str,
        schema: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn mysql_auth_method(&self) -> MysqlAuthMethod { ... }
    fn mysql_auth_method_for_user<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _username: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<MysqlAuthMethod>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn postgres_auth_info<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _id: Identity<'life1>,
        _catalog: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<PgAuthInfo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn external(&self) -> bool { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Source

fn authenticate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: Identity<'life1>, password: Password<'life2>, ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Checks whether a user is valid and allowed to access the database.

Source

fn authorize<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, catalog: &'life1 str, schema: &'life2 str, user_info: &'life3 UserInfoRef, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Checks whether a connection request from a certain user to a certain catalog/schema is legal. This method should be called after authenticate().

Provided Methods§

Source

fn auth<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, id: Identity<'life1>, password: Password<'life2>, catalog: &'life3 str, schema: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Combination of authenticate() and authorize(). In most cases it’s preferred for both convenience and performance.

Source

fn authenticate_bearer_token<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _token: &'life1 str, _catalog: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Authenticates an opaque bearer token (e.g. a JWT or an OAuth2 access token) and derives its user identity.

Unlike auth(), the caller has no Identity/Password — the provider validates the token and derives the identity from it. The token is opaque to the server, so JWT/JWKS/OIDC validation policy stays pluggable and out of core.

The default rejects token auth with [Error::UnsupportedAuthMethod], so password-only providers keep today’s behavior. Providers that support token auth override this to validate the token and resolve it to a user.

Source

fn auth_bearer_token<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, token: &'life1 str, catalog: &'life2 str, schema: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<UserInfoRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source

fn mysql_auth_method(&self) -> MysqlAuthMethod

Source

fn mysql_auth_method_for_user<'life0, 'life1, 'async_trait>( &'life0 self, _username: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<MysqlAuthMethod>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Selects authentication after the MySQL handshake supplies a username. The user is resolved in the same scope as authenticate.

Source

fn postgres_auth_info<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _id: Identity<'life1>, _catalog: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<PgAuthInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn external(&self) -> bool

Returns whether this user provider implementation is backed by an external system.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§