Trait tower_http::auth::AuthorizeRequest
source · [−]pub trait AuthorizeRequest {
type Output;
type ResponseBody: Body;
fn authorize<B>(&mut self, request: &Request<B>) -> Option<Self::Output>;
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.
type ResponseBody: Body
type ResponseBody: Body
The body type used for responses to unauthorized requests.
Required methods
Authorize the request.
If Some(_)
is returned 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.