From ac444ca798694dfeeab002c9bf422469622a17ee Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 28 Oct 2022 23:44:21 +0100 Subject: [PATCH 1/7] add support for private network access cors header (#297) closes #294 --- actix-cors/CHANGES.md | 1 + actix-cors/Cargo.toml | 9 ++-- actix-cors/src/builder.rs | 36 ++++++++++--- actix-cors/src/inner.rs | 14 ++++++ actix-cors/src/lib.rs | 14 ++++-- actix-cors/src/middleware.rs | 25 +++++++++ actix-cors/tests/tests.rs | 98 +++++++++++++++++++++++++++++++++++- 7 files changed, 183 insertions(+), 14 deletions(-) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index 8ad8ae4f1..ee3b24d5d 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -1,6 +1,7 @@ # Changes ## Unreleased - 2022-xx-xx +- Add `Cors::allow_private_network_access()` behind an unstable flag (`draft-private-network-access`). [#297] ## 0.6.3 - 2022-09-21 diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 7f1847eb5..22baadd87 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -12,9 +12,12 @@ repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" edition = "2018" -[lib] -name = "actix_cors" -path = "src/lib.rs" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true + +[features] +draft-private-network-access = [] [dependencies] actix-utils = "3" diff --git a/actix-cors/src/builder.rs b/actix-cors/src/builder.rs index 4cf751e00..16d4a1578 100644 --- a/actix-cors/src/builder.rs +++ b/actix-cors/src/builder.rs @@ -101,6 +101,8 @@ impl Cors { preflight: true, send_wildcard: false, supports_credentials: true, + #[cfg(feature = "draft-private-network-access")] + allow_private_network_access: false, vary_header: true, block_on_origin_mismatch: true, }; @@ -370,7 +372,7 @@ impl Cors { /// [Fetch Standard CORS protocol]: https://fetch.spec.whatwg.org/#http-cors-protocol pub fn max_age(mut self, max_age: impl Into>) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.max_age = max_age.into() + cors.max_age = max_age.into(); } self @@ -389,7 +391,7 @@ impl Cors { /// Defaults to `false`. pub fn send_wildcard(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.send_wildcard = true + cors.send_wildcard = true; } self @@ -412,7 +414,27 @@ impl Cors { /// [Fetch Standard CORS protocol]: https://fetch.spec.whatwg.org/#http-cors-protocol pub fn supports_credentials(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.supports_credentials = true + cors.supports_credentials = true; + } + + self + } + + /// Allow private network access. + /// + /// If true, injects the `Access-Control-Allow-Private-Network: true` header in responses if the + /// request contained the `Access-Control-Request-Private-Network: true` header. + /// + /// For more information on this behavior, see the draft [Private Network Access] spec. + /// + /// Defaults to `false`. + /// + /// [Private Network Access]: https://wicg.github.io/private-network-access + #[cfg(feature = "draft-private-network-access")] + #[cfg_attr(docsrs, doc(cfg(feature = "draft-private-network-access")))] + pub fn allow_private_network_access(mut self) -> Cors { + if let Some(cors) = cors(&mut self.inner, &self.error) { + cors.allow_private_network_access = true; } self @@ -430,7 +452,7 @@ impl Cors { /// By default, `Vary` header support is enabled. pub fn disable_vary_header(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.vary_header = false + cors.vary_header = false; } self @@ -444,7 +466,7 @@ impl Cors { /// By default *preflight* support is enabled. pub fn disable_preflight(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.preflight = false + cors.preflight = false; } self @@ -462,7 +484,7 @@ impl Cors { /// Defaults to `true`. pub fn block_on_origin_mismatch(mut self, block: bool) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.block_on_origin_mismatch = block + cors.block_on_origin_mismatch = block; } self @@ -492,6 +514,8 @@ impl Default for Cors { preflight: true, send_wildcard: false, supports_credentials: false, + #[cfg(feature = "draft-private-network-access")] + allow_private_network_access: false, vary_header: true, block_on_origin_mismatch: true, }; diff --git a/actix-cors/src/inner.rs b/actix-cors/src/inner.rs index 617bcd2ff..f5ab671cb 100644 --- a/actix-cors/src/inner.rs +++ b/actix-cors/src/inner.rs @@ -64,6 +64,8 @@ pub(crate) struct Inner { pub(crate) preflight: bool, pub(crate) send_wildcard: bool, pub(crate) supports_credentials: bool, + #[cfg(feature = "draft-private-network-access")] + pub(crate) allow_private_network_access: bool, pub(crate) vary_header: bool, pub(crate) block_on_origin_mismatch: bool, } @@ -219,8 +221,20 @@ pub(crate) fn add_vary_header(headers: &mut HeaderMap) { let mut val: Vec = Vec::with_capacity(hdr.len() + 71); val.extend(hdr.as_bytes()); val.extend(b", Origin, Access-Control-Request-Method, Access-Control-Request-Headers"); + + #[cfg(feature = "draft-private-network-access")] + val.extend(b", Access-Control-Allow-Private-Network"); + val.try_into().unwrap() } + + #[cfg(feature = "draft-private-network-access")] + None => HeaderValue::from_static( + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \ + Access-Control-Allow-Private-Network", + ), + + #[cfg(not(feature = "draft-private-network-access"))] None => HeaderValue::from_static( "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ), diff --git a/actix-cors/src/lib.rs b/actix-cors/src/lib.rs index 4f343b729..b8cc3697b 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -1,11 +1,16 @@ //! Cross-Origin Resource Sharing (CORS) controls for Actix Web. //! -//! This middleware can be applied to both applications and resources. Once built, a -//! [`Cors`] builder can be used as an argument for Actix Web's `App::wrap()`, -//! `Scope::wrap()`, or `Resource::wrap()` methods. +//! This middleware can be applied to both applications and resources. Once built, a [`Cors`] +//! builder can be used as an argument for Actix Web's `App::wrap()`, `Scope::wrap()`, or +//! `Resource::wrap()` methods. //! //! This CORS middleware automatically handles `OPTIONS` preflight requests. //! +//! # Crate Features +//! - `draft-private-network-access`: ⚠️ Unstable. Adds opt-in support for the [Private Network +//! Access] spec extensions. This feature is unstable since it will follow any breaking changes in +//! the draft spec until it is finalized. +//! //! # Example //! ```no_run //! use actix_cors::Cors; @@ -40,12 +45,15 @@ //! Ok(()) //! } //! ``` +//! +//! [Private Network Access]: https://wicg.github.io/private-network-access #![forbid(unsafe_code)] #![deny(rust_2018_idioms, nonstandard_style)] #![warn(future_incompatible, missing_docs, missing_debug_implementations)] #![doc(html_logo_url = "https://actix.rs/img/logo.png")] #![doc(html_favicon_url = "https://actix.rs/favicon.ico")] +#![cfg_attr(docsrs, feature(doc_cfg))] mod all_or_some; mod builder; diff --git a/actix-cors/src/middleware.rs b/actix-cors/src/middleware.rs index 552c947d6..81055d439 100644 --- a/actix-cors/src/middleware.rs +++ b/actix-cors/src/middleware.rs @@ -93,6 +93,18 @@ impl CorsMiddleware { res.insert_header((header::ACCESS_CONTROL_ALLOW_HEADERS, headers.clone())); } + #[cfg(feature = "draft-private-network-access")] + if inner.allow_private_network_access + && req + .headers() + .contains_key("access-control-request-private-network") + { + res.insert_header(( + header::HeaderName::from_static("access-control-allow-private-network"), + HeaderValue::from_static("true"), + )); + } + if inner.supports_credentials { res.insert_header(( header::ACCESS_CONTROL_ALLOW_CREDENTIALS, @@ -162,6 +174,19 @@ impl CorsMiddleware { ); } + #[cfg(feature = "draft-private-network-access")] + if inner.allow_private_network_access + && res + .request() + .headers() + .contains_key("access-control-request-private-network") + { + res.headers_mut().insert( + header::HeaderName::from_static("access-control-allow-private-network"), + HeaderValue::from_static("true"), + ); + } + if inner.vary_header { add_vary_header(res.headers_mut()); } diff --git a/actix-cors/tests/tests.rs b/actix-cors/tests/tests.rs index 2637b4950..e08c76678 100644 --- a/actix-cors/tests/tests.rs +++ b/actix-cors/tests/tests.rs @@ -264,10 +264,16 @@ async fn test_response() { .get(header::ACCESS_CONTROL_ALLOW_ORIGIN) .map(HeaderValue::as_bytes) ); + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers().get(header::VARY).map(HeaderValue::as_bytes), Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers"[..]), ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers().get(header::VARY).map(HeaderValue::as_bytes), + Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network"[..]), + ); #[allow(clippy::needless_collect)] { @@ -311,9 +317,18 @@ async fn test_response() { .method(Method::OPTIONS) .to_srv_request(); let resp = test::call_service(&cors, req).await; + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( - resp.headers().get(header::VARY).map(HeaderValue::as_bytes), - Some(&b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers"[..]), + resp.headers() + .get(header::VARY) + .map(HeaderValue::as_bytes) + .unwrap(), + b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers", + ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers().get(header::VARY).map(HeaderValue::as_bytes).unwrap(), + b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", ); let cors = Cors::default() @@ -463,6 +478,7 @@ async fn vary_header_on_all_handled_responses() { assert!(resp .headers() .contains_key(header::ACCESS_CONTROL_ALLOW_METHODS)); + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -471,6 +487,15 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers() + .get(header::VARY) + .expect("response should have Vary header") + .to_str() + .unwrap(), + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", + ); // follow-up regular request let req = TestRequest::default() @@ -479,6 +504,7 @@ async fn vary_header_on_all_handled_responses() { .to_srv_request(); let resp = test::call_service(&cors, req).await; assert_eq!(resp.status(), StatusCode::OK); + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -487,6 +513,15 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers() + .get(header::VARY) + .expect("response should have Vary header") + .to_str() + .unwrap(), + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", + ); let cors = Cors::default() .allow_any_method() @@ -501,6 +536,7 @@ async fn vary_header_on_all_handled_responses() { .to_srv_request(); let resp = test::call_service(&cors, req).await; assert_eq!(resp.status(), StatusCode::BAD_REQUEST); + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -509,11 +545,21 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers() + .get(header::VARY) + .expect("response should have Vary header") + .to_str() + .unwrap(), + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", + ); // regular request no origin let req = TestRequest::default().method(Method::PUT).to_srv_request(); let resp = test::call_service(&cors, req).await; assert_eq!(resp.status(), StatusCode::OK); + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -522,6 +568,15 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); + #[cfg(feature = "draft-private-network-access")] + assert_eq!( + resp.headers() + .get(header::VARY) + .expect("response should have Vary header") + .to_str() + .unwrap(), + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", + ); } #[actix_web::test] @@ -578,3 +633,42 @@ async fn expose_all_request_header_values() { assert!(cd_hdr.contains("content-disposition")); assert!(cd_hdr.contains("access-control-allow-origin")); } + +#[cfg(feature = "draft-private-network-access")] +#[actix_web::test] +async fn private_network_access() { + let cors = Cors::permissive() + .allowed_origin("https://public.site") + .allow_private_network_access() + .new_transform(fn_service(|req: ServiceRequest| async move { + let res = req.into_response( + HttpResponse::Ok() + .insert_header((header::CONTENT_DISPOSITION, "test disposition")) + .finish(), + ); + + Ok(res) + })) + .await + .unwrap(); + + let req = TestRequest::default() + .insert_header((header::ORIGIN, "https://public.site")) + .insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, "POST")) + .insert_header((header::ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")) + .to_srv_request(); + let res = test::call_service(&cors, req).await; + assert!(res.headers().contains_key("access-control-allow-origin")); + + let req = TestRequest::default() + .insert_header((header::ORIGIN, "https://public.site")) + .insert_header((header::ACCESS_CONTROL_REQUEST_METHOD, "POST")) + .insert_header((header::ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")) + .insert_header(("Access-Control-Request-Private-Network", "true")) + .to_srv_request(); + let res = test::call_service(&cors, req).await; + assert!(res.headers().contains_key("access-control-allow-origin")); + assert!(res + .headers() + .contains_key("access-control-allow-private-network")); +} From b95ce3a2101f141ee673b6c7ee552d9603310394 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 28 Oct 2022 23:49:28 +0100 Subject: [PATCH 2/7] prepare actix-cors release 0.6.4 --- actix-cors/CHANGES.md | 3 +++ actix-cors/Cargo.toml | 2 +- actix-cors/README.md | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index ee3b24d5d..d9924c295 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2022-xx-xx + + +## 0.6.4 - 2022-10-28 - Add `Cors::allow_private_network_access()` behind an unstable flag (`draft-private-network-access`). [#297] diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 22baadd87..48ab1671a 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-cors" -version = "0.6.3" +version = "0.6.4" authors = [ "Nikolay Kim ", "Rob Ede ", diff --git a/actix-cors/README.md b/actix-cors/README.md index 9489226e1..4c936a52b 100644 --- a/actix-cors/README.md +++ b/actix-cors/README.md @@ -3,9 +3,9 @@ > Cross-Origin Resource Sharing (CORS) controls 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.3)](https://docs.rs/actix-cors/0.6.3) +[![Documentation](https://docs.rs/actix-cors/badge.svg?version=0.6.4)](https://docs.rs/actix-cors/0.6.4) ![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-cors) -[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.3/status.svg)](https://deps.rs/crate/actix-cors/0.6.3) +[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.4/status.svg)](https://deps.rs/crate/actix-cors/0.6.4) ## Documentation & Resources From 1ac325ab79e8287dd8102478c24e949e6dd5eb70 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 30 Oct 2022 16:28:21 +0000 Subject: [PATCH 3/7] fix cors changelog --- actix-cors/CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index d9924c295..3e7896505 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -6,6 +6,8 @@ ## 0.6.4 - 2022-10-28 - Add `Cors::allow_private_network_access()` behind an unstable flag (`draft-private-network-access`). [#297] +[#297]: https://github.com/actix/actix-extras/pull/297 + ## 0.6.3 - 2022-09-21 - Add `Cors::block_on_origin_mismatch()` option for controlling if requests are pre-emptively rejected. [#287] From 8fd166435fa1247bdd34cc448ac84d776edbee50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Even=20O=2E=20Rogstadkj=C3=A6rnet?= Date: Tue, 8 Nov 2022 10:29:23 +0100 Subject: [PATCH 4/7] Add secure field to removal cookie (#300) Closes https://github.com/actix/actix-extras/issues/299 --- actix-session/CHANGES.md | 2 ++ actix-session/src/middleware.rs | 1 + actix-session/tests/middleware.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 0dd47e5be..44da7fe39 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,7 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx +- Set secure attribute when adding a session removal cookie. [#300] +[#300]: https://github.com/actix/actix-extras/pull/300 ## 0.7.2 - 2022-09-11 - Set SameSite attribute when adding a session removal cookie. [#284] diff --git a/actix-session/src/middleware.rs b/actix-session/src/middleware.rs index 9a055c9fd..9bab74bf3 100644 --- a/actix-session/src/middleware.rs +++ b/actix-session/src/middleware.rs @@ -444,6 +444,7 @@ fn delete_session_cookie( ) -> Result<(), anyhow::Error> { let removal_cookie = Cookie::build(config.name.clone(), "") .path(config.path.clone()) + .secure(config.secure) .http_only(config.http_only) .same_site(config.same_site); diff --git a/actix-session/tests/middleware.rs b/actix-session/tests/middleware.rs index 8b9f278c4..5058b8b11 100644 --- a/actix-session/tests/middleware.rs +++ b/actix-session/tests/middleware.rs @@ -48,7 +48,7 @@ async fn cookie_storage() -> std::io::Result<()> { let deletion_cookie = logout_response.response().cookies().next().unwrap(); assert_eq!(deletion_cookie.name(), "id"); assert_eq!(deletion_cookie.path().unwrap(), "/test"); - assert!(deletion_cookie.secure().is_none()); + assert!(deletion_cookie.secure().unwrap()); assert!(deletion_cookie.http_only().unwrap()); assert_eq!(deletion_cookie.max_age().unwrap(), Duration::ZERO); assert_eq!(deletion_cookie.domain().unwrap(), "localhost"); From 8e76c6c6288df577ef437c08c7110273bc702fee Mon Sep 17 00:00:00 2001 From: aalhitennf Date: Sat, 12 Nov 2022 15:26:16 +0200 Subject: [PATCH 5/7] add bincode extractor lib to community crates (#303) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6c48f6351..164971103 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ These crates are provided by the community. | [tracing-actix-web] | [![crates.io](https://img.shields.io/crates/v/tracing-actix-web?label=latest)][tracing-actix-web] [![dependency status](https://deps.rs/crate/tracing-actix-web/0.6.0/status.svg)](https://deps.rs/crate/tracing-actix-web/0.6.0) | A middleware to collect telemetry data from applications built on top of the actix-web framework. | | [actix-ws] | [![crates.io](https://img.shields.io/crates/v/actix-ws?label=latest)][actix-ws] [![dependency status](https://deps.rs/crate/actix-ws/0.2.5/status.svg)](https://deps.rs/crate/actix-ws/0.2.5) | Actor-less WebSockets for the Actix Runtime. | | [actix-hash] | [![crates.io](https://img.shields.io/crates/v/actix-hash?label=latest)][actix-hash] [![dependency status](https://deps.rs/crate/actix-hash/0.4.0/status.svg)](https://deps.rs/crate/actix-hash/0.4.0) | Hashing utilities for Actix Web. | +| [actix-bincode](https://crates.io/crates/actix-bincode) | ![crates.io](https://img.shields.io/crates/v/actix-bincode?label=latest) [![dependency status](https://deps.rs/crate/actix-bincode/0.2.0/status.svg)](https://deps.rs/crate/actix-bincode/0.2.0) | Bincode payload extractor for Actix Web | To add a crate to this list, submit a pull request. From 9508be94d5a3f183ed6f04212ccf41bd4ac1c4f7 Mon Sep 17 00:00:00 2001 From: aalhitennf Date: Sat, 12 Nov 2022 21:52:29 +0200 Subject: [PATCH 6/7] Update README.md (#304) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 164971103..a4b34ee29 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ These crates are provided by the community. | [tracing-actix-web] | [![crates.io](https://img.shields.io/crates/v/tracing-actix-web?label=latest)][tracing-actix-web] [![dependency status](https://deps.rs/crate/tracing-actix-web/0.6.0/status.svg)](https://deps.rs/crate/tracing-actix-web/0.6.0) | A middleware to collect telemetry data from applications built on top of the actix-web framework. | | [actix-ws] | [![crates.io](https://img.shields.io/crates/v/actix-ws?label=latest)][actix-ws] [![dependency status](https://deps.rs/crate/actix-ws/0.2.5/status.svg)](https://deps.rs/crate/actix-ws/0.2.5) | Actor-less WebSockets for the Actix Runtime. | | [actix-hash] | [![crates.io](https://img.shields.io/crates/v/actix-hash?label=latest)][actix-hash] [![dependency status](https://deps.rs/crate/actix-hash/0.4.0/status.svg)](https://deps.rs/crate/actix-hash/0.4.0) | Hashing utilities for Actix Web. | -| [actix-bincode](https://crates.io/crates/actix-bincode) | ![crates.io](https://img.shields.io/crates/v/actix-bincode?label=latest) [![dependency status](https://deps.rs/crate/actix-bincode/0.2.0/status.svg)](https://deps.rs/crate/actix-bincode/0.2.0) | Bincode payload extractor for Actix Web | +| [actix-bincode] | ![crates.io](https://img.shields.io/crates/v/actix-bincode?label=latest) [![dependency status](https://deps.rs/crate/actix-bincode/0.2.0/status.svg)](https://deps.rs/crate/actix-bincode/0.2.0) | Bincode payload extractor for Actix Web | To add a crate to this list, submit a pull request. @@ -73,3 +73,4 @@ To add a crate to this list, submit a pull request. [tracing-actix-web]: https://crates.io/crates/tracing-actix-web [actix-ws]: https://crates.io/crates/actix-ws [actix-hash]: https://crates.io/crates/actix-hash +[actix-bincode]: https://crates.io/crates/actix-bincode From 1774b8a36ef145bb85e2c0db50c9ff78f844804e Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 1 Dec 2022 19:45:31 +0900 Subject: [PATCH 7/7] Fix GHA deprecation warnings (#301) --- .github/workflows/ci-post-merge.yml | 40 ++++++-------- .github/workflows/ci.yml | 81 +++++++++++------------------ .github/workflows/coverage.yml | 15 +++--- .github/workflows/lint.yml | 27 ++++------ .github/workflows/upload-doc.yml | 13 ++--- 5 files changed, 64 insertions(+), 112 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index 2de0ee349..af0e15531 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -42,7 +42,7 @@ jobs: with: command: generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + uses: Swatinem/rust-cache@v2.1.0 - name: check minimal uses: actions-rs/cargo@v1 @@ -72,7 +72,11 @@ jobs: matrix: target: - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } - - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } + - { + name: Windows, + os: windows-latest, + triple: x86_64-pc-windows-msvc, + } version: - nightly @@ -83,44 +87,30 @@ jobs: - uses: actions/checkout@v3 - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} - profile: minimal - override: true + run: | + rustup install ${{ matrix.version }}-${{ matrix.target.triple }} + rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: - command: generate-lockfile + run: cargo generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + uses: Swatinem/rust-cache@v2.1.0 - name: check minimal - uses: actions-rs/cargo@v1 - with: { command: ci-min } + run: cargo ci-min - name: check minimal + examples - uses: actions-rs/cargo@v1 - with: { command: ci-check-min-examples } + run: cargo ci-check-min-examples - name: check default - uses: actions-rs/cargo@v1 - with: { command: ci-check } + run: cargo ci-check - name: tests - uses: actions-rs/cargo@v1 timeout-minutes: 40 - with: - command: ci-test - args: >- - --exclude=actix-redis - --exclude=actix-session - --exclude=actix-limitation - -- --nocapture + run: cargo ci-test --exclude=actix-redis --exclude=actix-session --exclude=actix-limitation -- --nocapture - name: Clear the cargo caches run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b6bda9f4..ed53e46a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,38 +36,30 @@ jobs: - uses: actions/checkout@v3 - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} - profile: minimal - override: true + run: | + rustup install ${{ matrix.version }}-${{ matrix.target.triple }} + rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: - command: generate-lockfile + run: cargo generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + uses: Swatinem/rust-cache@v2.1.0 - name: check minimal - uses: actions-rs/cargo@v1 - with: { command: ci-min } + run: cargo ci-min - name: check minimal + examples - uses: actions-rs/cargo@v1 - with: { command: ci-check-min-examples } + run: cargo ci-check-min-examples - name: check default - uses: actions-rs/cargo@v1 - with: { command: ci-check } + run: cargo ci-check - name: tests - uses: actions-rs/cargo@v1 timeout-minutes: 40 - with: { command: ci-test } + run: cargo ci-test - name: Clear the cargo caches run: | @@ -80,7 +72,11 @@ jobs: matrix: target: - { name: macOS, os: macos-latest, triple: x86_64-apple-darwin } - - { name: Windows, os: windows-latest, triple: x86_64-pc-windows-msvc } + - { + name: Windows, + os: windows-latest, + triple: x86_64-pc-windows-msvc, + } version: - 1.59 # MSRV - stable @@ -92,43 +88,30 @@ jobs: - uses: actions/checkout@v3 - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} - profile: minimal - override: true + run: | + rustup install ${{ matrix.version }}-${{ matrix.target.triple }} + rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: - command: generate-lockfile + run: cargo generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + uses: Swatinem/rust-cache@v2.1.0 - name: check minimal - uses: actions-rs/cargo@v1 - with: { command: ci-min } + run: cargo ci-min - name: check minimal + examples - uses: actions-rs/cargo@v1 - with: { command: ci-check-min-examples } + run: cargo ci-check-min-examples - name: check default - uses: actions-rs/cargo@v1 - with: { command: ci-check } + run: cargo ci-check - name: tests - uses: actions-rs/cargo@v1 timeout-minutes: 40 - with: - command: ci-test - args: >- - --exclude=actix-redis - --exclude=actix-session - --exclude=actix-limitation + run: cargo ci-test --exclude=actix-redis --exclude=actix-session --exclude=actix-limitation - name: Clear the cargo caches run: | @@ -142,21 +125,15 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust (nightly) - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-x86_64-unknown-linux-gnu - profile: minimal - override: true + run: | + rustup install nightly + rustup override set nightly - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: { command: generate-lockfile } + run: cargo generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.3.0 + uses: Swatinem/rust-cache@v2.1.0 - name: doc tests - uses: actions-rs/cargo@v1 timeout-minutes: 40 - with: - command: ci-doctest - args: -- --nocapture + run: cargo ci-doctest -- --nocapture diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2d8ec2d4c..86427041c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -21,22 +21,19 @@ jobs: - uses: actions/checkout@v3 - name: Install stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable-x86_64-unknown-linux-gnu - profile: minimal - override: true + run: | + rustup override set stable + rustup update stable - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: { command: generate-lockfile } + run: cargo generate-lockfile - name: Cache Dependencies - uses: Swatinem/rust-cache@v1.2.0 + uses: Swatinem/rust-cache@v2.1.0 - name: Generate coverage file run: | cargo install cargo-tarpaulin --vers "^0.13" cargo tarpaulin --workspace --out Xml --verbose - name: Upload to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: { file: cobertura.xml } diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ec65be585..0c2bd4ef5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,15 +11,12 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - components: rustfmt + run: | + rustup override set nightly + rustup update nightly + rustup component add rustfmt - name: Check with rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + run: cargo fmt --all -- --check clippy: runs-on: ubuntu-latest @@ -27,13 +24,9 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: clippy - override: true + run: | + rustup override set stable + rustup update stable + rustup component add rustfmt - name: Check with Clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --workspace --tests --all-features + run: cargo clippy --workspace --tests --all-features diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index bae24c567..2cae41484 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -12,17 +12,12 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-x86_64-unknown-linux-gnu - profile: minimal - override: true + run: | + rustup override set nightly + rustup update nightly - name: Build Docs - uses: actions-rs/cargo@v1 - with: - command: doc - args: --workspace --all-features --no-deps + run: cargo doc --workspace --all-features --no-deps - name: Tweak HTML run: echo '' > target/doc/index.html