Skip to main content

OnChallenge

Trait OnChallenge 

Source
pub trait OnChallenge:
    Debug
    + Send
    + Sync {
    // Required method
    fn on_challenge<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        context: &'life1 Context<'_>,
        request: &'life2 mut Request,
        authorizer: &'life3 dyn Authorizer,
        headers: &'life4 Headers,
    ) -> 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,
             'life4: 'async_trait;
}
Expand description

Callback BearerTokenAuthorizationPolicy invokes when it receives a 401 Unauthorized response with an authentication challenge (WWW-Authenticate header).

Required Methods§

Source

fn on_challenge<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, context: &'life1 Context<'_>, request: &'life2 mut Request, authorizer: &'life3 dyn Authorizer, headers: &'life4 Headers, ) -> 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, 'life4: 'async_trait,

Called when BearerTokenAuthorizationPolicy receives a 401 Unauthorized response with a challenge.

Implementations are responsible for parsing authentication parameters from the challenge, authorizing the request via the provided Authorizer, and indicating whether the policy should retry the request.

§Arguments
  • context - The request context
  • request - The HTTP request that received the challenge
  • authorizer - Helper used to acquire an access token and set the request’s authorization header
  • headers - The 401 response’s headers
§Returns
  • Ok when the callback handled the challenge and BearerTokenAuthorizationPolicy should retry the request.
  • Err when an error occurred while handling the challenge.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§