pub trait AsyncAuthorizeRequest {
    type Output;
    type Future: Future<Output = Option<Self::Output>>;
    type ResponseBody: Body;
    fn authorize<B>(&mut self, request: &Request<B>) -> Self::Future;
fn unauthorized_response<B>(
        &mut self,
        request: &Request<B>
    ) -> Response<Self::ResponseBody>; fn on_authorized<B>(
        &mut self,
        _request: &mut Request<B>,
        _output: Self::Output
    ) { ... } }
This is supported on crate feature auth only.
Expand description

Trait for authorizing requests.

Associated Types

The output type of doing the authorization.

Use () if authorization doesn’t produce any meaningful output.

The Future type returned by authorize

The body type used for responses to unauthorized requests.

Required methods

Authorize the request.

If the future resolves to Some(_) then the request is allowed through, otherwise not.

Create the response for an unauthorized request.

Provided methods

Callback for when a request has been successfully authorized.

For example this allows you to save Self::Output in a request extension to make it available to services further down the stack. This could for example be the “claims” for a valid JWT.

Defaults to doing nothing.

See the module docs for an example.

Implementors