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§
Sourcetype AuthContext: Send
type AuthContext: Send
Context type that can be passed from verification to acceptance.
Required Methods§
Sourcefn verify(
&self,
hello: &ClientHello,
) -> impl Future<Output = Result<Self::AuthContext, ConnectionAuthError>> + Send
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.
Sourcefn accept(
&self,
auth_context: Self::AuthContext,
connection: ConnectionHandle<T>,
) -> impl Future<Output = ()> + Send
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.