[][src]Struct actix_web_httpauth::extractors::bearer::BearerAuth

pub struct BearerAuth(_);

Extractor for HTTP Bearer auth

Example

use actix_web_httpauth::extractors::bearer::BearerAuth;

async fn index(auth: BearerAuth) -> String {
    format!("Hello, user with token {}!", auth.token())
}

If authentication fails, this extractor fetches the Config instance from the [app data] in order to properly form the WWW-Authenticate response header.

Example

use actix_web::{web, App};
use actix_web_httpauth::extractors::bearer::{BearerAuth, Config};

async fn index(auth: BearerAuth) -> String {
    format!("Hello, {}!", auth.token())
}

fn main() {
    let app = App::new()
        .data(
            Config::default()
                .realm("Restricted area")
                .scope("email photo"),
        )
        .service(web::resource("/index.html").route(web::get().to(index)));
}

Methods

impl BearerAuth[src]

pub fn token(&self) -> &str[src]

Returns bearer token provided by client.

Trait Implementations

impl AuthExtractor for BearerAuth[src]

type Future = Ready<Result<Self, Self::Error>>

Future that resolves into extracted credentials type.

type Error = AuthenticationError<Bearer>

The associated error which can be returned.

impl Clone for BearerAuth[src]

impl Debug for BearerAuth[src]

impl FromRequest for BearerAuth[src]

type Config = Config

Configuration for this extractor

type Future = Ready<Result<Self, Self::Error>>

Future that resolves to a Self

type Error = AuthenticationError<Bearer>

The associated error which can be returned.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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