Struct actix_web_httpauth::extractors::basic::BasicAuth[][src]

pub struct BasicAuth(_);

Extractor for HTTP Basic auth.

Example

use actix_web::Result;
use actix_web_httpauth::extractors::basic::BasicAuth;

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

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::basic::{BasicAuth, Config};

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

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

Implementations

impl BasicAuth[src]

pub fn user_id(&self) -> &Cow<'static, str>[src]

Returns client’s user-ID.

pub fn password(&self) -> Option<&Cow<'static, str>>[src]

Returns client’s password.

Trait Implementations

impl AuthExtractor for BasicAuth[src]

type Error = AuthenticationError<Challenge>

The associated error which can be returned.

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

Future that resolves into extracted credentials type.

impl Clone for BasicAuth[src]

impl Debug for BasicAuth[src]

impl FromRequest for BasicAuth[src]

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

Future that resolves to a Self.

type Config = Config

Configuration for this extractor.

type Error = AuthenticationError<Challenge>

The associated error which can be returned.

Auto Trait Implementations

impl RefUnwindSafe for BasicAuth

impl Send for BasicAuth

impl Sync for BasicAuth

impl Unpin for BasicAuth

impl UnwindSafe for BasicAuth

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> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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>,