pub trait Authenticator:
Send
+ Sync
+ 'static {
// Required method
fn authenticate<'a>(&'a self, ctx: &'a Context) -> AuthFuture<'a>;
// Provided method
fn authenticate_sync(
&self,
_ctx: &Context,
) -> Option<Result<AuthPrincipal, AuthError>> { ... }
}Expand description
Pluggable asynchronous authenticator resolving a Hyperlane Context into an AuthPrincipal.
Required Methods§
Sourcefn authenticate<'a>(&'a self, ctx: &'a Context) -> AuthFuture<'a>
fn authenticate<'a>(&'a self, ctx: &'a Context) -> AuthFuture<'a>
Authenticates the incoming request represented by ctx.
§Arguments
&'a self- Shared reference to self.&'a Context- Incoming request context.
§Returns
AuthFuture<'a>- Future resolving to the verifiedAuthPrincipalorAuthError.
Provided Methods§
Sourcefn authenticate_sync(
&self,
_ctx: &Context,
) -> Option<Result<AuthPrincipal, AuthError>>
fn authenticate_sync( &self, _ctx: &Context, ) -> Option<Result<AuthPrincipal, AuthError>>
Optional zero-allocation synchronous fast path for non-blocking authenticators.
Returning Some(result) bypasses Box::pin future allocation on the hot request path.
Returning None falls back to Authenticator::authenticate.
§Arguments
&Self- Shared reference to self.&Context- Incoming request context.
§Returns
Option<Result<AuthPrincipal, AuthError>>- Synchronous authentication result when available.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Authenticator for ApiKeyAuthenticator
Implements Authenticator for ApiKeyAuthenticator.
impl Authenticator for BasicAuthenticator
Implements Authenticator for BasicAuthenticator.
impl Authenticator for CompositeAuthenticator
Implements Authenticator for CompositeAuthenticator.
impl Authenticator for JwtAuthenticator
Implements Authenticator for JwtAuthenticator.