From 6676a509443306cd589e10e16d1617154c40ee23 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 18 Dec 2021 03:37:23 +0000 Subject: [PATCH] actix-web beta 15 updates (#216) --- actix-cors/CHANGES.md | 6 ++++++ actix-cors/Cargo.toml | 6 +++--- actix-cors/README.md | 4 ++-- actix-cors/src/builder.rs | 9 ++++----- actix-cors/src/middleware.rs | 10 +++++----- actix-identity/CHANGES.md | 6 ++++++ actix-identity/Cargo.toml | 8 ++++---- actix-identity/README.md | 4 ++-- actix-identity/src/middleware.rs | 6 +++--- actix-redis/Cargo.toml | 2 +- actix-session/CHANGES.md | 6 ++++++ actix-session/Cargo.toml | 8 ++++---- actix-session/README.md | 4 ++-- actix-session/src/cookie.rs | 8 ++++---- actix-web-httpauth/CHANGES.md | 6 ++++++ actix-web-httpauth/Cargo.toml | 8 ++++---- actix-web-httpauth/README.md | 4 ++-- .../src/headers/authorization/header.rs | 6 +++--- .../src/headers/authorization/scheme/basic.rs | 20 +++++++++---------- .../headers/authorization/scheme/bearer.rs | 9 ++++----- .../src/headers/authorization/scheme/mod.rs | 4 ++-- .../www_authenticate/challenge/basic.rs | 9 ++++----- .../challenge/bearer/challenge.rs | 6 +++--- .../headers/www_authenticate/challenge/mod.rs | 5 ++--- .../src/headers/www_authenticate/header.rs | 14 +++++++------ actix-web-httpauth/src/middleware.rs | 5 ++--- 26 files changed, 101 insertions(+), 82 deletions(-) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index 4fbc3f6c3..f6977413f 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -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] diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index b7531b9e6..95e555cfb 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-cors" -version = "0.6.0-beta.6" +version = "0.6.0-beta.7" authors = [ "Nikolay Kim ", "Rob Ede ", @@ -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 } diff --git a/actix-cors/README.md b/actix-cors/README.md index a54fcc72a..13c4a4a52 100644 --- a/actix-cors/README.md +++ b/actix-cors/README.md @@ -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 diff --git a/actix-cors/src/builder.rs b/actix-cors/src/builder.rs index 6131fa297..0828eb840 100644 --- a/actix-cors/src/builder.rs +++ b/actix-cors/src/builder.rs @@ -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 Transform for Cors where S: Service, Error = Error>, S::Future: 'static, + B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; 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(); diff --git a/actix-cors/src/middleware.rs b/actix-cors/src/middleware.rs index 54cfacf86..71aecfbe9 100644 --- a/actix-cors/src/middleware.rs +++ b/actix-cors/src/middleware.rs @@ -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 Service for CorsMiddleware where S: Service, Error = Error>, S::Future: 'static, + B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; 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()) } diff --git a/actix-identity/CHANGES.md b/actix-identity/CHANGES.md index c05f5da3d..7df335fc1 100644 --- a/actix-identity/CHANGES.md +++ b/actix-identity/CHANGES.md @@ -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] diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 734397035..c03373c33 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "actix-identity" -version = "0.4.0-beta.5" +version = "0.4.0-beta.6" authors = ["Nikolay Kim "] -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" diff --git a/actix-identity/README.md b/actix-identity/README.md index da8bc9968..16bee5405 100644 --- a/actix-identity/README.md +++ b/actix-identity/README.md @@ -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 diff --git a/actix-identity/src/middleware.rs b/actix-identity/src/middleware.rs index b768e098e..67ad23e73 100644 --- a/actix-identity/src/middleware.rs +++ b/actix-identity/src/middleware.rs @@ -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, { type Response = ServiceResponse>; type Error = Error; @@ -80,7 +80,7 @@ where S::Future: 'static, T: IdentityPolicy, B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; type Error = Error; diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 1668e4c65..07e36c477 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -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 } diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 6eb25819e..a293d8652 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -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] diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index b41af7d00..2cc08196c 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "actix-session" -version = "0.5.0-beta.5" +version = "0.5.0-beta.6" authors = ["Nikolay Kim "] -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 } diff --git a/actix-session/README.md b/actix-session/README.md index bfc30a0dd..864f8100e 100644 --- a/actix-session/README.md +++ b/actix-session/README.md @@ -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 diff --git a/actix-session/src/cookie.rs b/actix-session/src/cookie.rs index 504bf5367..e1dc2f348 100644 --- a/actix-session/src/cookie.rs +++ b/actix-session/src/cookie.rs @@ -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, { type Response = ServiceResponse>; type Error = S::Error; @@ -329,7 +329,7 @@ where S::Future: 'static, S::Error: 'static, B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; 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")); } diff --git a/actix-web-httpauth/CHANGES.md b/actix-web-httpauth/CHANGES.md index 4b50ed576..d7d74dedd 100644 --- a/actix-web-httpauth/CHANGES.md +++ b/actix-web-httpauth/CHANGES.md @@ -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] diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index 144eff04c..cd0b0e4a1 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "actix-web-httpauth" -version = "0.6.0-beta.5" +version = "0.6.0-beta.6" authors = [ "svartalf ", "Yuki Okushi ", ] -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 } diff --git a/actix-web-httpauth/README.md b/actix-web-httpauth/README.md index cd2367b17..0925c22af 100644 --- a/actix-web-httpauth/README.md +++ b/actix-web-httpauth/README.md @@ -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 diff --git a/actix-web-httpauth/src/headers/authorization/header.rs b/actix-web-httpauth/src/headers/authorization/header.rs index 93e5c8231..3f0351ac7 100644 --- a/actix-web-httpauth/src/headers/authorization/header.rs +++ b/actix-web-httpauth/src/headers/authorization/header.rs @@ -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 Header for Authorization { } } -impl IntoHeaderValue for Authorization { - type Error = ::Error; +impl TryIntoHeaderValue for Authorization { + type Error = ::Error; fn try_into_value(self) -> Result { self.0.try_into_value() diff --git a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs index 595658f86..0252f581b 100644 --- a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs +++ b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs @@ -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::Error> { + fn try_into_value(self) -> Result { 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() { diff --git a/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs b/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs index 247d2c328..1efb1e24d 100644 --- a/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs +++ b/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs @@ -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::Error> { + fn try_into_value(self) -> Result { 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() { diff --git a/actix-web-httpauth/src/headers/authorization/scheme/mod.rs b/actix-web-httpauth/src/headers/authorization/scheme/mod.rs index 3224e2c43..8d22c112b 100644 --- a/actix-web-httpauth/src/headers/authorization/scheme/mod.rs +++ b/actix-web-httpauth/src/headers/authorization/scheme/mod.rs @@ -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; } diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs index 0a74f3251..a2fba66a5 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/basic.rs @@ -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::Error> { + fn try_into_value(self) -> Result { 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() { diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs index b2b5e86df..82526c2a4 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/challenge.rs @@ -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::Error> { + fn try_into_value(self) -> Result { HeaderValue::from_maybe_shared(self.to_bytes()) } } diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs index f05c1cc9f..15f87c379 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/mod.rs @@ -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; } diff --git a/actix-web-httpauth/src/headers/www_authenticate/header.rs b/actix-web-httpauth/src/headers/www_authenticate/header.rs index 2743a47a0..e7b20be6b 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/header.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/header.rs @@ -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 Header for WwwAuthenticate { } } -impl IntoHeaderValue for WwwAuthenticate { - type Error = ::Error; +impl TryIntoHeaderValue for WwwAuthenticate { + type Error = ::Error; - fn try_into_value(self) -> Result::Error> { + fn try_into_value(self) -> Result { self.0.try_into_value() } } diff --git a/actix-web-httpauth/src/middleware.rs b/actix-web-httpauth/src/middleware.rs index fa6d5651b..f93fc53cc 100644 --- a/actix-web-httpauth/src/middleware.rs +++ b/actix-web-httpauth/src/middleware.rs @@ -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> + 'static, T: AuthExtractor + 'static, B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; type Error = Error; @@ -160,7 +159,7 @@ where O: Future> + 'static, T: AuthExtractor + 'static, B: MessageBody + 'static, - B::Error: StdError, + B::Error: Into, { type Response = ServiceResponse>; type Error = S::Error;