1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-27 17:22:57 +01:00

actix-web beta 15 updates (#216)

This commit is contained in:
Rob Ede 2021-12-18 03:37:23 +00:00 committed by GitHub
parent c047cd5653
commit 6676a50944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 101 additions and 82 deletions

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 0.6.0-beta.7 - 2021-12-18
* Update `actix-web` dependency to `4.0.0.beta-15`. [#216]
[#216]: https://github.com/actix/actix-extras/pull/216
## 0.6.0-beta.6 - 2021-12-13
* Fix panic when wrapping routes with dynamic segments in their paths. [#213]

View File

@ -1,6 +1,6 @@
[package]
name = "actix-cors"
version = "0.6.0-beta.6"
version = "0.6.0-beta.7"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
@ -17,9 +17,9 @@ name = "actix_cors"
path = "src/lib.rs"
[dependencies]
actix-service = "2.0.0"
actix-service = "2"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.14", default-features = false }
actix-web = { version = "4.0.0-beta.15", default-features = false }
derive_more = "0.99.5"
futures-util = { version = "0.3.7", default-features = false }

View File

@ -3,9 +3,9 @@
> Cross-origin resource sharing (CORS) for Actix Web.
[![crates.io](https://img.shields.io/crates/v/actix-cors?label=latest)](https://crates.io/crates/actix-cors)
[![Documentation](https://docs.rs/actix-cors/badge.svg?version=0.6.0-beta.6)](https://docs.rs/actix-cors/0.6.0-beta.6)
[![Documentation](https://docs.rs/actix-cors/badge.svg?version=0.6.0-beta.7)](https://docs.rs/actix-cors/0.6.0-beta.7)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-cors)
[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.0-beta.6/status.svg)](https://deps.rs/crate/actix-cors/0.6.0-beta.6)
[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.0-beta.7/status.svg)](https://deps.rs/crate/actix-cors/0.6.0-beta.7)
## Documentation & Resources

View File

@ -1,6 +1,4 @@
use std::{
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
};
use std::{collections::HashSet, convert::TryInto, iter::FromIterator, rc::Rc};
use actix_utils::future::{self, Ready};
use actix_web::{
@ -490,8 +488,9 @@ impl<S, B> Transform<S, ServiceRequest> for Cors
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
@ -636,7 +635,7 @@ mod test {
#[actix_rt::test]
async fn middleware_generic_over_body_type() {
let srv = fn_service(|req: ServiceRequest| async move {
Ok(req.into_response(HttpResponse::Ok().message_body(body::None::new())?))
Ok(req.into_response(HttpResponse::with_body(StatusCode::OK, body::None::new())))
});
Cors::default().new_transform(srv).await.unwrap();

View File

@ -1,15 +1,14 @@
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};
use std::{collections::HashSet, convert::TryInto, rc::Rc};
use actix_utils::future::ok;
use actix_web::{
body::{EitherBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse},
error::{Error, Result},
http::{
header::{self, HeaderValue},
Method,
},
HttpResponse,
Error, HttpResponse, Result,
};
use futures_util::future::{FutureExt as _, LocalBoxFuture};
use log::debug;
@ -138,8 +137,9 @@ impl<S, B> Service<ServiceRequest> for CorsMiddleware<S>
where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
@ -172,7 +172,7 @@ where
if origin.is_some() {
Ok(Self::augment_response(&inner, res?))
} else {
res
res.map_err(Into::into)
}
.map(|res| res.map_into_left_body())
}

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 0.4.0-beta.6 - 2021-12-18
* Update `actix-web` dependency to `4.0.0.beta-15`. [#216]
[#216]: https://github.com/actix/actix-extras/pull/216
## 0.4.0-beta.5 - 2021-12-12
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]

View File

@ -1,8 +1,8 @@
[package]
name = "actix-identity"
version = "0.4.0-beta.5"
version = "0.4.0-beta.6"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Identity service for Actix web"
description = "Identity service for Actix Web"
keywords = ["actix", "auth", "identity", "web", "security"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras.git"
@ -14,9 +14,9 @@ name = "actix_identity"
path = "src/lib.rs"
[dependencies]
actix-service = "2.0.0"
actix-service = "2"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["cookies", "secure-cookies"] }
actix-web = { version = "4.0.0-beta.15", default-features = false, features = ["cookies", "secure-cookies"] }
futures-util = { version = "0.3.7", default-features = false }
serde = "1.0"

View File

@ -3,9 +3,9 @@
> Identity service for actix-web framework.
[![crates.io](https://img.shields.io/crates/v/actix-identity?label=latest)](https://crates.io/crates/actix-identity)
[![Documentation](https://docs.rs/actix-identity/badge.svg?version=0.4.0-beta.5)](https://docs.rs/actix-identity/0.4.0-beta.5)
[![Documentation](https://docs.rs/actix-identity/badge.svg?version=0.4.0-beta.6)](https://docs.rs/actix-identity/0.4.0-beta.6)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-identity)
[![Dependency Status](https://deps.rs/crate/actix-identity/0.4.0-beta.5/status.svg)](https://deps.rs/crate/actix-identity/0.4.0-beta.5)
[![Dependency Status](https://deps.rs/crate/actix-identity/0.4.0-beta.6/status.svg)](https://deps.rs/crate/actix-identity/0.4.0-beta.6)
## Documentation & community resources

View File

@ -1,4 +1,4 @@
use std::{error::Error as StdError, rc::Rc};
use std::rc::Rc;
use actix_utils::future::{ready, Ready};
use actix_web::{
@ -44,7 +44,7 @@ where
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
@ -80,7 +80,7 @@ where
S::Future: 'static,
T: IdentityPolicy,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;

View File

@ -46,7 +46,7 @@ tokio-util = "0.6.1"
# actix-session
actix-web = { version = "4.0.0-beta.14", default_features = false, optional = true }
actix-session = { version = "0.5.0-beta.5", optional = true }
actix-session = { version = "0.5.0-beta.6", optional = true }
rand = { version = "0.8.0", optional = true }
serde = { version = "1.0.101", optional = true }
serde_json = { version = "1.0.40", optional = true }

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 0.5.0-beta.6 - 2021-12-18
* Update `actix-web` dependency to `4.0.0.beta-15`. [#216]
[#216]: https://github.com/actix/actix-extras/pull/216
## 0.5.0-beta.5 - 2021-12-12
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]
* Remove `UserSession` implementation for `RequestHead`. [#209]

View File

@ -1,8 +1,8 @@
[package]
name = "actix-session"
version = "0.5.0-beta.5"
version = "0.5.0-beta.6"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Sessions for Actix web"
description = "Sessions for Actix Web"
keywords = ["http", "web", "framework", "async", "session"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras.git"
@ -18,9 +18,9 @@ default = ["cookie-session"]
cookie-session = ["actix-web/secure-cookies"]
[dependencies]
actix-service = "2.0.0"
actix-service = "2"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.14", default_features = false, features = ["cookies"] }
actix-web = { version = "4.0.0-beta.15", default_features = false, features = ["cookies"] }
derive_more = "0.99.5"
futures-util = { version = "0.3.7", default-features = false }

View File

@ -3,9 +3,9 @@
> Sessions for Actix Web.
[![crates.io](https://img.shields.io/crates/v/actix-session?label=latest)](https://crates.io/crates/actix-session)
[![Documentation](https://docs.rs/actix-session/badge.svg?version=0.5.0-beta.5)](https://docs.rs/actix-session/0.5.0-beta.5)
[![Documentation](https://docs.rs/actix-session/badge.svg?version=0.5.0-beta.6)](https://docs.rs/actix-session/0.5.0-beta.6)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-session)
[![Dependency Status](https://deps.rs/crate/actix-session/0.5.0-beta.5/status.svg)](https://deps.rs/crate/actix-session/0.5.0-beta.5)
[![Dependency Status](https://deps.rs/crate/actix-session/0.5.0-beta.6/status.svg)](https://deps.rs/crate/actix-session/0.5.0-beta.6)
## Documentation & Resources

View File

@ -1,6 +1,6 @@
//! Cookie based sessions. See docs for [`CookieSession`].
use std::{collections::HashMap, error::Error as StdError, rc::Rc};
use std::{collections::HashMap, rc::Rc};
use actix_utils::future::{ok, Ready};
use actix_web::{
@ -301,7 +301,7 @@ where
S::Future: 'static,
S::Error: 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;
@ -329,7 +329,7 @@ where
S::Future: 'static,
S::Error: 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;
@ -516,7 +516,7 @@ mod tests {
let request = test::TestRequest::with_uri("/test/")
.cookie(cookie)
.to_request();
let body = test::read_response(&app, request).await;
let body = test::call_and_read_body(&app, request).await;
assert_eq!(body, Bytes::from_static(b"counter: 100"));
}

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 0.6.0-beta.6 - 2021-12-18
* Update `actix-web` dependency to `4.0.0.beta-15`. [#216]
[#216]: https://github.com/actix/actix-extras/pull/216
## 0.6.0-beta.5 - 2021-12-12
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]

View File

@ -1,11 +1,11 @@
[package]
name = "actix-web-httpauth"
version = "0.6.0-beta.5"
version = "0.6.0-beta.6"
authors = [
"svartalf <self@svartalf.info>",
"Yuki Okushi <huyuumi.dev@gmail.com>",
]
description = "HTTP authentication schemes for Actix web"
description = "HTTP authentication schemes for Actix Web"
keywords = ["http", "web", "framework", "authentication", "security"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-extras.git"
@ -18,9 +18,9 @@ name = "actix_web_httpauth"
path = "src/lib.rs"
[dependencies]
actix-service = "2.0.0"
actix-service = "2"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.14", default_features = false }
actix-web = { version = "4.0.0-beta.15", default_features = false }
base64 = "0.13"
futures-util = { version = "0.3.7", default-features = false }

View File

@ -3,9 +3,9 @@
> HTTP authentication schemes for [actix-web](https://github.com/actix/actix-web).
[![crates.io](https://img.shields.io/crates/v/actix-web-httpauth?label=latest)](https://crates.io/crates/actix-web-httpauth)
[![Documentation](https://docs.rs/actix-web-httpauth/badge.svg?version=0.6.0-beta.5)](https://docs.rs/actix-web-httpauth/0.6.0-beta.5)
[![Documentation](https://docs.rs/actix-web-httpauth/badge.svg?version=0.6.0-beta.6)](https://docs.rs/actix-web-httpauth/0.6.0-beta.6)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-web-httpauth)
[![Dependency Status](https://deps.rs/crate/actix-web-httpauth/0.6.0-beta.5/status.svg)](https://deps.rs/crate/actix-web-httpauth/0.6.0-beta.5)
[![Dependency Status](https://deps.rs/crate/actix-web-httpauth/0.6.0-beta.6/status.svg)](https://deps.rs/crate/actix-web-httpauth/0.6.0-beta.6)
## Documentation & Resources

View File

@ -1,7 +1,7 @@
use std::fmt;
use actix_web::error::ParseError;
use actix_web::http::header::{Header, HeaderName, HeaderValue, IntoHeaderValue, AUTHORIZATION};
use actix_web::http::header::{Header, HeaderName, HeaderValue, TryIntoHeaderValue, AUTHORIZATION};
use actix_web::HttpMessage;
use crate::headers::authorization::scheme::Scheme;
@ -86,8 +86,8 @@ impl<S: Scheme> Header for Authorization<S> {
}
}
impl<S: Scheme> IntoHeaderValue for Authorization<S> {
type Error = <S as IntoHeaderValue>::Error;
impl<S: Scheme> TryIntoHeaderValue for Authorization<S> {
type Error = <S as TryIntoHeaderValue>::Error;
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
self.0.try_into_value()

View File

@ -1,12 +1,11 @@
use std::borrow::Cow;
use std::fmt;
use std::str;
use std::{borrow::Cow, fmt, str};
use actix_web::http::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue};
use actix_web::web::{BufMut, BytesMut};
use actix_web::{
http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue},
web::{BufMut, BytesMut},
};
use crate::headers::authorization::errors::ParseError;
use crate::headers::authorization::Scheme;
use crate::headers::authorization::{errors::ParseError, Scheme};
/// Credentials for `Basic` authentication scheme, defined in [RFC 7617](https://tools.ietf.org/html/rfc7617)
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
@ -94,10 +93,10 @@ impl fmt::Display for Basic {
}
}
impl IntoHeaderValue for Basic {
impl TryIntoHeaderValue for Basic {
type Error = InvalidHeaderValue;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
let mut credentials = BytesMut::with_capacity(
self.user_id.len()
+ 1 // ':'
@ -123,8 +122,7 @@ impl IntoHeaderValue for Basic {
#[cfg(test)]
mod tests {
use super::{Basic, Scheme};
use actix_web::http::header::{HeaderValue, IntoHeaderValue};
use super::*;
#[test]
fn test_parse_header() {

View File

@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::fmt;
use actix_web::http::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue};
use actix_web::http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue};
use actix_web::web::{BufMut, BytesMut};
use crate::headers::authorization::errors::ParseError;
@ -73,10 +73,10 @@ impl fmt::Display for Bearer {
}
}
impl IntoHeaderValue for Bearer {
impl TryIntoHeaderValue for Bearer {
type Error = InvalidHeaderValue;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
let mut buffer = BytesMut::with_capacity(7 + self.token.len());
buffer.put(&b"Bearer "[..]);
buffer.extend_from_slice(self.token.as_bytes());
@ -87,8 +87,7 @@ impl IntoHeaderValue for Bearer {
#[cfg(test)]
mod tests {
use super::{Bearer, Scheme};
use actix_web::http::header::{HeaderValue, IntoHeaderValue};
use super::*;
#[test]
fn test_parse_header() {

View File

@ -1,6 +1,6 @@
use std::fmt::{Debug, Display};
use actix_web::http::header::{HeaderValue, IntoHeaderValue};
use actix_web::http::header::{HeaderValue, TryIntoHeaderValue};
pub mod basic;
pub mod bearer;
@ -9,7 +9,7 @@ use crate::headers::authorization::errors::ParseError;
/// Authentication scheme for [`Authorization`](./struct.Authorization.html)
/// header.
pub trait Scheme: IntoHeaderValue + Debug + Display + Clone + Send + Sync {
pub trait Scheme: TryIntoHeaderValue + Debug + Display + Clone + Send + Sync {
/// Try to parse the authentication scheme from the `Authorization` header.
fn parse(header: &HeaderValue) -> Result<Self, ParseError>;
}

View File

@ -5,7 +5,7 @@ use std::default::Default;
use std::fmt;
use std::str;
use actix_web::http::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue};
use actix_web::http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue};
use actix_web::web::{BufMut, Bytes, BytesMut};
use super::Challenge;
@ -103,18 +103,17 @@ impl fmt::Display for Basic {
}
}
impl IntoHeaderValue for Basic {
impl TryIntoHeaderValue for Basic {
type Error = InvalidHeaderValue;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
HeaderValue::from_maybe_shared(self.to_bytes())
}
}
#[cfg(test)]
mod tests {
use super::Basic;
use actix_web::http::header::IntoHeaderValue;
use super::*;
#[test]
fn test_plain_into_header_value() {

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use std::fmt;
use std::str;
use actix_web::http::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue};
use actix_web::http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue};
use actix_web::web::{BufMut, Bytes, BytesMut};
use super::super::Challenge;
@ -130,10 +130,10 @@ impl fmt::Display for Bearer {
}
}
impl IntoHeaderValue for Bearer {
impl TryIntoHeaderValue for Bearer {
type Error = InvalidHeaderValue;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
HeaderValue::from_maybe_shared(self.to_bytes())
}
}

View File

@ -1,13 +1,12 @@
use std::fmt::{Debug, Display};
use actix_web::http::header::IntoHeaderValue;
use actix_web::web::Bytes;
use actix_web::{http::header::TryIntoHeaderValue, web::Bytes};
pub mod basic;
pub mod bearer;
/// Authentication challenge for `WWW-Authenticate` header.
pub trait Challenge: IntoHeaderValue + Debug + Display + Clone + Send + Sync {
pub trait Challenge: TryIntoHeaderValue + Debug + Display + Clone + Send + Sync {
/// Converts the challenge into a bytes suitable for HTTP transmission.
fn to_bytes(&self) -> Bytes;
}

View File

@ -1,6 +1,8 @@
use actix_web::error::ParseError;
use actix_web::http::header::{Header, HeaderName, HeaderValue, IntoHeaderValue, WWW_AUTHENTICATE};
use actix_web::HttpMessage;
use actix_web::{
error::ParseError,
http::header::{Header, HeaderName, HeaderValue, TryIntoHeaderValue, WWW_AUTHENTICATE},
HttpMessage,
};
use super::Challenge;
@ -22,10 +24,10 @@ impl<C: Challenge> Header for WwwAuthenticate<C> {
}
}
impl<C: Challenge> IntoHeaderValue for WwwAuthenticate<C> {
type Error = <C as IntoHeaderValue>::Error;
impl<C: Challenge> TryIntoHeaderValue for WwwAuthenticate<C> {
type Error = <C as TryIntoHeaderValue>::Error;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
self.0.try_into_value()
}
}

View File

@ -1,7 +1,6 @@
//! HTTP Authentication middleware.
use std::{
error::Error as StdError,
future::Future,
marker::PhantomData,
pin::Pin,
@ -125,7 +124,7 @@ where
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = Error;
@ -160,7 +159,7 @@ where
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
T: AuthExtractor + 'static,
B: MessageBody + 'static,
B::Error: StdError,
B::Error: Into<Error>,
{
type Response = ServiceResponse<EitherBody<B>>;
type Error = S::Error;