mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 23:51:06 +01:00
standardize future types to ones from actix_utils
This commit is contained in:
parent
ec66754c0d
commit
56051786a6
@ -17,8 +17,9 @@ name = "actix_cors"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "4.0.0-beta.10", default-features = false }
|
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
|
actix-utils = "3"
|
||||||
|
actix-web = { version = "4.0.0-beta.10", default-features = false }
|
||||||
|
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
@ -28,5 +29,5 @@ smallvec = "1.6"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
pretty_env_logger = "0.4"
|
env_logger = "0.9"
|
||||||
regex = "1.4"
|
regex = "1.4"
|
||||||
|
@ -3,7 +3,7 @@ use actix_web::{http::header, web, App, HttpServer};
|
|||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
pretty_env_logger::init();
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
|
@ -2,6 +2,7 @@ use std::{
|
|||||||
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
|
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use actix_utils::future::{self, Ready};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::MessageBody,
|
body::MessageBody,
|
||||||
dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
|
dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
|
||||||
@ -9,7 +10,6 @@ use actix_web::{
|
|||||||
http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
|
http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
|
||||||
Either,
|
Either,
|
||||||
};
|
};
|
||||||
use futures_util::future::{self, Ready};
|
|
||||||
use log::error;
|
use log::error;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use smallvec::smallvec;
|
use smallvec::smallvec;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};
|
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};
|
||||||
|
|
||||||
|
use actix_utils::future::{ok, Either, Ready};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::{AnyBody, MessageBody},
|
body::{AnyBody, MessageBody},
|
||||||
dev::{Service, ServiceRequest, ServiceResponse},
|
dev::{Service, ServiceRequest, ServiceResponse},
|
||||||
@ -10,7 +11,7 @@ use actix_web::{
|
|||||||
},
|
},
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use futures_util::future::{ok, Either, FutureExt as _, LocalBoxFuture, Ready, TryFutureExt as _};
|
use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
||||||
use crate::{builder::intersperse_header_values, AllOrSome, Inner};
|
use crate::{builder::intersperse_header_values, AllOrSome, Inner};
|
||||||
@ -155,7 +156,7 @@ where
|
|||||||
if self.inner.preflight && req.method() == Method::OPTIONS {
|
if self.inner.preflight && req.method() == Method::OPTIONS {
|
||||||
let inner = Rc::clone(&self.inner);
|
let inner = Rc::clone(&self.inner);
|
||||||
let res = Self::handle_preflight(&inner, req);
|
let res = Self::handle_preflight(&inner, req);
|
||||||
Either::Left(ok(res))
|
Either::left(ok(res))
|
||||||
} else {
|
} else {
|
||||||
let origin = req.headers().get(header::ORIGIN).cloned();
|
let origin = req.headers().get(header::ORIGIN).cloned();
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ where
|
|||||||
// Only check requests with a origin header.
|
// Only check requests with a origin header.
|
||||||
if let Err(err) = self.inner.validate_origin(req.head()) {
|
if let Err(err) = self.inner.validate_origin(req.head()) {
|
||||||
debug!("origin validation failed; inner service is not called");
|
debug!("origin validation failed; inner service is not called");
|
||||||
return Either::Left(ok(req.error_response(err)));
|
return Either::left(ok(req.error_response(err)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +184,7 @@ where
|
|||||||
.map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
|
.map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
|
||||||
.boxed_local();
|
.boxed_local();
|
||||||
|
|
||||||
Either::Right(res)
|
Either::right(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use actix_service::fn_service;
|
use actix_service::fn_service;
|
||||||
|
use actix_utils::future::ok;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::{ServiceRequest, Transform},
|
dev::{ServiceRequest, Transform},
|
||||||
http::{header, HeaderValue, Method, StatusCode},
|
http::{header, HeaderValue, Method, StatusCode},
|
||||||
test::{self, TestRequest},
|
test::{self, TestRequest},
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use futures_util::future::ok;
|
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
|
|
||||||
use actix_cors::Cors;
|
use actix_cors::Cors;
|
||||||
|
@ -5,7 +5,7 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
|||||||
description = "Identity service for Actix web"
|
description = "Identity service for Actix web"
|
||||||
keywords = ["actix", "auth", "identity", "web", "security"]
|
keywords = ["actix", "auth", "identity", "web", "security"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-extras"
|
repository = "https://github.com/actix/actix-extras.git"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
|
actix-utils = "3"
|
||||||
actix-web = { version = "4.0.0-beta.10", default-features = false, features = ["cookies", "secure-cookies"] }
|
actix-web = { version = "4.0.0-beta.10", default-features = false, features = ["cookies", "secure-cookies"] }
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{rc::Rc, time::SystemTime};
|
use std::{rc::Rc, time::SystemTime};
|
||||||
|
|
||||||
use futures_util::future::{ready, Ready};
|
use actix_utils::future::{ready, Ready};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use actix_web::{
|
|||||||
dev::{Extensions, Payload},
|
dev::{Extensions, Payload},
|
||||||
Error, FromRequest, HttpRequest,
|
Error, FromRequest, HttpRequest,
|
||||||
};
|
};
|
||||||
use futures_util::future::{ready, Ready};
|
use actix_utils::future::{ready, Ready};
|
||||||
|
|
||||||
pub(crate) struct IdentityItem {
|
pub(crate) struct IdentityItem {
|
||||||
pub(crate) id: Option<String>,
|
pub(crate) id: Option<String>,
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use std::{error::Error as StdError, rc::Rc};
|
use std::{error::Error as StdError, rc::Rc};
|
||||||
|
|
||||||
|
use actix_utils::future::{ready, Ready};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::{AnyBody, MessageBody},
|
body::{AnyBody, MessageBody},
|
||||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||||
Error, HttpMessage, Result,
|
Error, HttpMessage, Result,
|
||||||
};
|
};
|
||||||
use futures_util::future::{ready, FutureExt as _, LocalBoxFuture, Ready, TryFutureExt as _};
|
use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
|
||||||
|
|
||||||
use crate::{identity::IdentityItem, IdentityPolicy};
|
use crate::{identity::IdentityItem, IdentityPolicy};
|
||||||
|
|
||||||
@ -129,7 +130,8 @@ mod tests {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_borrowed_mut_error() {
|
async fn test_borrowed_mut_error() {
|
||||||
use futures_util::future::{lazy, ok, Ready};
|
use actix_utils::future::{ok, Ready};
|
||||||
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
struct Ident;
|
struct Ident;
|
||||||
impl IdentityPolicy for Ident {
|
impl IdentityPolicy for Ident {
|
||||||
|
@ -9,7 +9,7 @@ authors = [
|
|||||||
description = "Protobuf support for Actix web"
|
description = "Protobuf support for Actix web"
|
||||||
keywords = ["actix", "protobuf", "protocol", "rpc"]
|
keywords = ["actix", "protobuf", "protocol", "rpc"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-extras"
|
repository = "https://github.com/actix/actix-extras.git"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
exclude = [".cargo/config", "/examples/**"]
|
exclude = [".cargo/config", "/examples/**"]
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ description = "Redis integration for Actix and session store for Actix Web"
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
keywords = ["actix", "redis", "async", "session"]
|
keywords = ["actix", "redis", "async", "session"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-extras"
|
repository = "https://github.com/actix/actix-extras.git"
|
||||||
categories = ["network-programming", "asynchronous"]
|
categories = ["network-programming", "asynchronous"]
|
||||||
exclude = [".cargo/config"]
|
exclude = [".cargo/config"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
@ -5,7 +5,7 @@ authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
|||||||
description = "Sessions for Actix web"
|
description = "Sessions for Actix web"
|
||||||
keywords = ["http", "web", "framework", "async", "session"]
|
keywords = ["http", "web", "framework", "async", "session"]
|
||||||
homepage = "https://actix.rs"
|
homepage = "https://actix.rs"
|
||||||
repository = "https://github.com/actix/actix-extras"
|
repository = "https://github.com/actix/actix-extras.git"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
@ -18,8 +18,9 @@ default = ["cookie-session"]
|
|||||||
cookie-session = ["actix-web/secure-cookies"]
|
cookie-session = ["actix-web/secure-cookies"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "4.0.0-beta.10", default_features = false, features = ["cookies"] }
|
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
|
actix-utils = "3"
|
||||||
|
actix-web = { version = "4.0.0-beta.10", default_features = false, features = ["cookies"] }
|
||||||
|
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use std::{collections::HashMap, error::Error as StdError, rc::Rc};
|
use std::{collections::HashMap, error::Error as StdError, rc::Rc};
|
||||||
|
|
||||||
|
use actix_utils::future::{ok, Ready};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::{AnyBody, MessageBody},
|
body::{AnyBody, MessageBody},
|
||||||
cookie::{Cookie, CookieJar, Key, SameSite},
|
cookie::{Cookie, CookieJar, Key, SameSite},
|
||||||
@ -10,7 +11,7 @@ use actix_web::{
|
|||||||
Error, ResponseError,
|
Error, ResponseError,
|
||||||
};
|
};
|
||||||
use derive_more::Display;
|
use derive_more::Display;
|
||||||
use futures_util::future::{ok, FutureExt as _, LocalBoxFuture, Ready};
|
use futures_util::future::{FutureExt as _, LocalBoxFuture};
|
||||||
use serde_json::error::Error as JsonError;
|
use serde_json::error::Error as JsonError;
|
||||||
use time::{Duration, OffsetDateTime};
|
use time::{Duration, OffsetDateTime};
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ use std::{
|
|||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use actix_utils::future::{ok, Ready};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::{Extensions, Payload, RequestHead, ServiceRequest, ServiceResponse},
|
dev::{Extensions, Payload, RequestHead, ServiceRequest, ServiceResponse},
|
||||||
Error, FromRequest, HttpMessage, HttpRequest,
|
Error, FromRequest, HttpMessage, HttpRequest,
|
||||||
};
|
};
|
||||||
use futures_util::future::{ok, Ready};
|
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "cookie-session")]
|
#[cfg(feature = "cookie-session")]
|
||||||
|
@ -18,10 +18,13 @@ name = "actix_web_httpauth"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "4.0.0-beta.10", default_features = false }
|
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
|
actix-utils = "3"
|
||||||
|
actix-web = { version = "4.0.0-beta.10", default_features = false }
|
||||||
|
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
futures-util = { version = "0.3.7", default-features = false }
|
futures-util = { version = "0.3.7", default-features = false }
|
||||||
|
futures-core = { version = "0.3.7", default-features = false }
|
||||||
pin-project-lite = "0.2.7"
|
pin-project-lite = "0.2.7"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use actix_utils::future::{ready, Ready};
|
||||||
use actix_web::dev::{Payload, ServiceRequest};
|
use actix_web::dev::{Payload, ServiceRequest};
|
||||||
use actix_web::http::header::Header;
|
use actix_web::http::header::Header;
|
||||||
use actix_web::{FromRequest, HttpRequest};
|
use actix_web::{FromRequest, HttpRequest};
|
||||||
use futures_util::future::{ready, Ready};
|
|
||||||
|
|
||||||
use super::config::AuthExtractorConfig;
|
use super::config::AuthExtractorConfig;
|
||||||
use super::errors::AuthenticationError;
|
use super::errors::AuthenticationError;
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
//! Extractor for the "Bearer" HTTP Authentication Scheme
|
//! Extractor for the "Bearer" HTTP Authentication Scheme
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::{borrow::Cow, default::Default};
|
||||||
use std::default::Default;
|
|
||||||
|
|
||||||
use actix_web::dev::{Payload, ServiceRequest};
|
use actix_utils::future::{ready, Ready};
|
||||||
use actix_web::http::header::Header;
|
use actix_web::{
|
||||||
use actix_web::{FromRequest, HttpRequest};
|
dev::{Payload, ServiceRequest},
|
||||||
use futures_util::future::{ready, Ready};
|
http::header::Header,
|
||||||
|
FromRequest, HttpRequest,
|
||||||
|
};
|
||||||
|
|
||||||
use super::config::AuthExtractorConfig;
|
use super::{config::AuthExtractorConfig, errors::AuthenticationError, AuthExtractor};
|
||||||
use super::errors::AuthenticationError;
|
|
||||||
use super::AuthExtractor;
|
|
||||||
use crate::headers::authorization;
|
|
||||||
use crate::headers::www_authenticate::bearer;
|
|
||||||
pub use crate::headers::www_authenticate::bearer::Error;
|
pub use crate::headers::www_authenticate::bearer::Error;
|
||||||
|
use crate::headers::{authorization, www_authenticate::bearer};
|
||||||
|
|
||||||
/// [BearerAuth](./struct/BearerAuth.html) extractor configuration.
|
/// [BearerAuth](./struct/BearerAuth.html) extractor configuration.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
@ -8,7 +8,7 @@ use std::{
|
|||||||
|
|
||||||
use actix_web::dev::ServiceRequest;
|
use actix_web::dev::ServiceRequest;
|
||||||
use actix_web::Error;
|
use actix_web::Error;
|
||||||
use futures_util::ready;
|
use futures_core::ready;
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
|
|
||||||
pub mod basic;
|
pub mod basic;
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
//! HTTP Authentication middleware.
|
//! HTTP Authentication middleware.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
error::Error as StdError, future::Future, marker::PhantomData, pin::Pin, rc::Rc, sync::Arc,
|
error::Error as StdError,
|
||||||
|
future::Future,
|
||||||
|
marker::PhantomData,
|
||||||
|
pin::Pin,
|
||||||
|
rc::Rc,
|
||||||
|
sync::Arc,
|
||||||
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
@ -9,11 +15,8 @@ use actix_web::{
|
|||||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
use futures_util::{
|
use futures_core::ready;
|
||||||
future::{self, FutureExt as _, LocalBoxFuture, TryFutureExt as _},
|
use futures_util::future::{self, FutureExt as _, LocalBoxFuture, TryFutureExt as _};
|
||||||
ready,
|
|
||||||
task::{Context, Poll},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::extractors::{basic, bearer, AuthExtractor};
|
use crate::extractors::{basic, bearer, AuthExtractor};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user