Skip to main content

Authenticator

Trait Authenticator 

Source
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§

Source

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

Provided Methods§

Source

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§