mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-27 02:37:42 +02:00
httpauth: Minimize futures
dependency
This commit is contained in:
@ -5,7 +5,7 @@ use std::borrow::Cow;
|
||||
use actix_web::dev::{Payload, ServiceRequest};
|
||||
use actix_web::http::header::Header;
|
||||
use actix_web::{FromRequest, HttpRequest};
|
||||
use futures::future;
|
||||
use futures_util::future::{ready, Ready};
|
||||
|
||||
use super::config::AuthExtractorConfig;
|
||||
use super::errors::AuthenticationError;
|
||||
@ -104,7 +104,7 @@ impl BasicAuth {
|
||||
}
|
||||
|
||||
impl FromRequest for BasicAuth {
|
||||
type Future = future::Ready<Result<Self, Self::Error>>;
|
||||
type Future = Ready<Result<Self, Self::Error>>;
|
||||
type Config = Config;
|
||||
type Error = AuthenticationError<Challenge>;
|
||||
|
||||
@ -112,7 +112,7 @@ impl FromRequest for BasicAuth {
|
||||
req: &HttpRequest,
|
||||
_: &mut Payload,
|
||||
) -> <Self as FromRequest>::Future {
|
||||
future::ready(
|
||||
ready(
|
||||
Authorization::<Basic>::parse(req)
|
||||
.map(|auth| BasicAuth(auth.into_scheme()))
|
||||
.map_err(|_| {
|
||||
@ -131,10 +131,10 @@ impl FromRequest for BasicAuth {
|
||||
|
||||
impl AuthExtractor for BasicAuth {
|
||||
type Error = AuthenticationError<Challenge>;
|
||||
type Future = future::Ready<Result<Self, Self::Error>>;
|
||||
type Future = Ready<Result<Self, Self::Error>>;
|
||||
|
||||
fn from_service_request(req: &ServiceRequest) -> Self::Future {
|
||||
future::ready(
|
||||
ready(
|
||||
Authorization::<Basic>::parse(req)
|
||||
.map(|auth| BasicAuth(auth.into_scheme()))
|
||||
.map_err(|_| {
|
||||
|
@ -6,7 +6,7 @@ use std::default::Default;
|
||||
use actix_web::dev::{Payload, ServiceRequest};
|
||||
use actix_web::http::header::Header;
|
||||
use actix_web::{FromRequest, HttpRequest};
|
||||
use futures::future;
|
||||
use futures_util::future::{ready, Ready};
|
||||
|
||||
use super::config::AuthExtractorConfig;
|
||||
use super::errors::AuthenticationError;
|
||||
@ -104,14 +104,14 @@ impl BearerAuth {
|
||||
|
||||
impl FromRequest for BearerAuth {
|
||||
type Config = Config;
|
||||
type Future = future::Ready<Result<Self, Self::Error>>;
|
||||
type Future = Ready<Result<Self, Self::Error>>;
|
||||
type Error = AuthenticationError<bearer::Bearer>;
|
||||
|
||||
fn from_request(
|
||||
req: &HttpRequest,
|
||||
_payload: &mut Payload,
|
||||
) -> <Self as FromRequest>::Future {
|
||||
future::ready(
|
||||
ready(
|
||||
authorization::Authorization::<authorization::Bearer>::parse(req)
|
||||
.map(|auth| BearerAuth(auth.into_scheme()))
|
||||
.map_err(|_| {
|
||||
@ -127,11 +127,11 @@ impl FromRequest for BearerAuth {
|
||||
}
|
||||
|
||||
impl AuthExtractor for BearerAuth {
|
||||
type Future = future::Ready<Result<Self, Self::Error>>;
|
||||
type Future = Ready<Result<Self, Self::Error>>;
|
||||
type Error = AuthenticationError<bearer::Bearer>;
|
||||
|
||||
fn from_service_request(req: &ServiceRequest) -> Self::Future {
|
||||
future::ready(
|
||||
ready(
|
||||
authorization::Authorization::<authorization::Bearer>::parse(req)
|
||||
.map(|auth| BearerAuth(auth.into_scheme()))
|
||||
.map_err(|_| {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use actix_web::dev::ServiceRequest;
|
||||
use actix_web::Error;
|
||||
use futures::future::Future;
|
||||
use std::future::Future;
|
||||
|
||||
pub mod basic;
|
||||
pub mod bearer;
|
||||
|
Reference in New Issue
Block a user