From 8c509151f167e0a25e6b098f0b2426870f63d569 Mon Sep 17 00:00:00 2001 From: Peihao Yang <378974295@qq.com> Date: Thu, 5 Jan 2023 22:36:31 +0800 Subject: [PATCH 01/26] add sentinel middleware to community crates (#312) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a4b34ee29..6004fd153 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ These crates are provided by the community. | [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] | ![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 | +| [sentinel-actix] | ![crates.io](https://img.shields.io/crates/v/sentinel-actix?label=latest) [![dependency status](https://deps.rs/crate/sentinel-actix/0.1.0/status.svg)](https://deps.rs/crate/sentinel-actix/0.1.0) | General and flexible protection for Actix Web | To add a crate to this list, submit a pull request. @@ -74,3 +75,4 @@ To add a crate to this list, submit a pull request. [actix-ws]: https://crates.io/crates/actix-ws [actix-hash]: https://crates.io/crates/actix-hash [actix-bincode]: https://crates.io/crates/actix-bincode +[sentinel-actix]: https://crates.io/crates/sentinel-actix From 68483124678fa090f5faae454156f476470740c4 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:02:02 +0000 Subject: [PATCH 02/26] prettier markdown changelogs --- actix-cors/CHANGES.md | 53 +++++++++++++------------- actix-identity/CHANGES.md | 43 ++++++++++----------- actix-limitation/CHANGES.md | 8 ++-- actix-protobuf/CHANGES.md | 35 ++++++++--------- actix-redis/CHANGES.md | 61 ++++++++++++++++-------------- actix-session/CHANGES.md | 71 +++++++++++++++++++---------------- actix-web-httpauth/CHANGES.md | 45 +++++++++++----------- 7 files changed, 164 insertions(+), 152 deletions(-) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index 3e7896505..ee61c24c4 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -2,76 +2,77 @@ ## 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] [#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] - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. [#287]: https://github.com/actix/actix-extras/pull/287 - ## 0.6.2 - 2022-08-07 + - Fix `expose_any_header` to return list of response headers. [#273] - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. [#273]: https://github.com/actix/actix-extras/pull/273 - ## 0.6.1 - 2022-03-07 + - Do not consider requests without a `Access-Control-Request-Method` as preflight. [#226] [#226]: https://github.com/actix/actix-extras/pull/226 - ## 0.6.0 - 2022-02-25 + - Update `actix-web` dependency to 4.0. ## 0.6.0-beta.10 - 2022-02-07 + - Ensure that preflight responses contain a `Vary` header. [#224] [#224]: https://github.com/actix/actix-extras/pull/224 - ## 0.6.0-beta.9 - 2022-02-07 + - Relax body type bounds on middleware impl. [#223] - Update `actix-web` dependency to `4.0.0-rc.1`. [#223]: https://github.com/actix/actix-extras/pull/223 - ## 0.6.0-beta.8 - 2021-12-29 + - Minimum supported Rust version (MSRV) is now 1.54. - ## 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] [#213]: https://github.com/actix/actix-extras/pull/213 - ## 0.6.0-beta.5 - 2021-12-12 _(YANKED)_ + - Update `actix-web` dependency to `4.0.0.beta-14`. [#209] [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.6.0-beta.4 - 2021-11-22 + - No significant changes since `0.6.0-beta.3`. - ## 0.6.0-beta.3 - 2021-10-21 + - Make `Cors` middleware generic over body type [#195] - Fix `expose_any_header` behavior. [#204] - Update `actix-web` dependency to v4.0.0-beta.10. [#203] @@ -81,38 +82,38 @@ [#203]: https://github.com/actix/actix-extras/pull/203 [#204]: https://github.com/actix/actix-extras/pull/204 - ## 0.6.0-beta.2 - 2021-06-27 + - No notable changes. - ## 0.6.0-beta.1 - 2021-04-02 + - Update `actix-web` dependency to 4.0.0 beta. - Minimum supported Rust version (MSRV) is now 1.46.0. - ## 0.5.4 - 2020-12-31 + - Fix `expose_any_header` method, now set the correct field. [#143] [#143]: https://github.com/actix/actix-extras/pull/143 - ## 0.5.3 - 2020-11-19 + - Fix version spec for `derive_more` dependency. - ## 0.5.2 - 2020-11-15 + - Ensure `tinyvec` is using the correct features. - Bump `futures-util` minimum version to `0.3.7` to avoid `RUSTSEC-2020-0059`. - ## 0.5.1 - 2020-11-05 + - Fix `allow_any_header` method, now set the correct field. [#121] [#121]: https://github.com/actix/actix-extras/pull/121 - ## 0.5.0 - 2020-10-19 + - Disallow `*` in `Cors::allowed_origin`. [#114]. - Hide `CorsMiddleware` from docs. [#118]. - `CorsFactory` is removed. [#119] @@ -131,40 +132,40 @@ [#119]: https://github.com/actix/actix-extras/pull/119 [#120]: https://github.com/actix/actix-extras/pull/120 - ## 0.4.1 - 2020-10-07 + - Allow closures to be used with `allowed_origin_fn`. [#110] [#110]: https://github.com/actix/actix-extras/pull/110 - ## 0.4.0 - 2020-09-27 + - Implement `allowed_origin_fn` builder method. [#93] - Use `TryInto` instead of `TryFrom` where applicable. [#106] [#93]: https://github.com/actix/actix-extras/pull/93 [#106]: https://github.com/actix/actix-extras/pull/106 - ## 0.3.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimum supported Rust version (MSRV) is now 1.42.0. - Implement the Debug trait on all public types. - ## 0.3.0-alpha.1 - 2020-03-11 + - Minimize `futures-*` dependencies - Update `actix-web` dependency to 3.0.0-alpha.1 - ## 0.2.0 - 2019-12-20 + - Release - ## 0.2.0-alpha.3 - 2019-12-07 + - Migrate to actix-web 2.0.0 - Bump `derive_more` crate version to 0.99.0 - ## 0.1.0 - 2019-06-15 + - Move cors middleware to separate crate diff --git a/actix-identity/CHANGES.md b/actix-identity/CHANGES.md index d53068e22..1f7c9538d 100644 --- a/actix-identity/CHANGES.md +++ b/actix-identity/CHANGES.md @@ -1,22 +1,23 @@ # Changes ## Unreleased - 2022-xx-xx + - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. - ## 0.5.2 - 2022-07-19 + - Fix visit deadline. [#263] [#263]: https://github.com/actix/actix-extras/pull/263 - ## 0.5.1 - 2022-07-11 + - Remove unnecessary dependencies. [#259] [#259]: https://github.com/actix/actix-extras/pull/259 - ## 0.5.0 - 2022-07-11 + `actix-identity` v0.5 is a complete rewrite. The goal is to streamline user experience and reduce maintenance overhead. `actix-identity` is now designed as an additional layer on top of `actix-session` v0.7, focused on identity management. The identity information is stored in the session state, which is managed by `actix-session` and can be stored using any of the supported `SessionStore` implementations. This reduces the surface area in `actix-identity` (e.g., it is no longer concerned with cookies!) and provides a smooth upgrade path for users: if you need to work with sessions, you no longer need to choose between `actix-session` and `actix-identity`; they work together now! @@ -29,9 +30,9 @@ Changes: - `IdentityService`, `IdentityPolicy` and `CookieIdentityPolicy` have been replaced by `IdentityMiddleware`. [#246] - Rename `RequestIdentity` trait to `IdentityExt`. [#246] - Trying to extract an `Identity` for an unauthenticated user will return a `401 Unauthorized` response to the client. Extract an `Option` or a `Result` if you need to handle cases where requests may or may not be authenticated. [#246] - + Example: - + ```rust use actix_web::{http::header::LOCATION, get, HttpResponse, Responder}; use actix_identity::Identity; @@ -51,57 +52,57 @@ Changes: [#246]: https://github.com/actix/actix-extras/pull/246 - ## 0.4.0 - 2022-03-01 + - Update `actix-web` dependency to `4`. - ## 0.4.0-beta.9 - 2022-02-07 + - Relax body type bounds on middleware impl. [#223] - Update `actix-web` dependency to `4.0.0-rc.1`. [#223]: https://github.com/actix/actix-extras/pull/223 - ## 0.4.0-beta.8 - 2022-01-21 + - No significant changes since `0.4.0-beta.7`. - ## 0.4.0-beta.7 - 2021-12-29 + - Update `actix-web` dependency to `4.0.0.beta-18`. [#218] - Minimum supported Rust version (MSRV) is now 1.54. [#218]: https://github.com/actix/actix-extras/pull/218 - ## 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] [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.4.0-beta.4 - 2021-11-22 + - No significant changes since `0.4.0-beta.3`. - ## 0.4.0-beta.3 - 2021-10-21 + - Update `actix-web` dependency to v4.0.0-beta.10. [#203] - Minimum supported Rust version (MSRV) is now 1.52. [#203]: https://github.com/actix/actix-extras/pull/203 - ## 0.4.0-beta.2 - 2021-06-27 + - No notable changes. - ## 0.4.0-beta.1 - 2021-04-02 + - Rename `CookieIdentityPolicy::{max_age => max_age_secs}`. [#168] - Rename `CookieIdentityPolicy::{max_age_time => max_age}`. [#168] - Update `actix-web` dependency to 4.0.0 beta. @@ -109,31 +110,31 @@ Changes: [#168]: https://github.com/actix/actix-extras/pull/168 - ## 0.3.1 - 2020-09-20 + - Add method to set `HttpOnly` flag on cookie identity. [#102] [#102]: https://github.com/actix/actix-extras/pull/102 - ## 0.3.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimum supported Rust version (MSRV) is now 1.42.0. - ## 0.3.0-alpha.1 - 2020-03-14 + - Update the `time` dependency to 0.2.7 - Update the `actix-web` dependency to 3.0.0-alpha.1 - Minimize `futures` dependency - ## 0.2.1 - 2020-01-10 + - Fix panic with already borrowed: BorrowMutError #1263 - ## 0.2.0 - 2019-12-20 + - Use actix-web 2.0 - ## 0.1.0 - 2019-06-xx + - Move identity middleware to separate crate diff --git a/actix-limitation/CHANGES.md b/actix-limitation/CHANGES.md index 6fc0a163f..3b8ad8458 100644 --- a/actix-limitation/CHANGES.md +++ b/actix-limitation/CHANGES.md @@ -2,28 +2,28 @@ ## Unreleased - 2022-xx-xx - ## 0.4.0 - 2022-09-10 + - Add `Builder::key_by` for setting a custom rate limit key function. - Implement `Default` for `RateLimiter`. - `RateLimiter` is marked `#[non_exhaustive]`; use `RateLimiter::default()` instead. - In the middleware errors from the count function are matched and respond with `INTERNAL_SERVER_ERROR` if it's an unexpected error, instead of the default `TOO_MANY_REQUESTS`. - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. - ## 0.3.0 - 2022-07-11 + - `Limiter::builder` now takes an `impl Into`. - Removed lifetime from `Builder`. - Updated `actix-session` dependency to `0.7`. - ## 0.2.0 - 2022-03-22 + - Update Actix Web dependency to v4 ecosystem. - Update Tokio dependencies to v1 ecosystem. - Rename `Limiter::{build => builder}()`. - Rename `Builder::{finish => build}()`. - Exceeding the rate limit now returns a 429 Too Many Requests response. - ## 0.1.4 - 2022-03-18 + - Adopted into @actix org from . diff --git a/actix-protobuf/CHANGES.md b/actix-protobuf/CHANGES.md index ea75f097c..b8549593a 100644 --- a/actix-protobuf/CHANGES.md +++ b/actix-protobuf/CHANGES.md @@ -1,39 +1,40 @@ # Changes ## Unreleased - 2022-xx-xx + - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. - ## 0.9.0 - 2022-08-24 + - Added `application/x-protobuf` as an acceptable header. - Updated `prost` dependency to `0.11`. - ## 0.8.0 - 2022-06-25 + - Update `prost` dependency to `0.10`. - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. - ## 0.7.0 - 2022-03-01 + - Update `actix-web` dependency to `4`. - ## 0.7.0-beta.5 - 2022-02-03 + - Update `prost` dependency to `0.9`. - Update `actix-web` dependency to `4.0.0-rc.1`. - ## 0.7.0-beta.4 - 2021-12-29 + - Minimum supported Rust version (MSRV) is now 1.54. - ## 0.7.0-beta.3 - 2021-12-12 + - Update `actix-web` dependency to `4.0.0.beta-14`. [#209] [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.7.0-beta.2 - 2021-10-21 + - Bump `prost` version to 0.8. [#197] - Update `actix-web` dependency to v4.0.0-beta.10. [#203] - Minimum supported Rust version (MSRV) is now 1.52. @@ -41,52 +42,52 @@ [#197]: https://github.com/actix/actix-extras/pull/197 [#203]: https://github.com/actix/actix-extras/pull/203 - ## 0.7.0-beta.1 - 2021-06-27 + - Bump `prost` version to 0.7. [#144] - Update `actix-web` dependency to 4.0.0 beta. - Minimum supported Rust version (MSRV) is now 1.46.0. [#144]: https://github.com/actix/actix-extras/pull/144 - ## 0.6.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimum supported Rust version (MSRV) is now 1.42.0 to use `matches!` macro. - ## 0.6.0-alpha.1 - 2020-07-06 + - Update `actix-web` to 3.0.0-alpha.3 - Minimum supported Rust version(MSRV) is now 1.40.0. - Minimize `futures` dependency - ## 0.5.1 - 2019-02-17 + - Move repository to actix-extras - ## 0.5.0 - 2019-01-24 + - Migrate to actix-web 2.0.0 and std::future - Update prost to 0.6 - Update bytes to 0.5 - ## 0.4.1 - 2019-10-03 + - Upgrade prost and prost-derive to 0.5.0 - ## 0.4.0 - 2019-05-18 + - Upgrade to actix-web 1.0.0-rc - Removed `protobuf` method for `HttpRequest` (use `ProtoBuf` extractor instead) - ## 0.3.0 - 2019-03-07 + - Upgrade to actix-web 0.7.18 - ## 0.2.0 - 2018-04-10 + - Provide protobuf extractor - ## 0.1.0 - 2018-03-21 + - First release diff --git a/actix-redis/CHANGES.md b/actix-redis/CHANGES.md index 5b3e84599..6ef8aac47 100644 --- a/actix-redis/CHANGES.md +++ b/actix-redis/CHANGES.md @@ -1,83 +1,86 @@ # Changes ## Unreleased - 2022-xx-xx + - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. - ## 0.12.0 - 2022-07-09 + - Update `actix` dependency to `0.13`. - Update `redis-async` dependency to `0.13`. - Update `tokio-util` dependency to `0.7`. - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. - ## 0.11.0 - 2022-03-15 + ### Removed + - `RedisSession` has been removed. Check out `RedisActorSessionStore` in `actix-session` for a session store backed by Redis using `actix-redis`. [#212] ### Changed + - Update `redis-async` dependency to `0.12`. [#212] [#212]: https://github.com/actix/actix-extras/pull/212 - ## 0.10.0 - 2022-03-01 + - Update `actix-web` dependency to `4`. - ## 0.10.0-beta.6 - 2022-02-07 + - Update `actix-web` dependency to `4.0.0-rc.1`. - ## 0.10.0-beta.5 - 2021-12-29 + - Update `actix-web` dependency to `4.0.0.beta-18`. [#218] - Minimum supported Rust version (MSRV) is now 1.54. [#218]: https://github.com/actix/actix-extras/pull/218 - ## 0.10.0-beta.4 - 2021-12-12 + - A session will be created in Redis if and only if there is some data inside the session state. This reduces the performance impact of `RedisSession` on routes that do not leverage sessions. [#207] - Update `actix-web` dependency to `4.0.0.beta-14`. [#209] [#207]: https://github.com/actix/actix-extras/pull/207 [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.10.0-beta.3 - 2021-10-21 + - Update `actix-web` dependency to v4.0.0-beta.10. [#203] - Minimum supported Rust version (MSRV) is now 1.52. [#203]: https://github.com/actix/actix-extras/pull/203 - ## 0.10.0-beta.2 - 2021-06-27 + - No notable changes. - ## 0.10.0-beta.1 - 2021-04-02 + - Update `actix-web` dependency to 4.0.0 beta. - Minimum supported Rust version (MSRV) is now 1.46.0. - ## 0.9.2 - 2021-03-21 + - Implement `std::error::Error` for `Error` [#135] - Allow the removal of `Max-Age` for session-only cookies. [#161] [#135]: https://github.com/actix/actix-extras/pull/135 [#161]: https://github.com/actix/actix-extras/pull/161 - ## 0.9.1 - 2020-09-12 + - Enforce minimum redis-async version of 0.6.3 to workaround breaking patch change. - ## 0.9.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimize `futures` dependency. - ## 0.9.0-alpha.2 - 2020-05-17 + - Add `cookie_http_only` functionality to RedisSession builder, setting this to false allows JavaScript to access cookies. Defaults to true. - Change type of parameter of ttl method to u32. @@ -85,69 +88,69 @@ - Update `tokio-util` to 0.3 - Minimum supported Rust version(MSRV) is now 1.40.0. - ## 0.9.0-alpha.1 - 2020-03-28 + - Update `actix` to 0.10.0-alpha.2 - Update `actix-session` to 0.4.0-alpha.1 - Update `actix-web` to 3.0.0-alpha.1 - Update `time` to 0.2.9 - ## 0.8.1 - 2020-02-18 + - Move `env_logger` dependency to dev-dependencies and update to 0.7 - Update `actix_web` to 2.0.0 from 2.0.0-rc - Move repository to actix-extras - ## 0.8.0 - 2019-12-20 + - Release - ## 0.8.0-alpha.1 - 2019-12-16 + - Migrate to actix 0.9 - ## 0.7.0 - 2019-09-25 + - added cache_keygen functionality to RedisSession builder, enabling support for customizable cache key creation - ## 0.6.1 - 2019-07-19 + - remove ClonableService usage - added comprehensive tests for session workflow - ## 0.6.0 - 2019-07-08 + - actix-web 1.0.0 compatibility - Upgraded logic that evaluates session state, including new SessionStatus field, - and introduced ``session.renew()`` and ``session.purge()`` functionality. - Use ``renew()`` to cycle the session key at successful login. ``renew()`` keeps a + and introduced `session.renew()` and `session.purge()` functionality. + Use `renew()` to cycle the session key at successful login. `renew()` keeps a session's state while replacing the old cookie and session key with new ones. - Use ``purge()`` at logout to invalidate the session cookie and remove the + Use `purge()` at logout to invalidate the session cookie and remove the session's redis cache entry. - ## 0.5.1 - 2018-08-02 + - Use cookie 0.11 - ## 0.5.0 - 2018-07-21 + - Session cookie configuration - Actix/Actix-web 0.7 compatibility - ## 0.4.0 - 2018-05-08 + - Actix web 0.6 compatibility - ## 0.3.0 - 2018-04-10 + - Actix web 0.5 compatibility - ## 0.2.0 - 2018-02-28 + - Use resolver actor from actix - Use actix web 0.5 - ## 0.1.0 - 2018-01-23 + - First release diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 44da7fe39..b7702f9cd 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,24 +1,26 @@ # 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] - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. [#284]: https://github.com/actix/actix-extras/pull/284 - ## 0.7.1 - 2022-07-24 + - Fix interaction between session state changes and renewal. [#265] [#265]: https://github.com/actix/actix-extras/pull/265 - ## 0.7.0 - 2022-07-09 + - Added `TtlExtensionPolicy` enum to support different strategies for extending the TTL attached to the session state. `TtlExtensionPolicy::OnEveryRequest` now allows for long-lived sessions that do not expire if the user remains active. [#233] - `SessionLength` is now called `SessionLifecycle`. [#233] - `SessionLength::Predetermined` is now called `SessionLifecycle::PersistentSession`. [#233] @@ -34,8 +36,8 @@ [#233]: https://github.com/actix/actix-extras/pull/233 - ## 0.6.2 - 2022-03-25 + - Implement `SessionExt` for `GuardContext`. [#234] - `RedisSessionStore` will prevent connection timeouts from causing user-visible errors. [#235] - Do not leak internal implementation details to callers when errors occur. [#236] @@ -44,13 +46,14 @@ [#236]: https://github.com/actix/actix-extras/pull/236 [#235]: https://github.com/actix/actix-extras/pull/235 - ## 0.6.1 - 2022-03-21 + - No significant changes since `0.6.0`. - ## 0.6.0 - 2022-03-15 + ### Added + - `SessionMiddleware`, a middleware to provide support for saving/updating/deleting session state against a pluggable storage backend (see `SessionStore` trait). [#212] - `CookieSessionStore`, a cookie-based backend to store session state. [#212] - `RedisActorSessionStore`, a Redis-based backend to store session state powered by `actix-redis`. [#212] @@ -59,37 +62,39 @@ - Implement `SessionExt` for `ServiceResponse`. [#212] ### Changed + - Rename `UserSession` to `SessionExt`. [#212] ### Removed + - `CookieSession`; replaced with `CookieSessionStore`, a storage backend for `SessionMiddleware`. [#212] - `Session::set_session`; use `Session::insert` to modify the session state. [#212] [#212]: https://github.com/actix/actix-extras/pull/212 - ## 0.5.0 - 2022-03-01 + - Update `actix-web` dependency to `4`. - ## 0.5.0-beta.8 - 2022-02-07 + - Update `actix-web` dependency to `4.0.0-rc.1`. - ## 0.5.0-beta.7 - 2021-12-29 + - Update `actix-web` dependency to `4.0.0.beta-18`. [#218] - Minimum supported Rust version (MSRV) is now 1.54. [#218]: https://github.com/actix/actix-extras/pull/218 - ## 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] - A session will be created in the storage backend if and only if there is some data inside the session state. This reduces the performance impact of `SessionMiddleware` on routes that do not leverage sessions. [#207] @@ -97,12 +102,12 @@ [#207]: https://github.com/actix/actix-extras/pull/207 [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.5.0-beta.4 - 2021-11-22 + - No significant changes since `0.5.0-beta.3`. - ## 0.5.0-beta.3 - 2021-10-21 + - Impl `Clone` for `CookieSession`. [#201] - Update `actix-web` dependency to v4.0.0-beta.10. [#203] - Minimum supported Rust version (MSRV) is now 1.52. @@ -110,12 +115,12 @@ [#201]: https://github.com/actix/actix-extras/pull/201 [#203]: https://github.com/actix/actix-extras/pull/203 - ## 0.5.0-beta.2 - 2021-06-27 + - No notable changes. - ## 0.5.0-beta.1 - 2021-04-02 + - Add `Session::entries`. [#170] - Rename `Session::{set => insert}` to match standard hash map naming. [#170] - Return values from `Session::remove`. [#170] @@ -127,21 +132,21 @@ [#170]: https://github.com/actix/actix-extras/pull/170 - ## 0.4.1 - 2021-03-21 + - `Session::set_session` takes a `IntoIterator` instead of `Iterator`. [#105] - Fix calls to `session.purge()` from paths other than the one specified in the cookie. [#129] [#105]: https://github.com/actix/actix-extras/pull/105 [#129]: https://github.com/actix/actix-extras/pull/129 - ## 0.4.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimum supported Rust version (MSRV) is now 1.42.0. - ## 0.4.0-alpha.1 - 2020-03-14 + - Update the `time` dependency to 0.2.7 - Update the `actix-web` dependency to 3.0.0-alpha.1 - Long lasting auto-prolonged session [#1292] @@ -149,65 +154,65 @@ [#1292]: https://github.com/actix/actix-web/pull/1292 - ## 0.3.0 - 2019-12-20 + - Release - ## 0.3.0-alpha.4 - 2019-12-xx + - Allow access to sessions also from not mutable references to the request - ## 0.3.0-alpha.3 - 2019-12-xx + - Add access to the session from RequestHead for use of session from guard methods - Migrate to `std::future` - Migrate to `actix-web` 2.0 - ## 0.2.0 - 2019-07-08 -- Enhanced ``actix-session`` to facilitate state changes. Use ``Session.renew()`` + +- Enhanced `actix-session` to facilitate state changes. Use `Session.renew()` at successful login to cycle a session (new key/cookie but keeps state). - Use ``Session.purge()`` at logout to invalid a session cookie (and remove + Use `Session.purge()` at logout to invalid a session cookie (and remove from redis cache, if applicable). - ## 0.1.1 - 2019-06-03 + - Fix optional cookie session support - ## 0.1.0 - 2019-05-18 + - Use actix-web 1.0.0-rc - ## 0.1.0-beta.4 - 2019-05-12 + - Use actix-web 1.0.0-beta.4 - ## 0.1.0-beta.2 - 2019-04-28 + - Add helper trait `UserSession` which allows to get session for ServiceRequest and HttpRequest - ## 0.1.0-beta.1 - 2019-04-20 + - Update actix-web to beta.1 - `CookieSession::max_age()` accepts value in seconds - ## 0.1.0-alpha.6 - 2019-04-14 + - Update actix-web alpha.6 - ## 0.1.0-alpha.4 - 2019-04-08 -- Update actix-web +- Update actix-web ## 0.1.0-alpha.3 - 2019-04-02 + - Update actix-web - ## 0.1.0-alpha.2 - 2019-03-29 + - Update actix-web - Use new feature name for secure cookies - ## 0.1.0-alpha.1 - 2019-03-28 + - Initial impl diff --git a/actix-web-httpauth/CHANGES.md b/actix-web-httpauth/CHANGES.md index 56b69d72e..9c8885118 100644 --- a/actix-web-httpauth/CHANGES.md +++ b/actix-web-httpauth/CHANGES.md @@ -1,10 +1,11 @@ # Changes ## Unreleased - 2022-xx-xx + - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. - ## 0.8.0 - 2022-07-21 + - Removed `AuthExtractor` trait; implement `FromRequest` for your custom auth types. [#264] - `BasicAuth::user_id()` now returns `&str`. [#249] - `BasicAuth::password()` now returns `Option<&str>`. [#249] @@ -15,75 +16,75 @@ [#249]: https://github.com/actix/actix-extras/pull/249 [#264]: https://github.com/actix/actix-extras/pull/264 - ## 0.7.0 - 2022-07-19 + - Auth validator functions now need to return `(Error, ServiceRequest)` in error cases. [#260] - Minimum supported Rust version (MSRV) is now 1.57 due to transitive `time` dependency. [#260]: https://github.com/actix/actix-extras/pull/260 - ## 0.6.0 - 2022-03-01 + - Update `actix-web` dependency to `4`. - ## 0.6.0-beta.8 - 2022-02-07 + - Relax body type bounds on middleware impl. [#223] - Update `actix-web` dependency to `4.0.0-rc.1`. [#223]: https://github.com/actix/actix-extras/pull/223 - ## 0.6.0-beta.7 - 2021-12-29 + - Minimum supported Rust version (MSRV) is now 1.54. - ## 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] [#209]: https://github.com/actix/actix-extras/pull/209 - ## 0.6.0-beta.4 - 2021-11-22 + - impl `AuthExtractor` trait for `Option` and `Result`. [#205] [#205]: https://github.com/actix/actix-extras/pull/205 - ## 0.6.0-beta.3 - 2021-10-21 + - Update `actix-web` dependency to v4.0.0-beta.10. [#203] - Minimum supported Rust version (MSRV) is now 1.52. [#203]: https://github.com/actix/actix-extras/pull/203 - ## 0.6.0-beta.2 - 2021-06-27 + - No notable changes. - ## 0.6.0-beta.1 - 2021-04-02 + - Update `actix-web` dependency to 4.0.0 beta. - Minimum supported Rust version (MSRV) is now 1.46.0. - ## 0.5.1 - 2021-03-21 + - Correct error handling when extracting auth details from request. [#128] [#128]: https://github.com/actix/actix-extras/pull/128 - ## 0.5.0 - 2020-09-11 + - Update `actix-web` dependency to 3.0.0. - Minimum supported Rust version (MSRV) is now 1.42.0. - ## 0.4.2 - 2020-07-08 + - Update the `base64` dependency to 0.12 - AuthenticationError's status code is preserved when converting to a ResponseError - Minimize `futures` dependency @@ -91,46 +92,46 @@ [#69]: https://github.com/actix/actix-web-httpauth/pull/69 - ## 0.4.1 - 2020-02-19 + - Move repository to actix-extras - ## 0.4.0 - 2020-01-14 + - Depends on `actix-web = "^2.0"`, `actix-service = "^1.0"`, and `futures = "^0.3"` version now ([#14]) - Depends on `bytes = "^0.5"` and `base64 = "^0.11"` now [#14]: https://github.com/actix/actix-web-httpauth/pull/14 - ## 0.3.2 - 2019-07-19 + - Middleware accepts any `Fn` as a validator function instead of `FnMut` [#11] [#11]: https://github.com/actix/actix-web-httpauth/pull/11 - ## 0.3.1 - 2019-06-09 + - Multiple calls to the middleware would result in panic - ## 0.3.0 - 2019-06-05 + - Crate edition was changed to `2018`, same as `actix-web` - Depends on `actix-web = "^1.0"` version now - `WWWAuthenticate` header struct was renamed into `WwwAuthenticate` - Challenges and extractor configs are now operating with `Cow<'static, str>` types instead of `String` types - ## 0.2.0 - 2019-04-26 + - `actix-web` dependency is used without default features now [#6] - `base64` dependency version was bumped to `0.10` [#6]: https://github.com/actix/actix-web-httpauth/pull/6 - ## 0.1.0 - 2018-09-08 + - Update to `actix-web = "0.7"` version - ## 0.0.4 - 2018-07-01 + - Fix possible panic at `IntoHeaderValue` implementation for `headers::authorization::Basic` - Fix possible panic at `headers::www_authenticate::challenge::bearer::Bearer::to_bytes` call From 779860b664318e4435cbf369be6a3031a64d02da Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:04:16 +0000 Subject: [PATCH 03/26] clippy --- actix-identity/tests/integration/test_app.rs | 3 ++- actix-limitation/tests/tests.rs | 2 +- actix-protobuf/src/lib.rs | 6 +++--- actix-redis/src/lib.rs | 2 +- actix-redis/tests/test_redis.rs | 2 +- actix-session/examples/basic.rs | 4 ++-- actix-session/src/lib.rs | 8 ++++---- actix-session/src/session.rs | 4 ++-- actix-settings/src/error.rs | 15 ++++++--------- actix-settings/src/lib.rs | 2 +- actix-web-httpauth/examples/with-cors.rs | 2 +- .../src/headers/authorization/errors.rs | 2 +- .../www_authenticate/challenge/bearer/mod.rs | 4 ++-- 13 files changed, 27 insertions(+), 29 deletions(-) diff --git a/actix-identity/tests/integration/test_app.rs b/actix-identity/tests/integration/test_app.rs index 9ff493e3f..89ba665ed 100644 --- a/actix-identity/tests/integration/test_app.rs +++ b/actix-identity/tests/integration/test_app.rs @@ -32,7 +32,8 @@ impl TestApp { .listen(listener) .unwrap() .run(); - let _ = actix_web::rt::spawn(server); + + actix_web::rt::spawn(server); let client = reqwest::Client::builder() .cookie_store(true) diff --git a/actix-limitation/tests/tests.rs b/actix-limitation/tests/tests.rs index 07df6eb1a..fa6f1ae1d 100644 --- a/actix-limitation/tests/tests.rs +++ b/actix-limitation/tests/tests.rs @@ -21,7 +21,7 @@ async fn test_limiter_count() -> Result<(), Error> { for i in 0..20 { let status = limiter.count(id.to_string()).await?; - println!("status: {:?}", status); + println!("status: {status:?}"); assert_eq!(20 - status.remaining(), i + 1); } diff --git a/actix-protobuf/src/lib.rs b/actix-protobuf/src/lib.rs index 743a51d56..f2f7e0160 100644 --- a/actix-protobuf/src/lib.rs +++ b/actix-protobuf/src/lib.rs @@ -39,15 +39,15 @@ pub enum ProtoBufPayloadError { ContentType, /// Serialize error - #[display(fmt = "ProtoBuf serialize error: {}", _0)] + #[display(fmt = "ProtoBuf serialize error: {_0}")] Serialize(ProtoBufEncodeError), /// Deserialize error - #[display(fmt = "ProtoBuf deserialize error: {}", _0)] + #[display(fmt = "ProtoBuf deserialize error: {_0}")] Deserialize(ProtoBufDecodeError), /// Payload error - #[display(fmt = "Error that occur during reading payload: {}", _0)] + #[display(fmt = "Error that occur during reading payload: {_0}")] Payload(PayloadError), } diff --git a/actix-redis/src/lib.rs b/actix-redis/src/lib.rs index e7cd980c8..6d0ca7c40 100644 --- a/actix-redis/src/lib.rs +++ b/actix-redis/src/lib.rs @@ -13,7 +13,7 @@ pub use self::redis::{Command, RedisActor}; /// General purpose `actix-redis` error. #[derive(Debug, Display, Error, From)] pub enum Error { - #[display(fmt = "Redis error: {}", _0)] + #[display(fmt = "Redis error: {_0}")] Redis(redis_async::error::Error), /// Receiving message during reconnecting. diff --git a/actix-redis/tests/test_redis.rs b/actix-redis/tests/test_redis.rs index 6ae83f1e1..fa2f88f26 100644 --- a/actix-redis/tests/test_redis.rs +++ b/actix-redis/tests/test_redis.rs @@ -31,7 +31,7 @@ async fn test_redis() { let res = addr.send(Command(resp_array!["GET", "test"])).await; match res { Ok(Ok(resp)) => { - println!("RESP: {:?}", resp); + println!("RESP: {resp:?}"); assert_eq!(resp, RespValue::BulkString((&b"value"[..]).into())); } _ => panic!("Should not happen {:?}", res), diff --git a/actix-session/examples/basic.rs b/actix-session/examples/basic.rs index 3f41c68dc..f1f08ae66 100644 --- a/actix-session/examples/basic.rs +++ b/actix-session/examples/basic.rs @@ -3,11 +3,11 @@ use actix_web::{cookie::Key, middleware, web, App, Error, HttpRequest, HttpServe /// simple handler async fn index(req: HttpRequest, session: Session) -> Result { - println!("{:?}", req); + println!("{req:?}"); // session if let Some(count) = session.get::("counter")? { - println!("SESSION value: {}", count); + println!("SESSION value: {count}"); session.insert("counter", count + 1)?; } else { session.insert("counter", 1)?; diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index 0a8d5587f..6c6615ef6 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -179,7 +179,7 @@ pub mod test_helpers { CookieContentSecurity::Signed, CookieContentSecurity::Private, ] { - println!("Using {:?} as cookie content security policy.", policy); + println!("Using {policy:?} as cookie content security policy."); acceptance_tests::basic_workflow(store_builder.clone(), *policy).await; acceptance_tests::expiration_is_refreshed_on_changes(store_builder.clone(), *policy) .await; @@ -243,7 +243,7 @@ pub mod test_helpers { })) .service(web::resource("/test/").to(|ses: Session| async move { let val: usize = ses.get("counter").unwrap().unwrap(); - format!("counter: {}", val) + format!("counter: {val}") })), ) .await; @@ -710,9 +710,9 @@ pub mod test_helpers { async fn logout(session: Session) -> Result { let id: Option = session.get("user_id")?; - let body = if let Some(x) = id { + let body = if let Some(id) = id { session.purge(); - format!("Logged out: {}", x) + format!("Logged out: {id}") } else { "Could not log out anonymous user".to_owned() }; diff --git a/actix-session/src/session.rs b/actix-session/src/session.rs index 35aaaa3f2..3a056e1ba 100644 --- a/actix-session/src/session.rs +++ b/actix-session/src/session.rs @@ -291,7 +291,7 @@ impl FromRequest for Session { /// Error returned by [`Session::get`]. #[derive(Debug, Display, From)] -#[display(fmt = "{}", _0)] +#[display(fmt = "{_0}")] pub struct SessionGetError(anyhow::Error); impl StdError for SessionGetError { @@ -308,7 +308,7 @@ impl ResponseError for SessionGetError { /// Error returned by [`Session::insert`]. #[derive(Debug, Display, From)] -#[display(fmt = "{}", _0)] +#[display(fmt = "{_0}")] pub struct SessionInsertError(anyhow::Error); impl StdError for SessionInsertError { diff --git a/actix-settings/src/error.rs b/actix-settings/src/error.rs index f3834cf45..f59e355f0 100644 --- a/actix-settings/src/error.rs +++ b/actix-settings/src/error.rs @@ -89,7 +89,7 @@ impl From for io::Error { fn from(err: Error) -> Self { match err { Error::EnvVarError(var_error) => { - let msg = format!("Env var error: {}", var_error); + let msg = format!("Env var error: {var_error}"); io::Error::new(io::ErrorKind::InvalidInput, msg) } @@ -105,32 +105,29 @@ impl From for io::Error { line, column, } => { - let msg = format!( - "Expected {}, got {} (@ {}:{}:{})", - expected, got, file, line, column - ); + let msg = format!("Expected {expected}, got {got} (@ {file}:{line}:{column})"); io::Error::new(io::ErrorKind::InvalidInput, msg) } Error::IoError(io_error) => io_error.into(), Error::ParseBoolError(parse_bool_error) => { - let msg = format!("Failed to parse boolean: {}", parse_bool_error); + let msg = format!("Failed to parse boolean: {parse_bool_error}"); io::Error::new(io::ErrorKind::InvalidInput, msg) } Error::ParseIntError(parse_int_error) => { - let msg = format!("Failed to parse integer: {}", parse_int_error); + let msg = format!("Failed to parse integer: {parse_int_error}"); io::Error::new(io::ErrorKind::InvalidInput, msg) } Error::ParseAddressError(string) => { - let msg = format!("Failed to parse address: {}", string); + let msg = format!("Failed to parse address: {string}"); io::Error::new(io::ErrorKind::InvalidInput, msg) } Error::TomlError(toml_error) => { - let msg = format!("TOML error: {}", toml_error); + let msg = format!("TOML error: {toml_error}"); io::Error::new(io::ErrorKind::InvalidInput, msg) } } diff --git a/actix-settings/src/lib.rs b/actix-settings/src/lib.rs index 8383dc015..a0d0e3024 100644 --- a/actix-settings/src/lib.rs +++ b/actix-settings/src/lib.rs @@ -274,7 +274,7 @@ where todo!("[ApplySettings] TLS support has not been implemented yet."); } else { for Address { host, port } in &settings.actix.hosts { - self = self.bind(format!("{}:{}", host, port)) + self = self.bind(format!("{host}:{port}")) .unwrap(/*TODO*/); } } diff --git a/actix-web-httpauth/examples/with-cors.rs b/actix-web-httpauth/examples/with-cors.rs index 4f034a295..a5e37d881 100644 --- a/actix-web-httpauth/examples/with-cors.rs +++ b/actix-web-httpauth/examples/with-cors.rs @@ -6,7 +6,7 @@ async fn ok_validator( req: ServiceRequest, credentials: BearerAuth, ) -> Result { - eprintln!("{:?}", credentials); + eprintln!("{credentials:?}"); Ok(req) } diff --git a/actix-web-httpauth/src/headers/authorization/errors.rs b/actix-web-httpauth/src/headers/authorization/errors.rs index a203f6312..465156897 100644 --- a/actix-web-httpauth/src/headers/authorization/errors.rs +++ b/actix-web-httpauth/src/headers/authorization/errors.rs @@ -32,7 +32,7 @@ impl fmt::Display for ParseError { match self { ParseError::Invalid => f.write_str("Invalid header value"), ParseError::MissingScheme => f.write_str("Missing authorization scheme"), - ParseError::MissingField(field) => write!(f, "Missing header field ({})", field), + ParseError::MissingField(field) => write!(f, "Missing header field ({field})"), ParseError::ToStrError(err) => fmt::Display::fmt(err, f), ParseError::Base64DecodeError(err) => fmt::Display::fmt(err, f), ParseError::Utf8Error(err) => fmt::Display::fmt(err, f), diff --git a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs index f957dedc4..8c180b151 100644 --- a/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs +++ b/actix-web-httpauth/src/headers/www_authenticate/challenge/bearer/mod.rs @@ -12,14 +12,14 @@ mod tests { #[test] fn to_bytes() { - let b = Bearer::build() + let bearer = Bearer::build() .error(Error::InvalidToken) .error_description("Subject 8740827c-2e0a-447b-9716-d73042e4039d not found") .finish(); assert_eq!( "Bearer error=\"invalid_token\" error_description=\"Subject 8740827c-2e0a-447b-9716-d73042e4039d not found\"", - format!("{}", b) + format!("{bearer}") ); } } From e9428ba261f3ed6098d829c825be6b483a6bc533 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:08:01 +0000 Subject: [PATCH 04/26] update env_logger dev dep --- actix-cors/Cargo.toml | 4 ++-- actix-identity/Cargo.toml | 3 +-- actix-limitation/Cargo.toml | 2 +- actix-protobuf/Cargo.toml | 2 +- actix-redis/Cargo.toml | 4 ++-- actix-session/Cargo.toml | 4 ++-- actix-settings/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 48ab1671a..5b84ac017 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -23,7 +23,7 @@ draft-private-network-access = [] actix-utils = "3" actix-web = { version = "4", default-features = false } -derive_more = "0.99.5" +derive_more = "0.99.7" futures-util = { version = "0.3.7", default-features = false } log = "0.4" once_cell = "1" @@ -31,5 +31,5 @@ smallvec = "1.6.1" [dev-dependencies] actix-web = { version = "4", default_features = false, features = ["macros"] } -env_logger = "0.9" +env_logger = "0.10" regex = "1.4" diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 54994dd63..468159170 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -22,7 +22,6 @@ actix-session = "0.7" actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } -anyhow = "1" futures-core = "0.3.7" serde = { version = "1", features = ["derive"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } @@ -32,6 +31,6 @@ actix-http = "3" actix-web = { version = "4", default_features = false, features = ["macros", "cookies", "secure-cookies"] } actix-session = { version = "0.7", features = ["redis-rs-session", "cookie-session"] } -env_logger = "0.9" +env_logger = "0.10" reqwest = { version = "0.11", default_features = false, features = ["cookies", "json"] } uuid = { version = "1", features = ["v4"] } diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index c838b0fae..7bdc460b8 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -21,7 +21,7 @@ actix-utils = "3" actix-web = { version = "4", features = ["cookies"] } chrono = "0.4" -derive_more = "0.99.5" +derive_more = "0.99.7" log = "0.4" redis = { version = "0.21", default-features = false, features = ["tokio-comp"] } time = "0.3" diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index e87dec1df..b7ea4f31c 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -18,7 +18,7 @@ path = "src/lib.rs" [dependencies] actix-web = { version = "4", default_features = false } -derive_more = "0.99.5" +derive_more = "0.99.7" futures-util = { version = "0.3.7", default-features = false } prost = { version = "0.11", default_features = false } diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 0128f50ad..9780eb3c1 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -32,7 +32,7 @@ actix-tls = { version = "3", default-features = false, features = ["connect"] } log = "0.4.6" backoff = "0.4.0" -derive_more = "0.99.5" +derive_more = "0.99.7" futures-core = { version = "0.3.7", default-features = false } redis-async = "0.13" time = "0.3" @@ -43,5 +43,5 @@ actix-web = { version = "4", default_features = false, optional = true } [dev-dependencies] actix-test = "0.1.0-beta.12" actix-web = { version = "4", default_features = false, features = ["macros"] } -env_logger = "0.9" +env_logger = "0.10" serde = { version = "1.0.101", features = ["derive"] } diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index f016d511f..d5c8b79a4 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -34,7 +34,7 @@ actix-web = { version = "4", default_features = false, features = ["cookies", "s anyhow = "1" async-trait = "0.1" -derive_more = "0.99.5" +derive_more = "0.99.7" rand = { version = "0.8", optional = true } serde = { version = "1" } serde_json = { version = "1" } @@ -52,7 +52,7 @@ redis = { version = "0.21", default-features = false, features = ["aio", "tokio- actix-session = { path = ".", features = ["cookie-session", "redis-actor-session", "redis-rs-session"] } actix-test = "0.1.0-beta.10" actix-web = { version = "4", default_features = false, features = ["cookies", "secure-cookies", "macros"] } -env_logger = "0.9" +env_logger = "0.10" log = "0.4" [[example]] diff --git a/actix-settings/Cargo.toml b/actix-settings/Cargo.toml index 092c2bb0f..477fab353 100644 --- a/actix-settings/Cargo.toml +++ b/actix-settings/Cargo.toml @@ -21,4 +21,4 @@ serde = { version = "1", features = ["derive"] } toml = "0.5" [dev-dependencies] -env_logger = "0.9" +env_logger = "0.10" From 1036f54fd08dc39e01ef251e380d0fad1bd34549 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:09:34 +0000 Subject: [PATCH 05/26] update redis-async to 0.14 --- actix-redis/CHANGES.md | 1 + actix-redis/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/actix-redis/CHANGES.md b/actix-redis/CHANGES.md index 6ef8aac47..1d87755a5 100644 --- a/actix-redis/CHANGES.md +++ b/actix-redis/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased - 2022-xx-xx +- Update `redis-async` dependency to `0.14`. - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. ## 0.12.0 - 2022-07-09 diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 9780eb3c1..6d35b3b2d 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -34,7 +34,7 @@ log = "0.4.6" backoff = "0.4.0" derive_more = "0.99.7" futures-core = { version = "0.3.7", default-features = false } -redis-async = "0.13" +redis-async = "0.14" time = "0.3" tokio = { version = "1.13.1", features = ["sync"] } tokio-util = "0.7" From fe4d3d366d1ee82f30f2d0126999e81b888d7b0b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:15:26 +0000 Subject: [PATCH 06/26] Update redis dependency to 0.22 --- actix-limitation/CHANGES.md | 2 ++ actix-limitation/Cargo.toml | 2 +- actix-session/CHANGES.md | 1 + actix-session/Cargo.toml | 2 +- actix-session/examples/authentication.rs | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actix-limitation/CHANGES.md b/actix-limitation/CHANGES.md index 3b8ad8458..2a8889744 100644 --- a/actix-limitation/CHANGES.md +++ b/actix-limitation/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased - 2022-xx-xx +- Update `redis` dependency to `0.22`. + ## 0.4.0 - 2022-09-10 - Add `Builder::key_by` for setting a custom rate limit key function. diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index 7bdc460b8..44199f38f 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -23,7 +23,7 @@ actix-web = { version = "4", features = ["cookies"] } chrono = "0.4" derive_more = "0.99.7" log = "0.4" -redis = { version = "0.21", default-features = false, features = ["tokio-comp"] } +redis = { version = "0.22", default-features = false, features = ["tokio-comp"] } time = "0.3" # session diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index b7702f9cd..1973c33c7 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - 2021-xx-xx - Set secure attribute when adding a session removal cookie. [#300] +- Update `redis` dependency to `0.22`. [#300]: https://github.com/actix/actix-extras/pull/300 diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index d5c8b79a4..e02d15e26 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -46,7 +46,7 @@ actix-redis = { version = "0.12", optional = true } futures-core = { version = "0.3.7", default-features = false, optional = true } # redis-rs-session -redis = { version = "0.21", default-features = false, features = ["aio", "tokio-comp", "connection-manager"], optional = true } +redis = { version = "0.22", default-features = false, features = ["tokio-comp", "connection-manager"], optional = true } [dev-dependencies] actix-session = { path = ".", features = ["cookie-session", "redis-actor-session", "redis-rs-session"] } diff --git a/actix-session/examples/authentication.rs b/actix-session/examples/authentication.rs index 0dc2274b5..400971051 100644 --- a/actix-session/examples/authentication.rs +++ b/actix-session/examples/authentication.rs @@ -21,7 +21,7 @@ struct User { impl User { fn authenticate(credentials: Credentials) -> Result { - // TODO: figure out why I keep getting hacked + // to do: figure out why I keep getting hacked /s if &credentials.password != "hunter2" { return Err(HttpResponse::Unauthorized().json("Unauthorized")); } From d9175a0399f8e2f3e8d837bd640b74f5d096dae7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:16:14 +0000 Subject: [PATCH 07/26] update base64 dep to 0.20 --- actix-web-httpauth/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index 933b9ce0d..513f5d727 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -21,7 +21,7 @@ path = "src/lib.rs" actix-utils = "3" actix-web = { version = "4.1", default_features = false } -base64 = "0.13" +base64 = "0.20" futures-core = "0.3.7" futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" From f8a1165d10945fe1a5e787abc1de7810ffda2b51 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:17:45 +0000 Subject: [PATCH 08/26] fix manifest --- actix-identity/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 468159170..09212b69c 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -22,6 +22,7 @@ actix-session = "0.7" actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } +anyhow = "1" futures-core = "0.3.7" serde = { version = "1", features = ["derive"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } From 9be4f1ff73ced3ea4cb6a5e6a505d40717dbd93f Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:38:07 +0000 Subject: [PATCH 09/26] workaround dev dep msrv issues --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed53e46a8..92a0ac80c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,6 +95,16 @@ jobs: - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack + - name: workaround MSRV issues + if: matrix.version != 'stable' + run: | + cargo install cargo-edit --version=0.8.0 + cargo add env_logger@0.9 --dev -p=actix-cors + cargo add env_logger@0.9 --dev -p=actix-identity + cargo add env_logger@0.9 --dev -p=actix-redis + cargo add env_logger@0.9 --dev -p=actix-session + cargo add env_logger@0.9 --dev -p=actix-settings + - name: Generate Cargo.lock run: cargo generate-lockfile - name: Cache Dependencies From 708aa945dce4539de0113da4db8acdff018fbc0a Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 01:57:03 +0000 Subject: [PATCH 10/26] workaround msrv issues fix --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92a0ac80c..fb33a2e90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,16 @@ jobs: - name: Install cargo-hack uses: taiki-e/install-action@cargo-hack + - name: workaround MSRV issues + if: matrix.version != 'stable' + run: | + cargo install cargo-edit --version=0.8.0 + cargo add env_logger@0.9 --dev -p=actix-cors + cargo add env_logger@0.9 --dev -p=actix-identity + cargo add env_logger@0.9 --dev -p=actix-redis + cargo add env_logger@0.9 --dev -p=actix-session + cargo add env_logger@0.9 --dev -p=actix-settings + - name: Generate Cargo.lock run: cargo generate-lockfile - name: Cache Dependencies From 1ed893a08c70dc14280eb3d0d5d45f073dc7aa15 Mon Sep 17 00:00:00 2001 From: Joseph McCormick Date: Fri, 6 Jan 2023 20:05:12 -0600 Subject: [PATCH 11/26] Feature: Add IdentityError to actix-identity crate. (#296) * Add IdentityError to actix-identity crate. In order to let crates in the actix web ecosystem interact correctly with `actix_web::Error`, this commit introduces its own error type, replacing the previous usage of `anyhow::Error`. * Mend some clippy warnings on IdentityError. * Split identity error into more granular versions. - `MissingIdentityError` occurs whenever we attempt to gather information about an identity from a session, and fail. - `LoginError` occurs whenever we attempt to login via an identity, and fail. * Feedback for identity error implementation. - `IdentityError` -> `GetIdentityError` - Move error messages into Display impl where appropriate - Split `id` and `get_identity` errors into two types - Implement `source` on custom errors * Expand identity error types with struct markers. In order to get a little more future compatibility and reduce abstraction leaking, this commit introduces some contextual structs to our identity errors package. * Improve doc message for SessionExpiryError. Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> * Improve identity error docs and messaging. Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> * Expand LostIdentityError with placeholder. Adds a placeholder unit struct to the LostIdentityError variant of GetIdentityError, which should let us expand on that variant with extra context later if we like. * Add From coercion for LostIdentityError. Improve the ergonomics of using the LostIdentityError unit struct. * Update Cargo.toml * Update CHANGES.md * expose identity error module * fix error impl Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Co-authored-by: Rob Ede --- actix-identity/CHANGES.md | 3 + actix-identity/Cargo.toml | 1 - actix-identity/src/error.rs | 156 +++++++++++++++++++++++++++++ actix-identity/src/identity.rs | 46 ++++----- actix-identity/src/identity_ext.rs | 10 +- actix-identity/src/lib.rs | 1 + 6 files changed, 188 insertions(+), 29 deletions(-) create mode 100644 actix-identity/src/error.rs diff --git a/actix-identity/CHANGES.md b/actix-identity/CHANGES.md index 1f7c9538d..a3706f37c 100644 --- a/actix-identity/CHANGES.md +++ b/actix-identity/CHANGES.md @@ -2,8 +2,11 @@ ## Unreleased - 2022-xx-xx +- Replace use of `anyhow::Error` with specific error types. [#296] - Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +[#296]: https://github.com/actix/actix-extras/pull/296 + ## 0.5.2 - 2022-07-19 - Fix visit deadline. [#263] diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 09212b69c..468159170 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -22,7 +22,6 @@ actix-session = "0.7" actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } -anyhow = "1" futures-core = "0.3.7" serde = { version = "1", features = ["derive"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } diff --git a/actix-identity/src/error.rs b/actix-identity/src/error.rs new file mode 100644 index 000000000..b701db900 --- /dev/null +++ b/actix-identity/src/error.rs @@ -0,0 +1,156 @@ +//! Failure modes of identity operations. + +use std::fmt; + +use actix_session::{SessionGetError, SessionInsertError}; +use actix_web::{cookie::time::error::ComponentRange, http::StatusCode, ResponseError}; + +/// Error that can occur during login attempts. +#[derive(Debug)] +pub struct LoginError(SessionInsertError); + +impl fmt::Display for LoginError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for LoginError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(&self.0) + } +} + +impl ResponseError for LoginError { + fn status_code(&self) -> StatusCode { + StatusCode::UNAUTHORIZED + } +} + +impl From for LoginError { + fn from(error: SessionInsertError) -> Self { + Self(error) + } +} + +/// Error encountered when working with a session that has expired. +#[derive(Debug)] +pub struct SessionExpiryError(ComponentRange); + +impl fmt::Display for SessionExpiryError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("The given session has expired and is no longer valid") + } +} + +impl std::error::Error for SessionExpiryError {} + +/// The identity information has been lost. +/// +/// Seeing this error in user code indicates a bug in actix-identity. +#[derive(Debug)] +#[non_exhaustive] +pub struct LostIdentityError; + +impl fmt::Display for LostIdentityError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str( + "The identity information in the current session has disappeared \ + after having been successfully validated. This is likely to be a bug.", + ) + } +} + +impl std::error::Error for LostIdentityError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(self) + } +} + +/// There is no identity information attached to the current session. +#[derive(Debug)] +#[non_exhaustive] +pub struct MissingIdentityError; + +impl fmt::Display for MissingIdentityError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("There is no identity information attached to the current session.") + } +} + +impl std::error::Error for MissingIdentityError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(self) + } +} + +/// Errors that can occur while retrieving an identity. +#[derive(Debug)] +#[non_exhaustive] +pub enum GetIdentityError { + /// The session has expired. + SessionExpiryError(SessionExpiryError), + + /// No identity is found in a session. + MissingIdentityError(MissingIdentityError), + + /// Failed to accessing the session store. + SessionGetError(SessionGetError), + + /// Identity info was lost after being validated. + /// + /// Seeing this error indicates a bug in actix-identity. + LostIdentityError(LostIdentityError), +} + +impl fmt::Display for GetIdentityError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::SessionExpiryError(err) => write!(f, "{err}"), + Self::MissingIdentityError(err) => write!(f, "{err}"), + Self::SessionGetError(err) => write!(f, "{err}"), + Self::LostIdentityError(err) => write!(f, "{err}"), + } + } +} + +impl std::error::Error for GetIdentityError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Self::SessionExpiryError(err) => Some(err), + Self::MissingIdentityError(err) => Some(err), + Self::SessionGetError(err) => Some(err), + Self::LostIdentityError(err) => Some(err), + } + } +} + +impl ResponseError for GetIdentityError { + fn status_code(&self) -> StatusCode { + StatusCode::UNAUTHORIZED + } +} + +impl From for GetIdentityError { + fn from(error: LostIdentityError) -> Self { + Self::LostIdentityError(error) + } +} + +impl From for GetIdentityError { + fn from(error: MissingIdentityError) -> Self { + Self::MissingIdentityError(error) + } +} + +impl From for GetIdentityError { + fn from(error: ComponentRange) -> Self { + Self::SessionExpiryError(SessionExpiryError(error)) + } +} + +impl From for GetIdentityError { + fn from(source: SessionGetError) -> Self { + Self::SessionGetError(source) + } +} diff --git a/actix-identity/src/identity.rs b/actix-identity/src/identity.rs index 0b6342736..a991e646f 100644 --- a/actix-identity/src/identity.rs +++ b/actix-identity/src/identity.rs @@ -6,9 +6,11 @@ use actix_web::{ http::StatusCode, Error, FromRequest, HttpMessage, HttpRequest, HttpResponse, }; -use anyhow::{anyhow, Context}; -use crate::config::LogoutBehaviour; +use crate::{ + config::LogoutBehaviour, + error::{GetIdentityError, LoginError, LostIdentityError, MissingIdentityError}, +}; /// A verified user identity. It can be used as a request extractor. /// @@ -95,13 +97,10 @@ impl IdentityInner { } /// Retrieve the user id attached to the current session. - fn get_identity(&self) -> Result { + fn get_identity(&self) -> Result { self.session - .get::(ID_KEY) - .context("Failed to deserialize the user identifier attached to the current session")? - .ok_or_else(|| { - anyhow!("There is no identity information attached to the current session") - }) + .get::(ID_KEY)? + .ok_or_else(|| MissingIdentityError.into()) } } @@ -126,10 +125,11 @@ impl Identity { /// } /// } /// ``` - pub fn id(&self) -> Result { - self.0.session.get(ID_KEY)?.ok_or_else(|| { - anyhow!("Bug: the identity information attached to the current session has disappeared") - }) + pub fn id(&self) -> Result { + self.0 + .session + .get(ID_KEY)? + .ok_or_else(|| LostIdentityError.into()) } /// Attach a valid user identity to the current session. @@ -149,7 +149,7 @@ impl Identity { /// HttpResponse::Ok() /// } /// ``` - pub fn login(ext: &Extensions, id: String) -> Result { + pub fn login(ext: &Extensions, id: String) -> Result { let inner = IdentityInner::extract(ext); inner.session.insert(ID_KEY, id)?; let now = OffsetDateTime::now_utc().unix_timestamp(); @@ -200,31 +200,31 @@ impl Identity { } } - pub(crate) fn extract(ext: &Extensions) -> Result { + pub(crate) fn extract(ext: &Extensions) -> Result { let inner = IdentityInner::extract(ext); inner.get_identity()?; Ok(Self(inner)) } - pub(crate) fn logged_at(&self) -> Result, anyhow::Error> { - self.0 + pub(crate) fn logged_at(&self) -> Result, GetIdentityError> { + Ok(self + .0 .session .get(LOGIN_UNIX_TIMESTAMP_KEY)? .map(OffsetDateTime::from_unix_timestamp) - .transpose() - .map_err(anyhow::Error::from) + .transpose()?) } - pub(crate) fn last_visited_at(&self) -> Result, anyhow::Error> { - self.0 + pub(crate) fn last_visited_at(&self) -> Result, GetIdentityError> { + Ok(self + .0 .session .get(LAST_VISIT_UNIX_TIMESTAMP_KEY)? .map(OffsetDateTime::from_unix_timestamp) - .transpose() - .map_err(anyhow::Error::from) + .transpose()?) } - pub(crate) fn set_last_visited_at(&self) -> Result<(), anyhow::Error> { + pub(crate) fn set_last_visited_at(&self) -> Result<(), LoginError> { let now = OffsetDateTime::now_utc().unix_timestamp(); self.0.session.insert(LAST_VISIT_UNIX_TIMESTAMP_KEY, now)?; Ok(()) diff --git a/actix-identity/src/identity_ext.rs b/actix-identity/src/identity_ext.rs index 431539a86..8c4bbad69 100644 --- a/actix-identity/src/identity_ext.rs +++ b/actix-identity/src/identity_ext.rs @@ -1,27 +1,27 @@ use actix_web::{dev::ServiceRequest, guard::GuardContext, HttpMessage, HttpRequest}; -use crate::Identity; +use crate::{error::GetIdentityError, Identity}; /// Helper trait to retrieve an [`Identity`] instance from various `actix-web`'s types. pub trait IdentityExt { /// Retrieve the identity attached to the current session, if available. - fn get_identity(&self) -> Result; + fn get_identity(&self) -> Result; } impl IdentityExt for HttpRequest { - fn get_identity(&self) -> Result { + fn get_identity(&self) -> Result { Identity::extract(&self.extensions()) } } impl IdentityExt for ServiceRequest { - fn get_identity(&self) -> Result { + fn get_identity(&self) -> Result { Identity::extract(&self.extensions()) } } impl<'a> IdentityExt for GuardContext<'a> { - fn get_identity(&self) -> Result { + fn get_identity(&self) -> Result { Identity::extract(&self.req_data()) } } diff --git a/actix-identity/src/lib.rs b/actix-identity/src/lib.rs index d2fbfff9a..f88c9ca23 100644 --- a/actix-identity/src/lib.rs +++ b/actix-identity/src/lib.rs @@ -91,6 +91,7 @@ #![warn(future_incompatible)] pub mod config; +pub mod error; mod identity; mod identity_ext; mod middleware; From 441d604c000145e9ecb6e442cce001d21d79f244 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 7 Jan 2023 02:22:13 +0000 Subject: [PATCH 12/26] derive identity error impls --- actix-identity/Cargo.toml | 1 + actix-identity/src/error.rs | 130 ++++++--------------------------- actix-identity/src/identity.rs | 10 ++- 3 files changed, 30 insertions(+), 111 deletions(-) diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 468159170..4afa8659d 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -22,6 +22,7 @@ actix-session = "0.7" actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } +derive_more = "0.99.7" futures-core = "0.3.7" serde = { version = "1", features = ["derive"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } diff --git a/actix-identity/src/error.rs b/actix-identity/src/error.rs index b701db900..2db521f92 100644 --- a/actix-identity/src/error.rs +++ b/actix-identity/src/error.rs @@ -1,156 +1,70 @@ //! Failure modes of identity operations. -use std::fmt; - use actix_session::{SessionGetError, SessionInsertError}; use actix_web::{cookie::time::error::ComponentRange, http::StatusCode, ResponseError}; +use derive_more::{Display, Error, From}; /// Error that can occur during login attempts. -#[derive(Debug)] +#[derive(Debug, Display, Error, From)] +#[display(fmt = "{_0}")] pub struct LoginError(SessionInsertError); -impl fmt::Display for LoginError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -impl std::error::Error for LoginError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(&self.0) - } -} - impl ResponseError for LoginError { fn status_code(&self) -> StatusCode { StatusCode::UNAUTHORIZED } } -impl From for LoginError { - fn from(error: SessionInsertError) -> Self { - Self(error) - } -} - /// Error encountered when working with a session that has expired. -#[derive(Debug)] -pub struct SessionExpiryError(ComponentRange); - -impl fmt::Display for SessionExpiryError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("The given session has expired and is no longer valid") - } -} - -impl std::error::Error for SessionExpiryError {} +#[derive(Debug, Display, Error)] +#[display(fmt = "The given session has expired and is no longer valid")] +pub struct SessionExpiryError(#[error(not(source))] pub(crate) ComponentRange); /// The identity information has been lost. /// /// Seeing this error in user code indicates a bug in actix-identity. -#[derive(Debug)] +#[derive(Debug, Display, Error)] +#[display( + fmt = "The identity information in the current session has disappeared after having been \ + successfully validated. This is likely to be a bug." +)] #[non_exhaustive] pub struct LostIdentityError; -impl fmt::Display for LostIdentityError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str( - "The identity information in the current session has disappeared \ - after having been successfully validated. This is likely to be a bug.", - ) - } -} - -impl std::error::Error for LostIdentityError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(self) - } -} - /// There is no identity information attached to the current session. -#[derive(Debug)] +#[derive(Debug, Display, Error)] +#[display(fmt = "There is no identity information attached to the current session")] #[non_exhaustive] pub struct MissingIdentityError; -impl fmt::Display for MissingIdentityError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("There is no identity information attached to the current session.") - } -} - -impl std::error::Error for MissingIdentityError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(self) - } -} - /// Errors that can occur while retrieving an identity. -#[derive(Debug)] +#[derive(Debug, Display, Error, From)] #[non_exhaustive] pub enum GetIdentityError { /// The session has expired. + #[display(fmt = "{_0}")] SessionExpiryError(SessionExpiryError), /// No identity is found in a session. + #[display(fmt = "{_0}")] MissingIdentityError(MissingIdentityError), /// Failed to accessing the session store. + #[display(fmt = "{_0}")] SessionGetError(SessionGetError), /// Identity info was lost after being validated. /// /// Seeing this error indicates a bug in actix-identity. + #[display(fmt = "{_0}")] LostIdentityError(LostIdentityError), } -impl fmt::Display for GetIdentityError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::SessionExpiryError(err) => write!(f, "{err}"), - Self::MissingIdentityError(err) => write!(f, "{err}"), - Self::SessionGetError(err) => write!(f, "{err}"), - Self::LostIdentityError(err) => write!(f, "{err}"), - } - } -} - -impl std::error::Error for GetIdentityError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::SessionExpiryError(err) => Some(err), - Self::MissingIdentityError(err) => Some(err), - Self::SessionGetError(err) => Some(err), - Self::LostIdentityError(err) => Some(err), - } - } -} - impl ResponseError for GetIdentityError { fn status_code(&self) -> StatusCode { - StatusCode::UNAUTHORIZED - } -} - -impl From for GetIdentityError { - fn from(error: LostIdentityError) -> Self { - Self::LostIdentityError(error) - } -} - -impl From for GetIdentityError { - fn from(error: MissingIdentityError) -> Self { - Self::MissingIdentityError(error) - } -} - -impl From for GetIdentityError { - fn from(error: ComponentRange) -> Self { - Self::SessionExpiryError(SessionExpiryError(error)) - } -} - -impl From for GetIdentityError { - fn from(source: SessionGetError) -> Self { - Self::SessionGetError(source) + match self { + Self::LostIdentityError(_) => StatusCode::INTERNAL_SERVER_ERROR, + _ => StatusCode::UNAUTHORIZED, + } } } diff --git a/actix-identity/src/identity.rs b/actix-identity/src/identity.rs index a991e646f..9a75ede72 100644 --- a/actix-identity/src/identity.rs +++ b/actix-identity/src/identity.rs @@ -9,7 +9,9 @@ use actix_web::{ use crate::{ config::LogoutBehaviour, - error::{GetIdentityError, LoginError, LostIdentityError, MissingIdentityError}, + error::{ + GetIdentityError, LoginError, LostIdentityError, MissingIdentityError, SessionExpiryError, + }, }; /// A verified user identity. It can be used as a request extractor. @@ -212,7 +214,8 @@ impl Identity { .session .get(LOGIN_UNIX_TIMESTAMP_KEY)? .map(OffsetDateTime::from_unix_timestamp) - .transpose()?) + .transpose() + .map_err(SessionExpiryError)?) } pub(crate) fn last_visited_at(&self) -> Result, GetIdentityError> { @@ -221,7 +224,8 @@ impl Identity { .session .get(LAST_VISIT_UNIX_TIMESTAMP_KEY)? .map(OffsetDateTime::from_unix_timestamp) - .transpose()?) + .transpose() + .map_err(SessionExpiryError)?) } pub(crate) fn set_last_visited_at(&self) -> Result<(), LoginError> { From bf49b39740c334e6c75b56d0bbdffda04f6832c3 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 10 Jan 2023 09:03:27 +0000 Subject: [PATCH 13/26] use secure tokio version range see RUSTSEC-2023-0001 part of actix/actix-web#2962 --- actix-redis/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 6d35b3b2d..9fe9422aa 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -36,7 +36,7 @@ derive_more = "0.99.7" futures-core = { version = "0.3.7", default-features = false } redis-async = "0.14" time = "0.3" -tokio = { version = "1.13.1", features = ["sync"] } +tokio = { version = "1.18.4", features = ["sync"] } tokio-util = "0.7" actix-web = { version = "4", default_features = false, optional = true } From 713b157fd42d4f91cb2e556c2a180f175b854e02 Mon Sep 17 00:00:00 2001 From: Jacobtread <33708767+jacobtread@users.noreply.github.com> Date: Fri, 13 Jan 2023 23:43:52 +1300 Subject: [PATCH 14/26] Corrected actix-form-data community crate details (#314) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6004fd153..2222541e1 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ These crates are provided by the community. | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | [actix-web-lab] | [![crates.io](https://img.shields.io/crates/v/actix-web-lab?label=latest)][actix-web-lab] [![dependency status](https://deps.rs/crate/actix-web-lab/0.16.4/status.svg)](https://deps.rs/crate/actix-web-lab/0.16.4) | Experimental extractors, middleware, and other extras for possible inclusion in Actix Web. | | [actix-multipart-extract] | [![crates.io](https://img.shields.io/crates/v/actix-multipart-extract?label=latest)][actix-multipart-extract] [![dependency status](https://deps.rs/crate/actix-multipart-extract/0.1.4/status.svg)](https://deps.rs/crate/actix-multipart-extract/0.1.4) | Better multipart form support for Actix Web. | -| [actix-form-data] | [![crates.io](https://img.shields.io/crates/v/actix-form-data?label=latest)][actix-form-data] [![dependency status](https://deps.rs/crate/actix-form-data/0.6.2/status.svg)](https://deps.rs/crate/actix-form-data/0.6.2) | Rate-limiting backed by form-data. | +| [actix-form-data] | [![crates.io](https://img.shields.io/crates/v/actix-form-data?label=latest)][actix-form-data] [![dependency status](https://deps.rs/crate/actix-form-data/0.6.2/status.svg)](https://deps.rs/crate/actix-form-data/0.6.2) | Multipart form data from actix multipart streams | | [actix-governor] | [![crates.io](https://img.shields.io/crates/v/actix-governor?label=latest)][actix-governor] [![dependency status](https://deps.rs/crate/actix-governor/0.3.0/status.svg)](https://deps.rs/crate/actix-governor/0.3.0) | Rate-limiting backed by governor. | | [actix-casbin] | [![crates.io](https://img.shields.io/crates/v/actix-casbin?label=latest)][actix-casbin] [![dependency status](https://deps.rs/crate/actix-casbin/0.4.2/status.svg)](https://deps.rs/crate/actix-casbin/0.4.2) | Authorization library that supports access control models like ACL, RBAC & ABAC. | | [actix-ip-filter] | [![crates.io](https://img.shields.io/crates/v/actix-ip-filter?label=latest)][actix-ip-filter] [![dependency status](https://deps.rs/crate/actix-ip-filter/0.3.1/status.svg)](https://deps.rs/crate/actix-ip-filter/0.3.1) | IP address filter. Supports glob patterns. | From 2bc16eee18c98e0cc60ea0f9cebb3bbe15356213 Mon Sep 17 00:00:00 2001 From: citreae535 <81646018+citreae535@users.noreply.github.com> Date: Tue, 31 Jan 2023 00:53:30 +0800 Subject: [PATCH 15/26] Update `base64` dependency to 0.21 (#316) --- actix-web-httpauth/Cargo.toml | 2 +- .../src/headers/authorization/scheme/basic.rs | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index 513f5d727..befdce661 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -21,7 +21,7 @@ path = "src/lib.rs" actix-utils = "3" actix-web = { version = "4.1", default_features = false } -base64 = "0.20" +base64 = "0.21" futures-core = "0.3.7" futures-util = { version = "0.3.7", default-features = false, features = ["std"] } log = "0.4" diff --git a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs index da7a94f8b..4e5cbc676 100644 --- a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs +++ b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs @@ -4,6 +4,7 @@ use actix_web::{ http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue}, web::{BufMut, BytesMut}, }; +use base64::{prelude::BASE64_STANDARD, Engine}; use crate::headers::authorization::{errors::ParseError, Scheme}; @@ -58,7 +59,7 @@ impl Scheme for Basic { _ => return Err(ParseError::MissingScheme), } - let decoded = base64::decode(parts.next().ok_or(ParseError::Invalid)?)?; + let decoded = BASE64_STANDARD.decode(parts.next().ok_or(ParseError::Invalid)?)?; let mut credentials = str::from_utf8(&decoded)?.splitn(2, ':'); let user_id = credentials @@ -97,11 +98,13 @@ impl TryIntoHeaderValue for Basic { type Error = InvalidHeaderValue; fn try_into_value(self) -> Result { - let mut credentials = BytesMut::with_capacity( - self.user_id.len() - + 1 // ':' - + self.password.as_ref().map_or(0, |pwd| pwd.len()), - ); + let credential_length = + self.user_id.len() + 1 + self.password.as_ref().map_or(0, |pwd| pwd.len()); + // The length of BASE64 encoded bytes is `4 * credential_length.div_ceil(3)` + // TODO: Use credential_length.div_ceil(3) when `int_roundings` becomes stable + // https://github.com/rust-lang/rust/issues/88581 + let mut value = String::with_capacity(6 + 4 * (credential_length + 2) / 3); + let mut credentials = BytesMut::with_capacity(credential_length); credentials.extend_from_slice(self.user_id.as_bytes()); credentials.put_u8(b':'); @@ -109,14 +112,10 @@ impl TryIntoHeaderValue for Basic { credentials.extend_from_slice(password.as_bytes()); } - // TODO: It would be nice not to allocate new `String` here but write - // directly to `value` - let encoded = base64::encode(&credentials); - let mut value = BytesMut::with_capacity(6 + encoded.len()); - value.put(&b"Basic "[..]); - value.put(encoded.as_bytes()); + value.push_str("Basic "); + BASE64_STANDARD.encode_string(&credentials, &mut value); - HeaderValue::from_maybe_shared(value.freeze()) + HeaderValue::from_maybe_shared(value) } } From 218f18e69d8dbc3df9d5ccf92b6fcc192713494b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 22 Mar 2023 20:51:14 +0000 Subject: [PATCH 16/26] fix default features attributes --- actix-cors/Cargo.toml | 2 +- actix-identity/Cargo.toml | 4 ++-- actix-protobuf/Cargo.toml | 8 ++++---- actix-redis/Cargo.toml | 4 ++-- actix-session/Cargo.toml | 4 ++-- actix-web-httpauth/Cargo.toml | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 5b84ac017..88bb286ad 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -30,6 +30,6 @@ once_cell = "1" smallvec = "1.6.1" [dev-dependencies] -actix-web = { version = "4", default_features = false, features = ["macros"] } +actix-web = { version = "4", default-features = false, features = ["macros"] } env_logger = "0.10" regex = "1.4" diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 4afa8659d..2eb3f0876 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -29,9 +29,9 @@ tracing = { version = "0.1.30", default-features = false, features = ["log"] } [dev-dependencies] actix-http = "3" -actix-web = { version = "4", default_features = false, features = ["macros", "cookies", "secure-cookies"] } +actix-web = { version = "4", default-features = false, features = ["macros", "cookies", "secure-cookies"] } actix-session = { version = "0.7", features = ["redis-rs-session", "cookie-session"] } env_logger = "0.10" -reqwest = { version = "0.11", default_features = false, features = ["cookies", "json"] } +reqwest = { version = "0.11", default-features = false, features = ["cookies", "json"] } uuid = { version = "1", features = ["v4"] } diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index b7ea4f31c..e2e85d08f 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -17,11 +17,11 @@ name = "actix_protobuf" path = "src/lib.rs" [dependencies] -actix-web = { version = "4", default_features = false } +actix-web = { version = "4", default-features = false } derive_more = "0.99.7" futures-util = { version = "0.3.7", default-features = false } -prost = { version = "0.11", default_features = false } +prost = { version = "0.11", default-features = false } [dev-dependencies] -actix-web = { version = "4", default_features = false, features = ["macros"] } -prost = { version = "0.11", default_features = false, features = ["prost-derive"] } +actix-web = { version = "4", default-features = false, features = ["macros"] } +prost = { version = "0.11", default-features = false, features = ["prost-derive"] } diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 9fe9422aa..683179bbb 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -38,10 +38,10 @@ redis-async = "0.14" time = "0.3" tokio = { version = "1.18.4", features = ["sync"] } tokio-util = "0.7" -actix-web = { version = "4", default_features = false, optional = true } +actix-web = { version = "4", default-features = false, optional = true } [dev-dependencies] actix-test = "0.1.0-beta.12" -actix-web = { version = "4", default_features = false, features = ["macros"] } +actix-web = { version = "4", default-features = false, features = ["macros"] } env_logger = "0.10" serde = { version = "1.0.101", features = ["derive"] } diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index e02d15e26..2eda122de 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -30,7 +30,7 @@ redis-rs-tls-session = ["redis-rs-session", "redis/tokio-native-tls-comp"] [dependencies] actix-service = "2" actix-utils = "3" -actix-web = { version = "4", default_features = false, features = ["cookies", "secure-cookies"] } +actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } anyhow = "1" async-trait = "0.1" @@ -51,7 +51,7 @@ redis = { version = "0.22", default-features = false, features = ["tokio-comp", [dev-dependencies] actix-session = { path = ".", features = ["cookie-session", "redis-actor-session", "redis-rs-session"] } actix-test = "0.1.0-beta.10" -actix-web = { version = "4", default_features = false, features = ["cookies", "secure-cookies", "macros"] } +actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies", "macros"] } env_logger = "0.10" log = "0.4" diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index befdce661..95116c09f 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -19,7 +19,7 @@ path = "src/lib.rs" [dependencies] actix-utils = "3" -actix-web = { version = "4.1", default_features = false } +actix-web = { version = "4.1", default-features = false } base64 = "0.21" futures-core = "0.3.7" @@ -30,4 +30,4 @@ pin-project-lite = "0.2.7" [dev-dependencies] actix-cors = "0.6" actix-service = "2" -actix-web = { version = "4.1", default_features = false, features = ["macros"] } +actix-web = { version = "4.1", default-features = false, features = ["macros"] } From 8a9c604c033d824542deba76e54aa4e5a5503c53 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 22 Mar 2023 21:13:56 +0000 Subject: [PATCH 17/26] update msrv to 1.60 promted by prost 0.11.8 --- .github/workflows/ci.yml | 4 ++-- actix-cors/CHANGES.md | 2 ++ actix-identity/CHANGES.md | 2 +- actix-protobuf/CHANGES.md | 2 +- actix-redis/CHANGES.md | 2 +- actix-session/CHANGES.md | 5 ++--- actix-settings/CHANGES.md | 2 +- actix-web-httpauth/CHANGES.md | 2 +- clippy.toml | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb33a2e90..a83b2803d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: target: - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } version: - - 1.59 # MSRV + - 1.60 # MSRV - stable name: ${{ matrix.target.name }} / ${{ matrix.version }} @@ -88,7 +88,7 @@ jobs: triple: x86_64-pc-windows-msvc, } version: - - 1.59 # MSRV + - 1.60 # MSRV - stable name: ${{ matrix.target.name }} / ${{ matrix.version }} diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index ee61c24c4..31a23cb71 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased - 2022-xx-xx +- Minimum supported Rust version (MSRV) is now 1.60. + ## 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-identity/CHANGES.md b/actix-identity/CHANGES.md index a3706f37c..de5f2d15f 100644 --- a/actix-identity/CHANGES.md +++ b/actix-identity/CHANGES.md @@ -3,7 +3,7 @@ ## Unreleased - 2022-xx-xx - Replace use of `anyhow::Error` with specific error types. [#296] -- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Minimum supported Rust version (MSRV) is now 1.60. [#296]: https://github.com/actix/actix-extras/pull/296 diff --git a/actix-protobuf/CHANGES.md b/actix-protobuf/CHANGES.md index b8549593a..66b7326fa 100644 --- a/actix-protobuf/CHANGES.md +++ b/actix-protobuf/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2022-xx-xx -- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Minimum supported Rust version (MSRV) is now 1.60. ## 0.9.0 - 2022-08-24 diff --git a/actix-redis/CHANGES.md b/actix-redis/CHANGES.md index 1d87755a5..6cda7ae74 100644 --- a/actix-redis/CHANGES.md +++ b/actix-redis/CHANGES.md @@ -3,7 +3,7 @@ ## Unreleased - 2022-xx-xx - Update `redis-async` dependency to `0.14`. -- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Minimum supported Rust version (MSRV) is now 1.60. ## 0.12.0 - 2022-07-09 diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 1973c33c7..fff49b151 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -2,10 +2,9 @@ ## Unreleased - 2021-xx-xx -- Set secure attribute when adding a session removal cookie. [#300] +- Set secure attribute when adding a session removal cookie. - Update `redis` dependency to `0.22`. - -[#300]: https://github.com/actix/actix-extras/pull/300 +- Minimum supported Rust version (MSRV) is now 1.60. ## 0.7.2 - 2022-09-11 diff --git a/actix-settings/CHANGES.md b/actix-settings/CHANGES.md index 16f1edfe3..840e8d697 100644 --- a/actix-settings/CHANGES.md +++ b/actix-settings/CHANGES.md @@ -4,7 +4,7 @@ - Rename `AtError => Error`. - Remove `AtResult` type alias. -- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Minimum supported Rust version (MSRV) is now 1.60. ## 0.6.0 - 2022-07-31 diff --git a/actix-web-httpauth/CHANGES.md b/actix-web-httpauth/CHANGES.md index 9c8885118..712b74cf4 100644 --- a/actix-web-httpauth/CHANGES.md +++ b/actix-web-httpauth/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased - 2022-xx-xx -- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency. +- Minimum supported Rust version (MSRV) is now 1.60. ## 0.8.0 - 2022-07-21 diff --git a/clippy.toml b/clippy.toml index abe19b3a0..13f202e9e 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.59" +msrv = "1.60" From ad1f15eb18ebf13f35f0cc5556fd8e077fa29b88 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 22 Mar 2023 21:17:30 +0000 Subject: [PATCH 18/26] centralize msrv and edition specs --- Cargo.toml | 4 ++++ actix-cors/Cargo.toml | 3 ++- actix-identity/Cargo.toml | 3 ++- actix-limitation/Cargo.toml | 3 ++- actix-protobuf/Cargo.toml | 3 ++- actix-redis/Cargo.toml | 3 ++- actix-session/Cargo.toml | 3 ++- actix-settings/Cargo.toml | 3 ++- actix-web-httpauth/Cargo.toml | 3 ++- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7e099ede..84d60569b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,10 @@ members = [ "actix-web-httpauth", ] +[workspace.package] +edition = "2018" +rust-version = "1.60" + [patch.crates-io] actix-cors = { path = "./actix-cors" } actix-identity = { path = "./actix-identity" } diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 88bb286ad..8ec759285 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -10,7 +10,8 @@ keywords = ["actix", "cors", "web", "security", "crossorigin"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition = "2018" +edition.workspace = true +rust-version.workspace = true [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 2eb3f0876..f3760eaa1 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -10,7 +10,8 @@ keywords = ["actix", "auth", "identity", "web", "security"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition = "2018" +edition.workspace = true +rust-version.workspace = true [lib] name = "actix_identity" diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index 44199f38f..9656ce541 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -10,7 +10,8 @@ keywords = ["actix-web", "rate-api", "rate-limit", "limitation"] categories = ["asynchronous", "web-programming"] repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition = "2018" +edition.workspace = true +rust-version.workspace = true [features] default = ["session"] diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index e2e85d08f..587346f15 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -1,7 +1,6 @@ [package] name = "actix-protobuf" version = "0.9.0" -edition = "2018" authors = [ "kingxsp ", "Yuki Okushi ", @@ -11,6 +10,8 @@ keywords = ["actix", "web", "protobuf", "protocol", "rpc"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" +edition.workspace = true +rust-version.workspace = true [lib] name = "actix_protobuf" diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index 683179bbb..d09917a48 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -8,7 +8,8 @@ keywords = ["actix", "redis", "async"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" categories = ["network-programming", "asynchronous"] -edition = "2018" +edition.workspace = true +rust-version.workspace = true [package.metadata.docs.rs] all-features = true diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index 2eda122de..e91a0276b 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -10,7 +10,8 @@ keywords = ["http", "web", "framework", "async", "session"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition = "2018" +edition.workspace = true +rust-version.workspace = true [package.metadata.docs.rs] all-features = true diff --git a/actix-settings/Cargo.toml b/actix-settings/Cargo.toml index 477fab353..0dd1a872f 100644 --- a/actix-settings/Cargo.toml +++ b/actix-settings/Cargo.toml @@ -5,9 +5,10 @@ authors = [ "Joey Ezechiels ", "Rob Ede ", ] -edition = "2018" description = "Easily manage Actix Web's settings from a TOML file and environment variables" license = "MIT OR Apache-2.0" +edition.workspace = true +rust-version.workspace = true [dependencies] actix-http = "3" diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index 95116c09f..cf0f8aba7 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -11,7 +11,8 @@ homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" categories = ["web-programming::http-server"] license = "MIT OR Apache-2.0" -edition = "2018" +edition.workspace = true +rust-version.workspace = true [lib] name = "actix_web_httpauth" From b948ac9f7a01bc95ceb31606b4301a2380840e11 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 23 Mar 2023 10:53:54 +0000 Subject: [PATCH 19/26] fix MSRV in CI --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a83b2803d..e77153677 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: target: - { name: Linux, os: ubuntu-latest, triple: x86_64-unknown-linux-gnu } version: - - 1.60 # MSRV + - '1.60' # MSRV - stable name: ${{ matrix.target.name }} / ${{ matrix.version }} @@ -88,7 +88,7 @@ jobs: triple: x86_64-pc-windows-msvc, } version: - - 1.60 # MSRV + - '1.60' # MSRV - stable name: ${{ matrix.target.name }} / ${{ matrix.version }} From 77ee27b4ae0f4511666a7a7319ef60c5708b5ef1 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 23 Mar 2023 11:40:54 +0000 Subject: [PATCH 20/26] inline workspace package properties msrv needs to be 1.64 --- Cargo.toml | 7 ++++--- actix-cors/Cargo.toml | 4 ++-- actix-identity/Cargo.toml | 4 ++-- actix-limitation/Cargo.toml | 4 ++-- actix-protobuf/Cargo.toml | 4 ++-- actix-redis/Cargo.toml | 4 ++-- actix-session/Cargo.toml | 4 ++-- actix-settings/Cargo.toml | 4 ++-- actix-web-httpauth/Cargo.toml | 4 ++-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 84d60569b..a1993e244 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,10 @@ members = [ "actix-web-httpauth", ] -[workspace.package] -edition = "2018" -rust-version = "1.60" +# TODO(MSRV 1.64) +# [workspace.package] +# edition = "2018" +# rust-version = "1.60" [patch.crates-io] actix-cors = { path = "./actix-cors" } diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 8ec759285..a347f9787 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["actix", "cors", "web", "security", "crossorigin"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index f3760eaa1..3228226c1 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["actix", "auth", "identity", "web", "security"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [lib] name = "actix_identity" diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index 9656ce541..d92ff3844 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["actix-web", "rate-api", "rate-limit", "limitation"] categories = ["asynchronous", "web-programming"] repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [features] default = ["session"] diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index 587346f15..dfc0b388b 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["actix", "web", "protobuf", "protocol", "rpc"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [lib] name = "actix_protobuf" diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index d09917a48..efd95c5b0 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -8,8 +8,8 @@ keywords = ["actix", "redis", "async"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" categories = ["network-programming", "asynchronous"] -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [package.metadata.docs.rs] all-features = true diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index e91a0276b..3b100f33b 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -10,8 +10,8 @@ keywords = ["http", "web", "framework", "async", "session"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [package.metadata.docs.rs] all-features = true diff --git a/actix-settings/Cargo.toml b/actix-settings/Cargo.toml index 0dd1a872f..f045f5c63 100644 --- a/actix-settings/Cargo.toml +++ b/actix-settings/Cargo.toml @@ -7,8 +7,8 @@ authors = [ ] description = "Easily manage Actix Web's settings from a TOML file and environment variables" license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [dependencies] actix-http = "3" diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index cf0f8aba7..99fab1886 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -11,8 +11,8 @@ homepage = "https://actix.rs" repository = "https://github.com/actix/actix-extras.git" categories = ["web-programming::http-server"] license = "MIT OR Apache-2.0" -edition.workspace = true -rust-version.workspace = true +edition = "2018" +rust-version = "1.60" [lib] name = "actix_web_httpauth" From 8729f60f7904f097cbc1c321b67b9ff02fcf3406 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 23 Mar 2023 12:15:25 +0000 Subject: [PATCH 21/26] fix CI MSRV --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e77153677..4bd303482 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,11 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v2.1.0 + - name: workaround MSRV issues + if: matrix.version != 'stable' + run: | + cargo update -p=time --precise=0.3.13 + - name: check minimal run: cargo ci-min @@ -120,6 +125,11 @@ jobs: - name: Cache Dependencies uses: Swatinem/rust-cache@v2.1.0 + - name: workaround MSRV issues + if: matrix.version != 'stable' + run: | + cargo update -p=time --precise=0.3.13 + - name: check minimal run: cargo ci-min From 111d95eaea1fa4a481afb451c54fcb2aeabd011f Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Apr 2023 19:35:30 +0100 Subject: [PATCH 22/26] rename private-network-access feature (#320) * update CI with concurrency options * cors: rename private-network => local-network * modernize CI * clippy * run api diff job on all features --- .github/workflows/ci-post-merge.yml | 58 ++++++++------------ .github/workflows/ci.yml | 84 ++++++++++------------------- .github/workflows/coverage.yml | 10 +++- .github/workflows/lint.yml | 52 +++++++++++++----- .github/workflows/upload-doc.yml | 10 +++- actix-cors/CHANGES.md | 1 + actix-cors/Cargo.toml | 2 +- actix-cors/src/builder.rs | 24 ++++----- actix-cors/src/inner.rs | 14 ++--- actix-cors/src/lib.rs | 8 +-- actix-cors/src/middleware.rs | 17 +++--- actix-cors/tests/tests.rs | 44 +++++++-------- actix-session/src/lib.rs | 5 +- 13 files changed, 163 insertions(+), 166 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index af0e15531..ebcab14b8 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -1,8 +1,14 @@ name: CI (post-merge) on: - push: - branches: [master] + push: { branches: [master] } + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build_and_test_linux_nightly: @@ -27,39 +33,26 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 + - name: Install Rust (${{ matrix.version }}) + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: ${{ matrix.version }}-${{ matrix.target.triple }} - profile: minimal - override: true + toolchain: ${{ matrix.version }} - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack - - - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - with: - command: generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-hack } - 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: | @@ -86,18 +79,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install ${{ matrix.version }} - run: | - rustup install ${{ matrix.version }}-${{ matrix.target.triple }} - rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} + - name: Install Rust (${{ matrix.version }}) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ matrix.version }} - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-hack } - name: check minimal run: cargo ci-min diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bd303482..ab9b9b32d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,15 @@ name: CI on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: [master] + pull_request: {} + push: { branches: [master] } + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build_and_test_linux: @@ -35,33 +40,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install ${{ matrix.version }} - run: | - rustup install ${{ matrix.version }}-${{ matrix.target.triple }} - rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} + - name: Install Rust (${{ matrix.version }}) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ matrix.version }} - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-hack } - name: workaround MSRV issues if: matrix.version != 'stable' run: | - cargo install cargo-edit --version=0.8.0 - cargo add env_logger@0.9 --dev -p=actix-cors - cargo add env_logger@0.9 --dev -p=actix-identity - cargo add env_logger@0.9 --dev -p=actix-redis - cargo add env_logger@0.9 --dev -p=actix-session - cargo add env_logger@0.9 --dev -p=actix-settings - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 - - - name: workaround MSRV issues - if: matrix.version != 'stable' - run: | - cargo update -p=time --precise=0.3.13 + cargo update -p=time:0.3.20 --precise=0.3.16 - name: check minimal run: cargo ci-min @@ -102,33 +92,21 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install ${{ matrix.version }} - run: | - rustup install ${{ matrix.version }}-${{ matrix.target.triple }} - rustup override set ${{ matrix.version }}-${{ matrix.target.triple }} + - name: Install Rust (${{ matrix.version }}) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ matrix.version }} - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-hack } + + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-hack } - name: workaround MSRV issues if: matrix.version != 'stable' run: | - cargo install cargo-edit --version=0.8.0 - cargo add env_logger@0.9 --dev -p=actix-cors - cargo add env_logger@0.9 --dev -p=actix-identity - cargo add env_logger@0.9 --dev -p=actix-redis - cargo add env_logger@0.9 --dev -p=actix-session - cargo add env_logger@0.9 --dev -p=actix-settings - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 - - - name: workaround MSRV issues - if: matrix.version != 'stable' - run: | - cargo update -p=time --precise=0.3.13 + cargo update -p=time:0.3.20 --precise=0.3.16 - name: check minimal run: cargo ci-min @@ -155,14 +133,8 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust (nightly) - run: | - rustup install nightly - rustup override set nightly - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - name: doc tests timeout-minutes: 40 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 86427041c..ab01eaece 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -3,8 +3,14 @@ name: Coverage on: - push: - branches: [master] + push: { branches: [master] } + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: coverage: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0c2bd4ef5..2ff3c7b0d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,13 @@ name: Lint -on: - pull_request: - types: [opened, synchronize, reopened] +on: [pull_request] + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: fmt: @@ -10,11 +15,12 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install Rust - run: | - rustup override set nightly - rustup update nightly - rustup component add rustfmt + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly + components: rustfmt + - name: Check with rustfmt run: cargo fmt --all -- --check @@ -24,9 +30,31 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust - run: | - rustup override set stable - rustup update stable - rustup component add rustfmt + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { components: clippy } + - name: Check with Clippy run: cargo clippy --workspace --tests --all-features + + public-api-diff: + runs-on: ubuntu-latest + steps: + - name: checkout ${{ github.base_ref }} + uses: actions/checkout@v3 + with: + ref: ${{ github.base_ref }} + + - name: checkout ${{ github.head_ref }} + uses: actions/checkout@v3 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } + + - uses: taiki-e/cache-cargo-install-action@v1 + with: { tool: cargo-public-api } + + - name: generate API diff + run: | + for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do + cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} + done diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index 2cae41484..90fb8b56a 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -1,8 +1,14 @@ name: Upload Documentation on: - push: - branches: [master] + push: { branches: [master] } + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index 31a23cb71..3140cc45b 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased - 2022-xx-xx +- Rename `Cors::{allow_private_network_access => allow_local_network_access}()` and its unstable flag (`draft-private-network-access` => `draft-local-network-access`). - Minimum supported Rust version (MSRV) is now 1.60. ## 0.6.4 - 2022-10-28 diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index a347f9787..8aba2a231 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"] all-features = true [features] -draft-private-network-access = [] +draft-local-network-access = [] [dependencies] actix-utils = "3" diff --git a/actix-cors/src/builder.rs b/actix-cors/src/builder.rs index 16d4a1578..a985b212b 100644 --- a/actix-cors/src/builder.rs +++ b/actix-cors/src/builder.rs @@ -101,8 +101,8 @@ impl Cors { preflight: true, send_wildcard: false, supports_credentials: true, - #[cfg(feature = "draft-private-network-access")] - allow_private_network_access: false, + #[cfg(feature = "draft-local-network-access")] + allow_local_network_access: false, vary_header: true, block_on_origin_mismatch: true, }; @@ -422,19 +422,19 @@ impl Cors { /// 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. + /// If true, injects the `Access-Control-Allow-Local-Network: true` header in responses if the + /// request contained the `Access-Control-Request-Local-Network: true` header. /// - /// For more information on this behavior, see the draft [Private Network Access] spec. + /// For more information on this behavior, see the draft [Local 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 { + /// [Private Network Access]: https://wicg.github.io/local-network-access + #[cfg(feature = "draft-local-network-access")] + #[cfg_attr(docsrs, doc(cfg(feature = "draft-local-network-access")))] + pub fn allow_local_network_access(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { - cors.allow_private_network_access = true; + cors.allow_local_network_access = true; } self @@ -514,8 +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, + #[cfg(feature = "draft-local-network-access")] + allow_local_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 f5ab671cb..1da38c603 100644 --- a/actix-cors/src/inner.rs +++ b/actix-cors/src/inner.rs @@ -64,8 +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, + #[cfg(feature = "draft-local-network-access")] + pub(crate) allow_local_network_access: bool, pub(crate) vary_header: bool, pub(crate) block_on_origin_mismatch: bool, } @@ -222,19 +222,19 @@ pub(crate) fn add_vary_header(headers: &mut HeaderMap) { 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"); + #[cfg(feature = "draft-local-network-access")] + val.extend(b", Access-Control-Allow-Local-Network"); val.try_into().unwrap() } - #[cfg(feature = "draft-private-network-access")] + #[cfg(feature = "draft-local-network-access")] None => HeaderValue::from_static( "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \ - Access-Control-Allow-Private-Network", + Access-Control-Allow-Local-Network", ), - #[cfg(not(feature = "draft-private-network-access"))] + #[cfg(not(feature = "draft-local-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 b8cc3697b..f18fce1c4 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -7,9 +7,9 @@ //! 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. +//! - `draft-local-network-access`: ⚠️ Unstable. Adds opt-in support for the [Local 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 @@ -46,7 +46,7 @@ //! } //! ``` //! -//! [Private Network Access]: https://wicg.github.io/private-network-access +//! [Local Network Access]: https://wicg.github.io/local-network-access #![forbid(unsafe_code)] #![deny(rust_2018_idioms, nonstandard_style)] diff --git a/actix-cors/src/middleware.rs b/actix-cors/src/middleware.rs index 81055d439..3a6c0fa28 100644 --- a/actix-cors/src/middleware.rs +++ b/actix-cors/src/middleware.rs @@ -93,14 +93,14 @@ impl CorsMiddleware { res.insert_header((header::ACCESS_CONTROL_ALLOW_HEADERS, headers.clone())); } - #[cfg(feature = "draft-private-network-access")] - if inner.allow_private_network_access + #[cfg(feature = "draft-local-network-access")] + if inner.allow_local_network_access && req .headers() - .contains_key("access-control-request-private-network") + .contains_key("access-control-request-local-network") { res.insert_header(( - header::HeaderName::from_static("access-control-allow-private-network"), + header::HeaderName::from_static("access-control-allow-local-network"), HeaderValue::from_static("true"), )); } @@ -149,7 +149,6 @@ impl CorsMiddleware { let expose_all_request_headers = res .headers() .keys() - .into_iter() .map(|name| name.as_str()) .collect::>(); @@ -174,15 +173,15 @@ impl CorsMiddleware { ); } - #[cfg(feature = "draft-private-network-access")] - if inner.allow_private_network_access + #[cfg(feature = "draft-local-network-access")] + if inner.allow_local_network_access && res .request() .headers() - .contains_key("access-control-request-private-network") + .contains_key("access-control-request-local-network") { res.headers_mut().insert( - header::HeaderName::from_static("access-control-allow-private-network"), + header::HeaderName::from_static("access-control-allow-local-network"), HeaderValue::from_static("true"), ); } diff --git a/actix-cors/tests/tests.rs b/actix-cors/tests/tests.rs index e08c76678..755384136 100644 --- a/actix-cors/tests/tests.rs +++ b/actix-cors/tests/tests.rs @@ -264,15 +264,15 @@ async fn test_response() { .get(header::ACCESS_CONTROL_ALLOW_ORIGIN) .map(HeaderValue::as_bytes) ); - #[cfg(not(feature = "draft-private-network-access"))] + #[cfg(not(feature = "draft-local-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")] + #[cfg(feature = "draft-local-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"[..]), + Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-Network"[..]), ); #[allow(clippy::needless_collect)] @@ -317,7 +317,7 @@ 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"))] + #[cfg(not(feature = "draft-local-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -325,10 +325,10 @@ async fn test_response() { .unwrap(), b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-private-network-access")] + #[cfg(feature = "draft-local-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", + b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-Network", ); let cors = Cors::default() @@ -478,7 +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"))] + #[cfg(not(feature = "draft-local-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -487,14 +487,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-private-network-access")] + #[cfg(feature = "draft-local-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", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-Network", ); // follow-up regular request @@ -504,7 +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"))] + #[cfg(not(feature = "draft-local-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -513,14 +513,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-private-network-access")] + #[cfg(feature = "draft-local-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", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-Network", ); let cors = Cors::default() @@ -536,7 +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"))] + #[cfg(not(feature = "draft-local-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -545,21 +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")] + #[cfg(feature = "draft-local-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", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-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"))] + #[cfg(not(feature = "draft-local-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -568,14 +568,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-private-network-access")] + #[cfg(feature = "draft-local-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", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Local-Network", ); } @@ -634,12 +634,12 @@ async fn expose_all_request_header_values() { assert!(cd_hdr.contains("access-control-allow-origin")); } -#[cfg(feature = "draft-private-network-access")] +#[cfg(feature = "draft-local-network-access")] #[actix_web::test] async fn private_network_access() { let cors = Cors::permissive() .allowed_origin("https://public.site") - .allow_private_network_access() + .allow_local_network_access() .new_transform(fn_service(|req: ServiceRequest| async move { let res = req.into_response( HttpResponse::Ok() @@ -664,11 +664,11 @@ async fn private_network_access() { .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")) + .insert_header(("Access-Control-Request-Local-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")); + .contains_key("access-control-allow-local-network")); } diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index 6c6615ef6..cebe707bc 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -726,10 +726,7 @@ pub mod test_helpers { impl ServiceResponseExt for ServiceResponse { fn get_cookie(&self, cookie_name: &str) -> Option> { - self.response() - .cookies() - .into_iter() - .find(|c| c.name() == cookie_name) + self.response().cookies().find(|c| c.name() == cookie_name) } } } From f37c93a2a8895cee2ed9697778bae91310a9a012 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Apr 2023 19:41:57 +0100 Subject: [PATCH 23/26] migrate to doc_auto_cfg --- .github/workflows/ci-post-merge.yml | 3 +-- .github/workflows/ci.yml | 12 +++++------- .github/workflows/coverage.yml | 18 +++++------------- .github/workflows/lint.yml | 13 ++++++++----- .github/workflows/upload-doc.yml | 10 ++++------ actix-cors/src/builder.rs | 1 - actix-cors/src/lib.rs | 2 +- actix-session/src/lib.rs | 2 +- actix-session/src/storage/cookie.rs | 1 - actix-session/src/storage/redis_actor.rs | 2 -- actix-session/src/storage/redis_rs.rs | 2 -- 11 files changed, 25 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci-post-merge.yml b/.github/workflows/ci-post-merge.yml index ebcab14b8..e97973976 100644 --- a/.github/workflows/ci-post-merge.yml +++ b/.github/workflows/ci-post-merge.yml @@ -3,8 +3,7 @@ name: CI (post-merge) on: push: { branches: [master] } -permissions: - contents: read # to fetch code (actions/checkout) +permissions: { contents: read } concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab9b9b32d..84e502340 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,7 @@ on: pull_request: {} push: { branches: [master] } -permissions: - contents: read # to fetch code (actions/checkout) +permissions: { contents: read } concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -45,7 +44,8 @@ jobs: with: toolchain: ${{ matrix.version }} - - uses: taiki-e/cache-cargo-install-action@v1 + - name: Install cargo-hack + uses: taiki-e/cache-cargo-install-action@v1 with: { tool: cargo-hack } - name: workaround MSRV issues @@ -97,10 +97,8 @@ jobs: with: toolchain: ${{ matrix.version }} - - uses: taiki-e/cache-cargo-install-action@v1 - with: { tool: cargo-hack } - - - uses: taiki-e/cache-cargo-install-action@v1 + - name: Install cargo-hack + uses: taiki-e/cache-cargo-install-action@v1 with: { tool: cargo-hack } - name: workaround MSRV issues diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ab01eaece..000149436 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,12 +1,9 @@ -# disabled because `cargo tarpaulin` currently segfaults - name: Coverage on: push: { branches: [master] } -permissions: - contents: read # to fetch code (actions/checkout) +permissions: { contents: read } concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -26,20 +23,15 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install stable - run: | - rustup override set stable - rustup update stable - - - name: Generate Cargo.lock - run: cargo generate-lockfile - - name: Cache Dependencies - uses: Swatinem/rust-cache@v2.1.0 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - 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@v3 with: { file: cobertura.xml } diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2ff3c7b0d..97ad9cec4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,8 +2,7 @@ name: Lint on: [pull_request] -permissions: - contents: read # to fetch code (actions/checkout) +permissions: { contents: read } concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -47,14 +46,18 @@ jobs: - name: checkout ${{ github.head_ref }} uses: actions/checkout@v3 - - uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1 with: { toolchain: nightly } - - uses: taiki-e/cache-cargo-install-action@v1 + - name: Install cargo-public-api + uses: taiki-e/cache-cargo-install-action@v1 with: { tool: cargo-public-api } - name: generate API diff run: | for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do - cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} + + cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} >> /tmp/diff.txt done + cat /tmp/diff.txt diff --git a/.github/workflows/upload-doc.yml b/.github/workflows/upload-doc.yml index 90fb8b56a..a59f7f22f 100644 --- a/.github/workflows/upload-doc.yml +++ b/.github/workflows/upload-doc.yml @@ -3,8 +3,7 @@ name: Upload Documentation on: push: { branches: [master] } -permissions: - contents: read # to fetch code (actions/checkout) +permissions: { contents: write } concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -17,10 +16,9 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install Rust - run: | - rustup override set nightly - rustup update nightly + - name: Install Rust (nightly) + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: { toolchain: nightly } - name: Build Docs run: cargo doc --workspace --all-features --no-deps diff --git a/actix-cors/src/builder.rs b/actix-cors/src/builder.rs index a985b212b..2b224d538 100644 --- a/actix-cors/src/builder.rs +++ b/actix-cors/src/builder.rs @@ -431,7 +431,6 @@ impl Cors { /// /// [Private Network Access]: https://wicg.github.io/local-network-access #[cfg(feature = "draft-local-network-access")] - #[cfg_attr(docsrs, doc(cfg(feature = "draft-local-network-access")))] pub fn allow_local_network_access(mut self) -> Cors { if let Some(cors) = cors(&mut self.inner, &self.error) { cors.allow_local_network_access = true; diff --git a/actix-cors/src/lib.rs b/actix-cors/src/lib.rs index f18fce1c4..622502841 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -53,7 +53,7 @@ #![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))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] mod all_or_some; mod builder; diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index cebe707bc..fbacce290 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -138,7 +138,7 @@ #![warn(future_incompatible, missing_docs)] #![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))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] pub mod config; mod middleware; diff --git a/actix-session/src/storage/cookie.rs b/actix-session/src/storage/cookie.rs index 10cc05bc6..d4144ccce 100644 --- a/actix-session/src/storage/cookie.rs +++ b/actix-session/src/storage/cookie.rs @@ -47,7 +47,6 @@ use crate::storage::{ /// storage backend. /// /// [`CookieContentSecurity::Private`]: crate::config::CookieContentSecurity::Private -#[cfg_attr(docsrs, doc(cfg(feature = "cookie-session")))] #[derive(Default)] #[non_exhaustive] pub struct CookieSessionStore; diff --git a/actix-session/src/storage/redis_actor.rs b/actix-session/src/storage/redis_actor.rs index 744f01156..975df10c9 100644 --- a/actix-session/src/storage/redis_actor.rs +++ b/actix-session/src/storage/redis_actor.rs @@ -53,7 +53,6 @@ use crate::storage::{ /// Redis. Use [`RedisSessionStore`] if you need TLS support. /// /// [`RedisSessionStore`]: crate::storage::RedisSessionStore -#[cfg_attr(docsrs, doc(cfg(feature = "redis-actor-session")))] pub struct RedisActorSessionStore { configuration: CacheConfiguration, addr: Addr, @@ -93,7 +92,6 @@ impl Default for CacheConfiguration { /// A fluent builder to construct a [`RedisActorSessionStore`] instance with custom configuration /// parameters. -#[cfg_attr(docsrs, doc(cfg(feature = "redis-actor-session")))] #[must_use] pub struct RedisActorSessionStoreBuilder { connection_string: String, diff --git a/actix-session/src/storage/redis_rs.rs b/actix-session/src/storage/redis_rs.rs index 04a780279..86db45a3e 100644 --- a/actix-session/src/storage/redis_rs.rs +++ b/actix-session/src/storage/redis_rs.rs @@ -60,7 +60,6 @@ use crate::storage::{ /// `RedisSessionStore` leverages [`redis-rs`] as Redis client. /// /// [`redis-rs`]: https://github.com/mitsuhiko/redis-rs -#[cfg_attr(docsrs, doc(cfg(feature = "redis-rs-session")))] #[derive(Clone)] pub struct RedisSessionStore { configuration: CacheConfiguration, @@ -105,7 +104,6 @@ impl RedisSessionStore { /// parameters. /// /// [`RedisSessionStore`]: crate::storage::RedisSessionStore -#[cfg_attr(docsrs, doc(cfg(feature = "redis-rs-session")))] #[must_use] pub struct RedisSessionStoreBuilder { connection_string: String, From 8c93f5314bfb8f3c53d65cb056a37d6cdebe2ebf Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Apr 2023 19:47:57 +0100 Subject: [PATCH 24/26] update readme crate versions --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2222541e1..3ca1822d8 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ | Crate | | | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | -| [actix-cors] | [![crates.io](https://img.shields.io/crates/v/actix-cors?label=latest)](https://crates.io/crates/actix-cors) [![dependency status](https://deps.rs/crate/actix-cors/0.6.1/status.svg)](https://deps.rs/crate/actix-cors/0.6.1) | Cross-Origin Resource Sharing (CORS) controls. | -| [actix-identity] | [![crates.io](https://img.shields.io/crates/v/actix-identity?label=latest)](https://crates.io/crates/actix-identity) [![dependency status](https://deps.rs/crate/actix-identity/0.4.0/status.svg)](https://deps.rs/crate/actix-identity/0.4.0) | Identity management. | -| [actix-limitation] | [![crates.io](https://img.shields.io/crates/v/actix-limitation?label=latest)](https://crates.io/crates/actix-limitation) [![dependency status](https://deps.rs/crate/actix-limitation/0.3.0/status.svg)](https://deps.rs/crate/actix-limitation/0.3.0) | Rate-limiting using a fixed window counter for arbitrary keys, backed by Redis. | -| [actix-protobuf] | [![crates.io](https://img.shields.io/crates/v/actix-protobuf?label=latest)](https://crates.io/crates/actix-protobuf) [![dependency status](https://deps.rs/crate/actix-protobuf/0.8.0/status.svg)](https://deps.rs/crate/actix-protobuf/0.8.0) | Protobuf payload extractor. | +| [actix-cors] | [![crates.io](https://img.shields.io/crates/v/actix-cors?label=latest)](https://crates.io/crates/actix-cors) [![dependency status](https://deps.rs/crate/actix-cors/0.6.4/status.svg)](https://deps.rs/crate/actix-cors/0.6.4) | Cross-Origin Resource Sharing (CORS) controls. | +| [actix-identity] | [![crates.io](https://img.shields.io/crates/v/actix-identity?label=latest)](https://crates.io/crates/actix-identity) [![dependency status](https://deps.rs/crate/actix-identity/0.5.2/status.svg)](https://deps.rs/crate/actix-identity/0.5.2) | Identity management. | +| [actix-limitation] | [![crates.io](https://img.shields.io/crates/v/actix-limitation?label=latest)](https://crates.io/crates/actix-limitation) [![dependency status](https://deps.rs/crate/actix-limitation/0.4.0/status.svg)](https://deps.rs/crate/actix-limitation/0.4.0) | Rate-limiting using a fixed window counter for arbitrary keys, backed by Redis. | +| [actix-protobuf] | [![crates.io](https://img.shields.io/crates/v/actix-protobuf?label=latest)](https://crates.io/crates/actix-protobuf) [![dependency status](https://deps.rs/crate/actix-protobuf/0.9.0/status.svg)](https://deps.rs/crate/actix-protobuf/0.9.0) | Protobuf payload extractor. | | [actix-redis] | [![crates.io](https://img.shields.io/crates/v/actix-redis?label=latest)](https://crates.io/crates/actix-redis) [![dependency status](https://deps.rs/crate/actix-redis/0.12.0/status.svg)](https://deps.rs/crate/actix-redis/0.12.0) | Actor-based Redis client. | -| [actix-session] | [![crates.io](https://img.shields.io/crates/v/actix-session?label=latest)](https://crates.io/crates/actix-session) [![dependency status](https://deps.rs/crate/actix-session/0.7.1/status.svg)](https://deps.rs/crate/actix-session/0.7.1) | Session management. | +| [actix-session] | [![crates.io](https://img.shields.io/crates/v/actix-session?label=latest)](https://crates.io/crates/actix-session) [![dependency status](https://deps.rs/crate/actix-session/0.7.2/status.svg)](https://deps.rs/crate/actix-session/0.7.2) | Session management. | | [actix-settings] | [![crates.io](https://img.shields.io/crates/v/actix-settings?label=latest)](https://crates.io/crates/actix-settings) [![dependency status](https://deps.rs/crate/actix-settings/0.6.0/status.svg)](https://deps.rs/crate/actix-settings/0.6.0) | Easily manage Actix Web's settings from a TOML file and environment variables. | | [actix-web-httpauth] | [![crates.io](https://img.shields.io/crates/v/actix-web-httpauth?label=latest)](https://crates.io/crates/actix-web-httpauth) [![dependency status](https://deps.rs/crate/actix-web-httpauth/0.8.0/status.svg)](https://deps.rs/crate/actix-web-httpauth/0.8.0) | HTTP authentication schemes. | @@ -28,22 +28,22 @@ These crates are provided by the community. | Crate | | | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| [actix-web-lab] | [![crates.io](https://img.shields.io/crates/v/actix-web-lab?label=latest)][actix-web-lab] [![dependency status](https://deps.rs/crate/actix-web-lab/0.16.4/status.svg)](https://deps.rs/crate/actix-web-lab/0.16.4) | Experimental extractors, middleware, and other extras for possible inclusion in Actix Web. | -| [actix-multipart-extract] | [![crates.io](https://img.shields.io/crates/v/actix-multipart-extract?label=latest)][actix-multipart-extract] [![dependency status](https://deps.rs/crate/actix-multipart-extract/0.1.4/status.svg)](https://deps.rs/crate/actix-multipart-extract/0.1.4) | Better multipart form support for Actix Web. | -| [actix-form-data] | [![crates.io](https://img.shields.io/crates/v/actix-form-data?label=latest)][actix-form-data] [![dependency status](https://deps.rs/crate/actix-form-data/0.6.2/status.svg)](https://deps.rs/crate/actix-form-data/0.6.2) | Multipart form data from actix multipart streams | -| [actix-governor] | [![crates.io](https://img.shields.io/crates/v/actix-governor?label=latest)][actix-governor] [![dependency status](https://deps.rs/crate/actix-governor/0.3.0/status.svg)](https://deps.rs/crate/actix-governor/0.3.0) | Rate-limiting backed by governor. | +| [actix-web-lab] | [![crates.io](https://img.shields.io/crates/v/actix-web-lab?label=latest)][actix-web-lab] [![dependency status](https://deps.rs/crate/actix-web-lab/0.19.1/status.svg)](https://deps.rs/crate/actix-web-lab/0.19.1) | Experimental extractors, middleware, and other extras for possible inclusion in Actix Web. | +| [actix-multipart-extract] | [![crates.io](https://img.shields.io/crates/v/actix-multipart-extract?label=latest)][actix-multipart-extract] [![dependency status](https://deps.rs/crate/actix-multipart-extract/0.1.5/status.svg)](https://deps.rs/crate/actix-multipart-extract/0.1.5) | Better multipart form support for Actix Web. | +| [actix-form-data] | [![crates.io](https://img.shields.io/crates/v/actix-form-data?label=latest)][actix-form-data] [![dependency status](https://deps.rs/crate/actix-form-data/0.7.0-beta.0/status.svg)](https://deps.rs/crate/actix-form-data/0.7.0-beta.0) | Multipart form data from actix multipart streams | +| [actix-governor] | [![crates.io](https://img.shields.io/crates/v/actix-governor?label=latest)][actix-governor] [![dependency status](https://deps.rs/crate/actix-governor/0.4.0/status.svg)](https://deps.rs/crate/actix-governor/0.4.0) | Rate-limiting backed by governor. | | [actix-casbin] | [![crates.io](https://img.shields.io/crates/v/actix-casbin?label=latest)][actix-casbin] [![dependency status](https://deps.rs/crate/actix-casbin/0.4.2/status.svg)](https://deps.rs/crate/actix-casbin/0.4.2) | Authorization library that supports access control models like ACL, RBAC & ABAC. | | [actix-ip-filter] | [![crates.io](https://img.shields.io/crates/v/actix-ip-filter?label=latest)][actix-ip-filter] [![dependency status](https://deps.rs/crate/actix-ip-filter/0.3.1/status.svg)](https://deps.rs/crate/actix-ip-filter/0.3.1) | IP address filter. Supports glob patterns. | -| [actix-web-static-files] | [![crates.io](https://img.shields.io/crates/v/actix-web-static-files?label=latest)][actix-web-static-files] [![dependency status](https://deps.rs/crate/actix-web-static-files/4.0.0/status.svg)](https://deps.rs/crate/actix-web-static-files/4.0.0) | Static files as embedded resources. | +| [actix-web-static-files] | [![crates.io](https://img.shields.io/crates/v/actix-web-static-files?label=latest)][actix-web-static-files] [![dependency status](https://deps.rs/crate/actix-web-static-files/4.0.1/status.svg)](https://deps.rs/crate/actix-web-static-files/4.0.1) | Static files as embedded resources. | | [actix-web-grants] | [![crates.io](https://img.shields.io/crates/v/actix-web-grants?label=latest)][actix-web-grants] [![dependency status](https://deps.rs/crate/actix-web-grants/3.0.1/status.svg)](https://deps.rs/crate/actix-web-grants/3.0.1) | Extension for validating user authorities. | -| [aliri_actix] | [![crates.io](https://img.shields.io/crates/v/aliri_actix?label=latest)][aliri_actix] [![dependency status](https://deps.rs/crate/aliri_actix/0.7.0/status.svg)](https://deps.rs/crate/aliri_actix/0.7.0) | Endpoint authorization and authentication using scoped OAuth2 JWT tokens. | -| [actix-web-flash-messages] | [![crates.io](https://img.shields.io/crates/v/actix-web-flash-messages?label=latest)][actix-web-flash-messages] [![dependency status](https://deps.rs/crate/actix-web-flash-messages/0.4.1/status.svg)](https://deps.rs/crate/actix-web-flash-messages/0.4.1) | Support for flash messages/one-time notifications in `actix-web`. | +| [aliri_actix] | [![crates.io](https://img.shields.io/crates/v/aliri_actix?label=latest)][aliri_actix] [![dependency status](https://deps.rs/crate/aliri_actix/0.8.0/status.svg)](https://deps.rs/crate/aliri_actix/0.8.0) | Endpoint authorization and authentication using scoped OAuth2 JWT tokens. | +| [actix-web-flash-messages] | [![crates.io](https://img.shields.io/crates/v/actix-web-flash-messages?label=latest)][actix-web-flash-messages] [![dependency status](https://deps.rs/crate/actix-web-flash-messages/0.4.2/status.svg)](https://deps.rs/crate/actix-web-flash-messages/0.4.2) | Support for flash messages/one-time notifications in `actix-web`. | | [awmp] | [![crates.io](https://img.shields.io/crates/v/awmp?label=latest)][awmp] [![dependency status](https://deps.rs/crate/awmp/0.8.1/status.svg)](https://deps.rs/crate/awmp/0.8.1) | An easy to use wrapper around multipart fields for Actix Web. | -| [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. | +| [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.7.3/status.svg)](https://deps.rs/crate/tracing-actix-web/0.7.3) | 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] | ![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 | -| [sentinel-actix] | ![crates.io](https://img.shields.io/crates/v/sentinel-actix?label=latest) [![dependency status](https://deps.rs/crate/sentinel-actix/0.1.0/status.svg)](https://deps.rs/crate/sentinel-actix/0.1.0) | General and flexible protection for Actix Web | +| [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.5.0/status.svg)](https://deps.rs/crate/actix-hash/0.5.0) | Hashing utilities 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.1/status.svg)](https://deps.rs/crate/actix-bincode/0.2.1) | Bincode payload extractor for Actix Web | +| [sentinel-actix] | ![crates.io](https://img.shields.io/crates/v/sentinel-actix?label=latest) [![dependency status](https://deps.rs/crate/sentinel-actix/0.1.0/status.svg)](https://deps.rs/crate/sentinel-actix/0.1.0) | General and flexible protection for Actix Web | To add a crate to this list, submit a pull request. From 8a31f3020e48e4a691524637cdb71496294b5ec8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 9 Apr 2023 19:56:43 +0100 Subject: [PATCH 25/26] revert local-network change see https://github.com/actix/actix-extras/pull/320#issuecomment-1501189129 --- actix-cors/CHANGES.md | 1 - actix-cors/Cargo.toml | 2 +- actix-cors/src/builder.rs | 22 +++++++++--------- actix-cors/src/inner.rs | 14 ++++++------ actix-cors/src/lib.rs | 6 ++--- actix-cors/src/middleware.rs | 16 ++++++------- actix-cors/tests/tests.rs | 44 ++++++++++++++++++------------------ 7 files changed, 52 insertions(+), 53 deletions(-) diff --git a/actix-cors/CHANGES.md b/actix-cors/CHANGES.md index 3140cc45b..31a23cb71 100644 --- a/actix-cors/CHANGES.md +++ b/actix-cors/CHANGES.md @@ -2,7 +2,6 @@ ## Unreleased - 2022-xx-xx -- Rename `Cors::{allow_private_network_access => allow_local_network_access}()` and its unstable flag (`draft-private-network-access` => `draft-local-network-access`). - Minimum supported Rust version (MSRV) is now 1.60. ## 0.6.4 - 2022-10-28 diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 8aba2a231..a347f9787 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"] all-features = true [features] -draft-local-network-access = [] +draft-private-network-access = [] [dependencies] actix-utils = "3" diff --git a/actix-cors/src/builder.rs b/actix-cors/src/builder.rs index 2b224d538..51c89223c 100644 --- a/actix-cors/src/builder.rs +++ b/actix-cors/src/builder.rs @@ -101,8 +101,8 @@ impl Cors { preflight: true, send_wildcard: false, supports_credentials: true, - #[cfg(feature = "draft-local-network-access")] - allow_local_network_access: false, + #[cfg(feature = "draft-private-network-access")] + allow_private_network_access: false, vary_header: true, block_on_origin_mismatch: true, }; @@ -422,18 +422,18 @@ impl Cors { /// Allow private network access. /// - /// If true, injects the `Access-Control-Allow-Local-Network: true` header in responses if the - /// request contained the `Access-Control-Request-Local-Network: true` header. + /// 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 [Local Network Access] spec. + /// For more information on this behavior, see the draft [Private Network Access] spec. /// /// Defaults to `false`. /// - /// [Private Network Access]: https://wicg.github.io/local-network-access - #[cfg(feature = "draft-local-network-access")] - pub fn allow_local_network_access(mut self) -> Cors { + /// [Private Network Access]: https://wicg.github.io/private-network-access + #[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_local_network_access = true; + cors.allow_private_network_access = true; } self @@ -513,8 +513,8 @@ impl Default for Cors { preflight: true, send_wildcard: false, supports_credentials: false, - #[cfg(feature = "draft-local-network-access")] - allow_local_network_access: 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 1da38c603..f5ab671cb 100644 --- a/actix-cors/src/inner.rs +++ b/actix-cors/src/inner.rs @@ -64,8 +64,8 @@ pub(crate) struct Inner { pub(crate) preflight: bool, pub(crate) send_wildcard: bool, pub(crate) supports_credentials: bool, - #[cfg(feature = "draft-local-network-access")] - pub(crate) allow_local_network_access: 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, } @@ -222,19 +222,19 @@ pub(crate) fn add_vary_header(headers: &mut HeaderMap) { val.extend(hdr.as_bytes()); val.extend(b", Origin, Access-Control-Request-Method, Access-Control-Request-Headers"); - #[cfg(feature = "draft-local-network-access")] - val.extend(b", Access-Control-Allow-Local-Network"); + #[cfg(feature = "draft-private-network-access")] + val.extend(b", Access-Control-Allow-Private-Network"); val.try_into().unwrap() } - #[cfg(feature = "draft-local-network-access")] + #[cfg(feature = "draft-private-network-access")] None => HeaderValue::from_static( "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, \ - Access-Control-Allow-Local-Network", + Access-Control-Allow-Private-Network", ), - #[cfg(not(feature = "draft-local-network-access"))] + #[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 622502841..e915aad9a 100644 --- a/actix-cors/src/lib.rs +++ b/actix-cors/src/lib.rs @@ -7,8 +7,8 @@ //! This CORS middleware automatically handles `OPTIONS` preflight requests. //! //! # Crate Features -//! - `draft-local-network-access`: ⚠️ Unstable. Adds opt-in support for the [Local Network Access] -//! spec extensions. This feature is unstable since it will follow any breaking changes in the +//! - `draft-private-network-access`: ⚠️ Unstable. Adds opt-in support for the [Private Network +//! Access] spec extensions. This feature is unstable since it will follow breaking changes in the //! draft spec until it is finalized. //! //! # Example @@ -46,7 +46,7 @@ //! } //! ``` //! -//! [Local Network Access]: https://wicg.github.io/local-network-access +//! [Private Network Access]: https://wicg.github.io/private-network-access #![forbid(unsafe_code)] #![deny(rust_2018_idioms, nonstandard_style)] diff --git a/actix-cors/src/middleware.rs b/actix-cors/src/middleware.rs index 3a6c0fa28..dce066274 100644 --- a/actix-cors/src/middleware.rs +++ b/actix-cors/src/middleware.rs @@ -93,14 +93,14 @@ impl CorsMiddleware { res.insert_header((header::ACCESS_CONTROL_ALLOW_HEADERS, headers.clone())); } - #[cfg(feature = "draft-local-network-access")] - if inner.allow_local_network_access + #[cfg(feature = "draft-private-network-access")] + if inner.allow_private_network_access && req .headers() - .contains_key("access-control-request-local-network") + .contains_key("access-control-request-private-network") { res.insert_header(( - header::HeaderName::from_static("access-control-allow-local-network"), + header::HeaderName::from_static("access-control-allow-private-network"), HeaderValue::from_static("true"), )); } @@ -173,15 +173,15 @@ impl CorsMiddleware { ); } - #[cfg(feature = "draft-local-network-access")] - if inner.allow_local_network_access + #[cfg(feature = "draft-private-network-access")] + if inner.allow_private_network_access && res .request() .headers() - .contains_key("access-control-request-local-network") + .contains_key("access-control-request-private-network") { res.headers_mut().insert( - header::HeaderName::from_static("access-control-allow-local-network"), + header::HeaderName::from_static("access-control-allow-private-network"), HeaderValue::from_static("true"), ); } diff --git a/actix-cors/tests/tests.rs b/actix-cors/tests/tests.rs index 755384136..e08c76678 100644 --- a/actix-cors/tests/tests.rs +++ b/actix-cors/tests/tests.rs @@ -264,15 +264,15 @@ async fn test_response() { .get(header::ACCESS_CONTROL_ALLOW_ORIGIN) .map(HeaderValue::as_bytes) ); - #[cfg(not(feature = "draft-local-network-access"))] + #[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-local-network-access")] + #[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-Local-Network"[..]), + Some(&b"Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network"[..]), ); #[allow(clippy::needless_collect)] @@ -317,7 +317,7 @@ async fn test_response() { .method(Method::OPTIONS) .to_srv_request(); let resp = test::call_service(&cors, req).await; - #[cfg(not(feature = "draft-local-network-access"))] + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -325,10 +325,10 @@ async fn test_response() { .unwrap(), b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-local-network-access")] + #[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-Local-Network", + b"Accept, Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", ); let cors = Cors::default() @@ -478,7 +478,7 @@ async fn vary_header_on_all_handled_responses() { assert!(resp .headers() .contains_key(header::ACCESS_CONTROL_ALLOW_METHODS)); - #[cfg(not(feature = "draft-local-network-access"))] + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -487,14 +487,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-local-network-access")] + #[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-Local-Network", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", ); // follow-up regular request @@ -504,7 +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-local-network-access"))] + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -513,14 +513,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-local-network-access")] + #[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-Local-Network", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", ); let cors = Cors::default() @@ -536,7 +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-local-network-access"))] + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -545,21 +545,21 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-local-network-access")] + #[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-Local-Network", + "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-local-network-access"))] + #[cfg(not(feature = "draft-private-network-access"))] assert_eq!( resp.headers() .get(header::VARY) @@ -568,14 +568,14 @@ async fn vary_header_on_all_handled_responses() { .unwrap(), "Origin, Access-Control-Request-Method, Access-Control-Request-Headers", ); - #[cfg(feature = "draft-local-network-access")] + #[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-Local-Network", + "Origin, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Private-Network", ); } @@ -634,12 +634,12 @@ async fn expose_all_request_header_values() { assert!(cd_hdr.contains("access-control-allow-origin")); } -#[cfg(feature = "draft-local-network-access")] +#[cfg(feature = "draft-private-network-access")] #[actix_web::test] async fn private_network_access() { let cors = Cors::permissive() .allowed_origin("https://public.site") - .allow_local_network_access() + .allow_private_network_access() .new_transform(fn_service(|req: ServiceRequest| async move { let res = req.into_response( HttpResponse::Ok() @@ -664,11 +664,11 @@ async fn private_network_access() { .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-Local-Network", "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-local-network")); + .contains_key("access-control-allow-private-network")); } From 75386f4a1dc9e1b42265dcd05943268d64d8dcbe Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 11 Apr 2023 12:22:28 +0100 Subject: [PATCH 26/26] ensure docs.rs builds all crates with all features --- actix-identity/Cargo.toml | 6 +++--- actix-limitation/Cargo.toml | 4 ++++ actix-protobuf/Cargo.toml | 6 +++--- actix-redis/Cargo.toml | 2 +- actix-session/Cargo.toml | 6 +----- actix-settings/Cargo.toml | 4 ++++ actix-web-httpauth/Cargo.toml | 6 +++--- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 3228226c1..373395191 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -13,9 +13,9 @@ license = "MIT OR Apache-2.0" edition = "2018" rust-version = "1.60" -[lib] -name = "actix_identity" -path = "src/lib.rs" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true [dependencies] actix-service = "2" diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index d92ff3844..8287c5e25 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -13,6 +13,10 @@ license = "MIT OR Apache-2.0" edition = "2018" rust-version = "1.60" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true + [features] default = ["session"] session = ["actix-session"] diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index dfc0b388b..633697f2c 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -13,9 +13,9 @@ license = "MIT OR Apache-2.0" edition = "2018" rust-version = "1.60" -[lib] -name = "actix_protobuf" -path = "src/lib.rs" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true [dependencies] actix-web = { version = "4", default-features = false } diff --git a/actix-redis/Cargo.toml b/actix-redis/Cargo.toml index efd95c5b0..039c0f165 100644 --- a/actix-redis/Cargo.toml +++ b/actix-redis/Cargo.toml @@ -12,8 +12,8 @@ edition = "2018" rust-version = "1.60" [package.metadata.docs.rs] -all-features = true rustdoc-args = ["--cfg", "docsrs"] +all-features = true [lib] name = "actix_redis" diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index 3b100f33b..48bd9ab02 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -14,12 +14,8 @@ edition = "2018" rust-version = "1.60" [package.metadata.docs.rs] -all-features = true rustdoc-args = ["--cfg", "docsrs"] - -[lib] -name = "actix_session" -path = "src/lib.rs" +all-features = true [features] default = [] diff --git a/actix-settings/Cargo.toml b/actix-settings/Cargo.toml index f045f5c63..337e57875 100644 --- a/actix-settings/Cargo.toml +++ b/actix-settings/Cargo.toml @@ -10,6 +10,10 @@ license = "MIT OR Apache-2.0" edition = "2018" rust-version = "1.60" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true + [dependencies] actix-http = "3" actix-service = "2" diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index 99fab1886..59dca5d50 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -14,9 +14,9 @@ license = "MIT OR Apache-2.0" edition = "2018" rust-version = "1.60" -[lib] -name = "actix_web_httpauth" -path = "src/lib.rs" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "docsrs"] +all-features = true [dependencies] actix-utils = "3"