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

pub struct BasicAuth(_);

Extractor for HTTP Basic auth.

Example

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

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};

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)));
}

Methods

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.

pub fn from_service_request(
    req: &mut ServiceRequest,
    config: &Config
) -> Self::Future
[src]

Try to parse actix-web' ServiceRequest and fetch the BasicAuth from it.

Warning

This function is used right now for middleware creation only and might change or be totally removed, depends on actix-web = "1.0" release changes.

This issue will be resolved in the 0.3.0 release. Before that -- brace yourselves!

Trait Implementations

impl Clone for BasicAuth[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for BasicAuth[src]

impl FromRequest for BasicAuth[src]

type Future = 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.

fn extract(req: &HttpRequest) -> Self::Future[src]

Convert request to a Self Read more

fn configure<F>(f: F) -> Self::Config where
    F: FnOnce(Self::Config) -> Self::Config
[src]

Create and configure config instance.

Auto Trait Implementations

impl Send for BasicAuth

impl Sync for BasicAuth

Blanket Implementations

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<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Erased for T