mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 15:51:06 +01:00
move identity service separate crate
This commit is contained in:
parent
ee769832cf
commit
ff724e239d
@ -1,6 +1,6 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [1.0.x] - 2019-xx-xx
|
## [1.0.1] - 2019-06-xx
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
|
||||||
@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
### Fixed
|
* Disable default feature `secure-cookies`.
|
||||||
|
|
||||||
|
* Move identity middleware to `actix-identity` crate.
|
||||||
|
|
||||||
|
|
||||||
## [1.0.0] - 2019-06-05
|
## [1.0.0] - 2019-06-05
|
||||||
|
@ -34,6 +34,7 @@ members = [
|
|||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-framed",
|
"actix-framed",
|
||||||
"actix-session",
|
"actix-session",
|
||||||
|
"actix-identity",
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-web-actors",
|
"actix-web-actors",
|
||||||
"actix-web-codegen",
|
"actix-web-codegen",
|
||||||
@ -41,7 +42,7 @@ members = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["brotli", "flate2-zlib", "secure-cookies", "client", "fail"]
|
default = ["brotli", "flate2-zlib", "client", "fail"]
|
||||||
|
|
||||||
# http client
|
# http client
|
||||||
client = ["awc"]
|
client = ["awc"]
|
||||||
@ -77,7 +78,7 @@ actix-http = "0.2.3"
|
|||||||
actix-server = "0.5.1"
|
actix-server = "0.5.1"
|
||||||
actix-server-config = "0.1.1"
|
actix-server-config = "0.1.1"
|
||||||
actix-threadpool = "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"
|
bytes = "0.4"
|
||||||
derive_more = "0.14"
|
derive_more = "0.14"
|
||||||
|
17
MIGRATION.md
17
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
|
## 1.0
|
||||||
|
|
||||||
* Resource registration. 1.0 version uses generalized resource
|
* Resource registration. 1.0 version uses generalized resource
|
||||||
|
5
actix-identity/CHANGES.md
Normal file
5
actix-identity/CHANGES.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.0] - 2019-06-xx
|
||||||
|
|
||||||
|
* Move identity middleware to separate crate
|
29
actix-identity/Cargo.toml
Normal file
29
actix-identity/Cargo.toml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[package]
|
||||||
|
name = "actix-identity"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
|
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"
|
1
actix-identity/LICENSE-APACHE
Symbolic link
1
actix-identity/LICENSE-APACHE
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../LICENSE-APACHE
|
1
actix-identity/LICENSE-MIT
Symbolic link
1
actix-identity/LICENSE-MIT
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../LICENSE-MIT
|
9
actix-identity/README.md
Normal file
9
actix-identity/README.md
Normal file
@ -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
|
@ -10,12 +10,11 @@
|
|||||||
//! uses cookies as identity storage.
|
//! uses cookies as identity storage.
|
||||||
//!
|
//!
|
||||||
//! To access current request identity
|
//! To access current request identity
|
||||||
//! [**Identity**](trait.Identity.html) extractor should be used.
|
//! [**Identity**](struct.Identity.html) extractor should be used.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use actix_web::middleware::identity::Identity;
|
|
||||||
//! use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService};
|
|
||||||
//! use actix_web::*;
|
//! use actix_web::*;
|
||||||
|
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
||||||
//!
|
//!
|
||||||
//! fn index(id: Identity) -> String {
|
//! fn index(id: Identity) -> String {
|
||||||
//! // access request identity
|
//! // access request identity
|
||||||
@ -39,7 +38,7 @@
|
|||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! let app = App::new().wrap(IdentityService::new(
|
//! let app = App::new().wrap(IdentityService::new(
|
||||||
//! // <- create identity middleware
|
//! // <- create identity middleware
|
||||||
//! CookieIdentityPolicy::new(&[0; 32]) // <- create cookie session backend
|
//! CookieIdentityPolicy::new(&[0; 32]) // <- create cookie identity policy
|
||||||
//! .name("auth-cookie")
|
//! .name("auth-cookie")
|
||||||
//! .secure(false)))
|
//! .secure(false)))
|
||||||
//! .service(web::resource("/index.html").to(index))
|
//! .service(web::resource("/index.html").to(index))
|
||||||
@ -57,20 +56,17 @@ use futures::{Future, IntoFuture, Poll};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::Duration;
|
use time::Duration;
|
||||||
|
|
||||||
use crate::cookie::{Cookie, CookieJar, Key, SameSite};
|
use actix_web::cookie::{Cookie, CookieJar, Key, SameSite};
|
||||||
use crate::error::{Error, Result};
|
use actix_web::dev::{Extensions, Payload, ServiceRequest, ServiceResponse};
|
||||||
use crate::http::header::{self, HeaderValue};
|
use actix_web::error::{Error, Result};
|
||||||
use crate::service::{ServiceRequest, ServiceResponse};
|
use actix_web::http::header::{self, HeaderValue};
|
||||||
use crate::{
|
use actix_web::{FromRequest, HttpMessage, HttpRequest};
|
||||||
dev::{Extensions, Payload},
|
|
||||||
FromRequest, HttpMessage, HttpRequest,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The extractor type to obtain your identity from a request.
|
/// The extractor type to obtain your identity from a request.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::*;
|
/// use actix_web::*;
|
||||||
/// use actix_web::middleware::identity::Identity;
|
/// use actix_identity::Identity;
|
||||||
///
|
///
|
||||||
/// fn index(id: Identity) -> Result<String> {
|
/// fn index(id: Identity) -> Result<String> {
|
||||||
/// // access request identity
|
/// // access request identity
|
||||||
@ -134,7 +130,9 @@ struct IdentityItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper trait that allows to get Identity.
|
/// 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
|
/// 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 {
|
pub trait RequestIdentity {
|
||||||
fn get_identity(&self) -> Option<String>;
|
fn get_identity(&self) -> Option<String>;
|
||||||
}
|
}
|
||||||
@ -152,7 +150,7 @@ where
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use actix_web::*;
|
/// # use actix_web::*;
|
||||||
/// use actix_web::middleware::identity::Identity;
|
/// use actix_identity::Identity;
|
||||||
///
|
///
|
||||||
/// fn index(id: Identity) -> String {
|
/// fn index(id: Identity) -> String {
|
||||||
/// // access request identity
|
/// // access request identity
|
||||||
@ -199,7 +197,7 @@ pub trait IdentityPolicy: Sized + 'static {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::App;
|
/// use actix_web::App;
|
||||||
/// use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService};
|
/// use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let app = App::new().wrap(IdentityService::new(
|
/// let app = App::new().wrap(IdentityService::new(
|
||||||
@ -464,9 +462,8 @@ impl CookieIdentityInner {
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # extern crate actix_web;
|
|
||||||
/// use actix_web::middleware::identity::{CookieIdentityPolicy, IdentityService};
|
|
||||||
/// use actix_web::App;
|
/// use actix_web::App;
|
||||||
|
/// use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let app = App::new().wrap(IdentityService::new(
|
/// let app = App::new().wrap(IdentityService::new(
|
||||||
@ -612,13 +609,13 @@ impl IdentityPolicy for CookieIdentityPolicy {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use crate::http::StatusCode;
|
|
||||||
use crate::test::{self, TestRequest};
|
|
||||||
use crate::{web, App, HttpResponse};
|
|
||||||
|
|
||||||
use std::borrow::Borrow;
|
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_KEY_MASTER: [u8; 32] = [0; 32];
|
||||||
const COOKIE_NAME: &'static str = "actix_auth";
|
const COOKIE_NAME: &'static str = "actix_auth";
|
||||||
const COOKIE_LOGIN: &'static str = "test";
|
const COOKIE_LOGIN: &'static str = "test";
|
||||||
@ -739,8 +736,8 @@ mod tests {
|
|||||||
f: F,
|
f: F,
|
||||||
) -> impl actix_service::Service<
|
) -> impl actix_service::Service<
|
||||||
Request = actix_http::Request,
|
Request = actix_http::Request,
|
||||||
Response = ServiceResponse<actix_http::body::Body>,
|
Response = ServiceResponse<actix_web::body::Body>,
|
||||||
Error = actix_http::Error,
|
Error = Error,
|
||||||
> {
|
> {
|
||||||
test::init_service(
|
test::init_service(
|
||||||
App::new()
|
App::new()
|
@ -38,6 +38,7 @@ pub mod test;
|
|||||||
pub mod ws;
|
pub mod ws;
|
||||||
|
|
||||||
pub use self::builder::ClientBuilder;
|
pub use self::builder::ClientBuilder;
|
||||||
|
pub use self::connect::BoxedSocket;
|
||||||
pub use self::request::ClientRequest;
|
pub use self::request::ClientRequest;
|
||||||
pub use self::response::{ClientResponse, JsonBody, MessageBody};
|
pub use self::response::{ClientResponse, JsonBody, MessageBody};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
//! * `ssl` - enables ssl support via `openssl` crate, supports `http/2`
|
//! * `ssl` - enables ssl support via `openssl` crate, supports `http/2`
|
||||||
//! * `rust-tls` - enables ssl support via `rustls` 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
|
//! * `secure-cookies` - enables secure cookies support, includes `ring` crate as
|
||||||
//! dependency (default enabled)
|
//! dependency
|
||||||
//! * `brotli` - enables `brotli` compression support, requires `c`
|
//! * `brotli` - enables `brotli` compression support, requires `c`
|
||||||
//! compiler (default enabled)
|
//! compiler (default enabled)
|
||||||
//! * `flate2-zlib` - enables `gzip`, `deflate` compression support, requires
|
//! * `flate2-zlib` - enables `gzip`, `deflate` compression support, requires
|
||||||
|
@ -11,6 +11,3 @@ mod normalize;
|
|||||||
pub use self::defaultheaders::DefaultHeaders;
|
pub use self::defaultheaders::DefaultHeaders;
|
||||||
pub use self::logger::Logger;
|
pub use self::logger::Logger;
|
||||||
pub use self::normalize::NormalizePath;
|
pub use self::normalize::NormalizePath;
|
||||||
|
|
||||||
#[cfg(feature = "secure-cookies")]
|
|
||||||
pub mod identity;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user