Struct actix_web_httpauth::extractors::basic::BasicAuth [−][src]
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.
fn from_service_request(req: &ServiceRequest) -> Self::Future
[src]
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.
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
[src]
pub fn extract(req: &HttpRequest) -> Self::Future
pub fn configure<F>(f: F) -> Self::Config where
F: FnOnce(Self::Config) -> Self::Config,
F: FnOnce(Self::Config) -> Self::Config,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,