Skip to main content

Authenticator

Trait Authenticator 

Source
pub trait Authenticator<T>: Send + Sync {
    type AuthContext: Send;

    // Required methods
    fn verify(
        &self,
        hello: &ClientHello,
    ) -> impl Future<Output = Result<Self::AuthContext, ConnectionAuthError>> + Send;
    fn accept(
        &self,
        auth_context: Self::AuthContext,
        connection: ConnectionHandle<T>,
    ) -> impl Future<Output = ()> + Send;
}
Expand description

Authenticator trait for verifying and accepting client connections.

This trait provides authentication logic for incoming connections. Implementations should verify the client’s credentials and optionally perform any setup needed when a connection is accepted.

Required Associated Types§

Source

type AuthContext: Send

Context type that can be passed from verification to acceptance.

Required Methods§

Source

fn verify( &self, hello: &ClientHello, ) -> impl Future<Output = Result<Self::AuthContext, ConnectionAuthError>> + Send

Verifies the client’s hello message and returns an authentication context.

This method is called during the authentication phase to verify the client’s credentials. If verification succeeds, it returns a context that will be passed to accept.

Source

fn accept( &self, auth_context: Self::AuthContext, connection: ConnectionHandle<T>, ) -> impl Future<Output = ()> + Send

Called after successful authentication to handle the accepted connection.

This method is called with the authentication context from verify and a handle to the connection. Implementations can use this to perform any additional setup or logging.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Send + Sync> Authenticator<T> for Secret

Source§

type AuthContext = ()

Source§

async fn verify(&self, hello: &ClientHello) -> Result<(), ConnectionAuthError>

Source§

async fn accept( &self, _auth_context: Self::AuthContext, _connection: ConnectionHandle<T>, )

Implementors§