diff --git a/CHANGES.md b/CHANGES.md index 3e9265258..231cb133f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # Changes -## [1.0.x] - 2019-xx-xx +## [1.0.1] - 2019-06-xx ### Add @@ -8,7 +8,9 @@ ### Changes -### Fixed +* Disable default feature `secure-cookies`. + +* Move identity middleware to `actix-identity` crate. ## [1.0.0] - 2019-06-05 diff --git a/Cargo.toml b/Cargo.toml index cd0e94589..08eb7cd9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ members = [ "actix-files", "actix-framed", "actix-session", + "actix-identity", "actix-multipart", "actix-web-actors", "actix-web-codegen", @@ -41,7 +42,7 @@ members = [ ] [features] -default = ["brotli", "flate2-zlib", "secure-cookies", "client", "fail"] +default = ["brotli", "flate2-zlib", "client", "fail"] # http client client = ["awc"] @@ -77,7 +78,7 @@ actix-http = "0.2.3" actix-server = "0.5.1" actix-server-config = "0.1.1" actix-threadpool = "0.1.1" -awc = { version = "0.2.0", optional = true } +awc = { version = "0.2.1", optional = true } bytes = "0.4" derive_more = "0.14" diff --git a/MIGRATION.md b/MIGRATION.md index 1736ee65d..8b5d7dd49 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,3 +1,20 @@ +## 1.0.1 + +* Identity middleware has been moved to `actix-identity` crate + + instead of + + ```rust + use actix_web::middleware::identity::{Identity, CookieIdentityPolicy, IdentityService}; + ``` + + use + + ```rust + use actix_identity::{Identity, CookieIdentityPolicy, IdentityService}; + ``` + + ## 1.0 * Resource registration. 1.0 version uses generalized resource diff --git a/actix-identity/CHANGES.md b/actix-identity/CHANGES.md new file mode 100644 index 000000000..74a204055 --- /dev/null +++ b/actix-identity/CHANGES.md @@ -0,0 +1,5 @@ +# Changes + +## [0.1.0] - 2019-06-xx + +* Move identity middleware to separate crate diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml new file mode 100644 index 000000000..3b1b90865 --- /dev/null +++ b/actix-identity/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "actix-identity" +version = "0.1.0" +authors = ["Nikolay Kim "] +description = "Identity service for actix web framework." +readme = "README.md" +keywords = ["http", "web", "framework", "async", "futures"] +homepage = "https://actix.rs" +repository = "https://github.com/actix/actix-web.git" +documentation = "https://docs.rs/actix-identity/" +license = "MIT/Apache-2.0" +edition = "2018" +workspace = ".." + +[lib] +name = "actix_identity" +path = "src/lib.rs" + +[dependencies] +actix-web = { version = "1.0.0", default-features = false, features = ["secure-cookies"] } +actix-service = "0.4.0" +futures = "0.1.25" +serde = "1.0" +serde_json = "1.0" +time = "0.1.42" + +[dev-dependencies] +actix-rt = "0.2.2" +actix-http = "0.2.3" diff --git a/actix-identity/LICENSE-APACHE b/actix-identity/LICENSE-APACHE new file mode 120000 index 000000000..965b606f3 --- /dev/null +++ b/actix-identity/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/actix-identity/LICENSE-MIT b/actix-identity/LICENSE-MIT new file mode 120000 index 000000000..76219eb72 --- /dev/null +++ b/actix-identity/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/actix-identity/README.md b/actix-identity/README.md new file mode 100644 index 000000000..60b615c76 --- /dev/null +++ b/actix-identity/README.md @@ -0,0 +1,9 @@ +# Identity service for actix web framework [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/actix-identity)](https://crates.io/crates/actix-identity) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Documentation & community resources + +* [User Guide](https://actix.rs/docs/) +* [API Documentation](https://docs.rs/actix-identity/) +* [Chat on gitter](https://gitter.im/actix/actix) +* Cargo package: [actix-session](https://crates.io/crates/actix-identity) +* Minimum supported Rust version: 1.34 or later diff --git a/src/middleware/identity.rs b/actix-identity/src/lib.rs similarity index 97% rename from src/middleware/identity.rs rename to actix-identity/src/lib.rs index 304df9eb2..6664df676 100644 --- a/src/middleware/identity.rs +++ b/actix-identity/src/lib.rs @@ -10,12 +10,11 @@ //! uses cookies as identity storage. //! //! To access current request identity -//! [**Identity**](trait.Identity.html) extractor should be used. +//! [**Identity**](struct.Identity.html) extractor should be used. //! //! ```rust -//! use actix_web::middleware::identity::Identity; -//! use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService}; //! use actix_web::*; +//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService}; //! //! fn index(id: Identity) -> String { //! // access request identity @@ -39,7 +38,7 @@ //! fn main() { //! let app = App::new().wrap(IdentityService::new( //! // <- create identity middleware -//! CookieIdentityPolicy::new(&[0; 32]) // <- create cookie session backend +//! CookieIdentityPolicy::new(&[0; 32]) // <- create cookie identity policy //! .name("auth-cookie") //! .secure(false))) //! .service(web::resource("/index.html").to(index)) @@ -57,20 +56,17 @@ use futures::{Future, IntoFuture, Poll}; use serde::{Deserialize, Serialize}; use time::Duration; -use crate::cookie::{Cookie, CookieJar, Key, SameSite}; -use crate::error::{Error, Result}; -use crate::http::header::{self, HeaderValue}; -use crate::service::{ServiceRequest, ServiceResponse}; -use crate::{ - dev::{Extensions, Payload}, - FromRequest, HttpMessage, HttpRequest, -}; +use actix_web::cookie::{Cookie, CookieJar, Key, SameSite}; +use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse}; +use actix_web::error::{Error, Result}; +use actix_web::http::header::{self, HeaderValue}; +use actix_web::{FromRequest, HttpMessage, HttpRequest}; /// The extractor type to obtain your identity from a request. /// /// ```rust /// use actix_web::*; -/// use actix_web::middleware::identity::Identity; +/// use actix_identity::Identity; /// /// fn index(id: Identity) -> Result { /// // access request identity @@ -134,7 +130,9 @@ struct IdentityItem { } /// Helper trait that allows to get Identity. +/// /// It could be used in middleware but identity policy must be set before any other middleware that needs identity +/// RequestIdentity is implemented both for `ServiceRequest` and `HttpRequest`. pub trait RequestIdentity { fn get_identity(&self) -> Option; } @@ -152,7 +150,7 @@ where /// /// ```rust /// # use actix_web::*; -/// use actix_web::middleware::identity::Identity; +/// use actix_identity::Identity; /// /// fn index(id: Identity) -> String { /// // access request identity @@ -199,7 +197,7 @@ pub trait IdentityPolicy: Sized + 'static { /// /// ```rust /// use actix_web::App; -/// use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService}; +/// use actix_identity::{CookieIdentityPolicy, IdentityService}; /// /// fn main() { /// let app = App::new().wrap(IdentityService::new( @@ -464,9 +462,8 @@ impl CookieIdentityInner { /// # Example /// /// ```rust -/// # extern crate actix_web; -/// use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService}; /// use actix_web::App; +/// use actix_identity::{CookieIdentityPolicy, IdentityService}; /// /// fn main() { /// let app = App::new().wrap(IdentityService::new( @@ -612,13 +609,13 @@ impl IdentityPolicy for CookieIdentityPolicy { #[cfg(test)] mod tests { - use super::*; - use crate::http::StatusCode; - use crate::test::{self, TestRequest}; - use crate::{web, App, HttpResponse}; - use std::borrow::Borrow; + use super::*; + use actix_web::http::StatusCode; + use actix_web::test::{self, TestRequest}; + use actix_web::{web, App, Error, HttpResponse}; + const COOKIE_KEY_MASTER: [u8; 32] = [0; 32]; const COOKIE_NAME: &'static str = "actix_auth"; const COOKIE_LOGIN: &'static str = "test"; @@ -739,8 +736,8 @@ mod tests { f: F, ) -> impl actix_service::Service< Request = actix_http::Request, - Response = ServiceResponse, - Error = actix_http::Error, + Response = ServiceResponse, + Error = Error, > { test::init_service( App::new() diff --git a/awc/src/lib.rs b/awc/src/lib.rs index 8c1bc80b6..9fbda8aa8 100644 --- a/awc/src/lib.rs +++ b/awc/src/lib.rs @@ -38,6 +38,7 @@ pub mod test; pub mod ws; pub use self::builder::ClientBuilder; +pub use self::connect::BoxedSocket; pub use self::request::ClientRequest; pub use self::response::{ClientResponse, JsonBody, MessageBody}; diff --git a/src/lib.rs b/src/lib.rs index f0bf01bc9..fffbc2f5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,7 +70,7 @@ //! * `ssl` - enables ssl support via `openssl` crate, supports `http/2` //! * `rust-tls` - enables ssl support via `rustls` crate, supports `http/2` //! * `secure-cookies` - enables secure cookies support, includes `ring` crate as -//! dependency (default enabled) +//! dependency //! * `brotli` - enables `brotli` compression support, requires `c` //! compiler (default enabled) //! * `flate2-zlib` - enables `gzip`, `deflate` compression support, requires diff --git a/src/middleware/mod.rs b/src/middleware/mod.rs index 5266f7c1a..99c6cb457 100644 --- a/src/middleware/mod.rs +++ b/src/middleware/mod.rs @@ -11,6 +11,3 @@ mod normalize; pub use self::defaultheaders::DefaultHeaders; pub use self::logger::Logger; pub use self::normalize::NormalizePath; - -#[cfg(feature = "secure-cookies")] -pub mod identity;