Struct poem::web::headers::Authorization

source ·
pub struct Authorization<C>(pub C)
where
    C: Credentials;
Expand description

Authorization header, defined in RFC7235

The Authorization header field allows a user agent to authenticate itself with an origin server – usually, but not necessarily, after receiving a 401 (Unauthorized) response. Its value consists of credentials containing the authentication information of the user agent for the realm of the resource being requested.

§ABNF

Authorization = credentials

§Example values

  • Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
  • Bearer fpKL54jvWmEGVoRdCNjG

§Examples

use headers::Authorization;

let basic = Authorization::basic("Aladdin", "open sesame");
let bearer = Authorization::bearer("some-opaque-token").unwrap();

Tuple Fields§

§0: C

Implementations§

source§

impl Authorization<Basic>

source

pub fn basic(username: &str, password: &str) -> Authorization<Basic>

Create a Basic authorization header.

source

pub fn username(&self) -> &str

View the decoded username.

source

pub fn password(&self) -> &str

View the decoded password.

source§

impl Authorization<Bearer>

source

pub fn bearer(token: &str) -> Result<Authorization<Bearer>, InvalidBearerToken>

Try to create a Bearer authorization header.

source

pub fn token(&self) -> &str

View the token part as a &str.

Trait Implementations§

source§

impl<C> Clone for Authorization<C>
where C: Clone + Credentials,

source§

fn clone(&self) -> Authorization<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C> Debug for Authorization<C>
where C: Debug + Credentials,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<C> Header for Authorization<C>
where C: Credentials,

source§

fn name() -> &'static HeaderName

The name of this header.
source§

fn decode<'i, I>(values: &mut I) -> Result<Authorization<C>, Error>
where I: Iterator<Item = &'i HeaderValue>,

Decode this type from an iterator of HeaderValues.
source§

fn encode<E>(&self, values: &mut E)
where E: Extend<HeaderValue>,

Encode this type to a HeaderMap. Read more
source§

impl<C> PartialEq for Authorization<C>

source§

fn eq(&self, other: &Authorization<C>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<C> StructuralPartialEq for Authorization<C>
where C: Credentials,

Auto Trait Implementations§

§

impl<C> Freeze for Authorization<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Authorization<C>
where C: RefUnwindSafe,

§

impl<C> Send for Authorization<C>
where C: Send,

§

impl<C> Sync for Authorization<C>
where C: Sync,

§

impl<C> Unpin for Authorization<C>
where C: Unpin,

§

impl<C> UnwindSafe for Authorization<C>
where C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyEq for T
where T: Any + PartialEq,

source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> TowerCompatExt for T

source§

fn compat<ResBody, Err, Fut>(self) -> TowerCompatEndpoint<Self>
where ResBody: Body + Send + Sync + 'static, ResBody::Data: Into<Bytes> + Send + 'static, ResBody::Error: StdError + Send + Sync + 'static, Err: Into<Error>, Self: Service<Request<BoxBody<Bytes, Error>>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + Sized + 'static, Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,

Available on crate feature tower-compat only.
Converts a tower service to a poem endpoint.
source§

impl<L> TowerLayerCompatExt for L

source§

fn compat(self) -> TowerCompatMiddleware<Self>
where Self: Sized,

Available on crate feature tower-compat only.
Converts a tower layer to a poem middleware.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more