Struct tower_http::auth::AddAuthorizationLayer
source · [−]pub struct AddAuthorizationLayer { /* private fields */ }
auth
only.Expand description
Layer that applies AddAuthorization
which adds authorization to all requests using the
Authorization
header.
See the module docs for an example.
You can also use SetRequestHeader
if you have a use case that isn’t supported by this
middleware.
Implementations
Authorize requests using a username and password pair.
The Authorization
header will be set to Basic {credentials}
where credentials
is
base64_encode("{username}:{password}")
.
Since the username and password is sent in clear text it is recommended to use HTTPS/TLS with this method. However use of HTTPS/TLS is not enforced by this middleware.
Authorize requests using a “bearer token”. Commonly used for OAuth 2.
The Authorization
header will be set to Bearer {token}
.
Panics
Panics if the token is not a valid HeaderValue
.
Mark the header as sensitive.
This can for example be used to hide the header value from logs.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for AddAuthorizationLayer
impl Send for AddAuthorizationLayer
impl Sync for AddAuthorizationLayer
impl Unpin for AddAuthorizationLayer
impl UnwindSafe for AddAuthorizationLayer
Blanket Implementations
Mutably borrows from an owned value. Read more
follow-redirect
only.Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more