1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

fix doctest ci (#188)

This commit is contained in:
Rob Ede
2021-06-27 07:02:38 +01:00
committed by GitHub
parent 64eec6e550
commit 20ef05c36e
23 changed files with 255 additions and 206 deletions

View File

@ -6,11 +6,9 @@ authors = [
"Yuki Okushi <huyuumi.dev@gmail.com>",
]
description = "HTTP authentication schemes for Actix web"
readme = "README.md"
keywords = ["http", "web", "framework", "authentication", "security"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras.git"
documentation = "https://docs.rs/actix-web-httpauth/"
repository = "https://github.com/actix/actix-extras"
categories = ["web-programming::http-server"]
license = "MIT OR Apache-2.0"
edition = "2018"
@ -20,8 +18,8 @@ name = "actix_web_httpauth"
path = "src/lib.rs"
[dependencies]
actix-web = { version = "4.0.0-beta.5", default_features = false }
actix-service = "2.0.0-beta.5"
actix-web = { version = "4.0.0-beta.8", default_features = false }
actix-service = "2.0.0"
base64 = "0.13"
futures-util = { version = "0.3.7", default-features = false }

View File

@ -81,7 +81,7 @@ impl AuthExtractorConfig for Config {
///
/// fn main() {
/// let app = App::new()
/// .data(Config::default().realm("Restricted area"))
/// .app_data(Config::default().realm("Restricted area"))
/// .service(web::resource("/index.html").route(web::get().to(index)));
/// }
/// ```

View File

@ -84,7 +84,7 @@ impl AuthExtractorConfig for Config {
///
/// fn main() {
/// let app = App::new()
/// .data(
/// .app_data(
/// Config::default()
/// .realm("Restricted area")
/// .scope("email photo"),

View File

@ -1,8 +1,12 @@
//! HTTP Authentication middleware.
use std::{future::Future, marker::PhantomData, pin::Pin, rc::Rc, sync::Arc};
use std::{
error::Error as StdError, future::Future, marker::PhantomData, pin::Pin, rc::Rc,
sync::Arc,
};
use actix_web::{
body::{AnyBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
Error,
};
@ -120,8 +124,10 @@ where
F: Fn(ServiceRequest, T) -> O + 'static,
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
{
type Response = ServiceResponse<B>;
type Response = ServiceResponse;
type Error = Error;
type Transform = AuthenticationMiddleware<S, F, T>;
type InitError = ();
@ -153,10 +159,12 @@ where
F: Fn(ServiceRequest, T) -> O + 'static,
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
{
type Response = ServiceResponse<B>;
type Response = ServiceResponse;
type Error = S::Error;
type Future = LocalBoxFuture<'static, Result<ServiceResponse<B>, Error>>;
type Future = LocalBoxFuture<'static, Result<ServiceResponse, Error>>;
actix_service::forward_ready!(service);
@ -177,7 +185,10 @@ where
// middleware to do their thing (eg. cors adding headers)
let req = process_fn(req, credentials).await?;
service.call(req).await
service
.call(req)
.await
.map(|res| res.map_body(|_, body| AnyBody::from_message(body)))
}
.boxed_local()
}