[−][src]Struct actix_web_httpauth::extractors::bearer::BearerAuth
Extractor for HTTP Bearer auth
Example
use actix_web_httpauth::extractors::bearer::BearerAuth; 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}; 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.
pub fn from_service_request(
req: &mut ServiceRequest,
config: &Config
) -> Self::Future
[src]
req: &mut ServiceRequest,
config: &Config
) -> Self::Future
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 BearerAuth
[src]
fn clone(&self) -> BearerAuth
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for BearerAuth
[src]
impl FromRequest for BearerAuth
[src]
type Config = Config
Configuration for this extractor
type Future = Result<Self, Self::Error>
Future that resolves to a Self
type Error = AuthenticationError<Bearer>
The associated error which can be returned.
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future
[src]
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]
F: FnOnce(Self::Config) -> Self::Config,
Create and configure config instance.
Auto Trait Implementations
impl Send for BearerAuth
impl Sync for BearerAuth
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,