for io::Error {
fn from(err: Error) -> Self {
match err {
- Error::EnvVarError(var_error) => {
- let msg = format!("Env var error: {var_error}");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
- }
+ Error::EnvVarError(_) => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
- Error::FileExists(path_buf) => {
- let msg = format!("File exists: {}", path_buf.display());
- io::Error::new(io::ErrorKind::AlreadyExists, msg)
- }
+ Error::FileExists(_) => io::Error::new(io::ErrorKind::AlreadyExists, err.to_string()),
- Error::InvalidValue {
- expected,
- ref got,
- file,
- line,
- column,
- } => {
- let msg = format!("Expected {expected}, got {got} (@ {file}:{line}:{column})");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
+ Error::InvalidValue { .. } => {
+ io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
}
- Error::IoError(io_error) => io_error.into(),
+ Error::IoError(io_error) => io_error,
- Error::ParseBoolError(parse_bool_error) => {
- let msg = format!("Failed to parse boolean: {parse_bool_error}");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
+ Error::ParseBoolError(_) => {
+ io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
}
- Error::ParseIntError(parse_int_error) => {
- let msg = format!("Failed to parse integer: {parse_int_error}");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
- }
+ Error::ParseIntError(_) => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
- Error::ParseAddressError(string) => {
- let msg = format!("Failed to parse address: {string}");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
+ Error::ParseAddressError(_) => {
+ io::Error::new(io::ErrorKind::InvalidInput, err.to_string())
}
- Error::TomlError(toml_error) => {
- let msg = format!("TOML error: {toml_error}");
- io::Error::new(io::ErrorKind::InvalidInput, msg)
- }
+ Error::TomlError(_) => io::Error::new(io::ErrorKind::InvalidInput, err.to_string()),
}
}
}
diff --git a/actix-settings/src/lib.rs b/actix-settings/src/lib.rs
index df999e46b9..818df35338 100644
--- a/actix-settings/src/lib.rs
+++ b/actix-settings/src/lib.rs
@@ -169,7 +169,8 @@ where
/// Writes the default TOML template to a new file, located at `filepath`.
///
/// # Errors
- /// Returns a [`FileExists`](crate::AtError::FileExists) error if a file already exists at that
+ ///
+ /// Returns a [`FileExists`](crate::Error::FileExists) error if a file already exists at that
/// location.
pub fn write_toml_file(filepath: P) -> AsResult<()>
where
diff --git a/actix-settings/src/parse.rs b/actix-settings/src/parse.rs
index e88a64a3c0..b4433dd93d 100644
--- a/actix-settings/src/parse.rs
+++ b/actix-settings/src/parse.rs
@@ -2,7 +2,7 @@ use std::{path::PathBuf, str::FromStr};
use crate::Error;
-/// A specialized `FromStr` trait that returns [`AtError`] errors
+/// A specialized `FromStr` trait that returns [`Error`] errors
pub trait Parse: Sized {
/// Parse `Self` from `string`.
fn parse(string: &str) -> Result;
diff --git a/actix-web-httpauth/CHANGES.md b/actix-web-httpauth/CHANGES.md
index 712b74cf4b..d307ad7d6b 100644
--- a/actix-web-httpauth/CHANGES.md
+++ b/actix-web-httpauth/CHANGES.md
@@ -1,10 +1,11 @@
# Changes
-## Unreleased - 2022-xx-xx
+## Unreleased
-- Minimum supported Rust version (MSRV) is now 1.60.
+- Implement `From` for `BasicAuth`.
+- Minimum supported Rust version (MSRV) is now 1.68.
-## 0.8.0 - 2022-07-21
+## 0.8.0
- Removed `AuthExtractor` trait; implement `FromRequest` for your custom auth types. [#264]
- `BasicAuth::user_id()` now returns `&str`. [#249]
@@ -16,74 +17,74 @@
[#249]: https://github.com/actix/actix-extras/pull/249
[#264]: https://github.com/actix/actix-extras/pull/264
-## 0.7.0 - 2022-07-19
+## 0.7.0
- 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
+## 0.6.0
- Update `actix-web` dependency to `4`.
-## 0.6.0-beta.8 - 2022-02-07
+## 0.6.0-beta.8
- 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
+## 0.6.0-beta.7
- Minimum supported Rust version (MSRV) is now 1.54.
-## 0.6.0-beta.6 - 2021-12-18
+## 0.6.0-beta.6
- 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
+## 0.6.0-beta.5
- 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
+## 0.6.0-beta.4
- 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
+## 0.6.0-beta.3
- 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
+## 0.6.0-beta.2
- No notable changes.
-## 0.6.0-beta.1 - 2021-04-02
+## 0.6.0-beta.1
- 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
+## 0.5.1
- 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
+## 0.5.0
- Update `actix-web` dependency to 3.0.0.
- Minimum supported Rust version (MSRV) is now 1.42.0.
-## 0.4.2 - 2020-07-08
+## 0.4.2
- Update the `base64` dependency to 0.12
- AuthenticationError's status code is preserved when converting to a ResponseError
@@ -92,11 +93,11 @@
[#69]: https://github.com/actix/actix-web-httpauth/pull/69
-## 0.4.1 - 2020-02-19
+## 0.4.1
- Move repository to actix-extras
-## 0.4.0 - 2020-01-14
+## 0.4.0
- 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
diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml
index 59dca5d50b..00977f3f9c 100644
--- a/actix-web-httpauth/Cargo.toml
+++ b/actix-web-httpauth/Cargo.toml
@@ -10,9 +10,9 @@ keywords = ["http", "web", "framework", "authentication", "security"]
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"
-rust-version = "1.60"
+license.workspace = true
+edition.workspace = true
+rust-version.workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
diff --git a/actix-web-httpauth/src/extractors/basic.rs b/actix-web-httpauth/src/extractors/basic.rs
index 97890dda28..8b0f39ee8c 100644
--- a/actix-web-httpauth/src/extractors/basic.rs
+++ b/actix-web-httpauth/src/extractors/basic.rs
@@ -89,6 +89,12 @@ impl BasicAuth {
}
}
+impl From for BasicAuth {
+ fn from(basic: Basic) -> Self {
+ Self(basic)
+ }
+}
+
impl FromRequest for BasicAuth {
type Future = Ready>;
type Error = AuthenticationError;
diff --git a/actix-web-httpauth/src/extractors/bearer.rs b/actix-web-httpauth/src/extractors/bearer.rs
index e5610ff1e2..78ed3b6160 100644
--- a/actix-web-httpauth/src/extractors/bearer.rs
+++ b/actix-web-httpauth/src/extractors/bearer.rs
@@ -102,7 +102,7 @@ impl FromRequest for BearerAuth {
let bearer = req
.app_data::()
.map(|config| config.0.clone())
- .unwrap_or_else(Default::default);
+ .unwrap_or_default();
AuthenticationError::new(bearer)
}),
diff --git a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs
index 4e5cbc6768..38e511adb1 100644
--- a/actix-web-httpauth/src/headers/authorization/scheme/basic.rs
+++ b/actix-web-httpauth/src/headers/authorization/scheme/basic.rs
@@ -55,7 +55,7 @@ impl Scheme for Basic {
let mut parts = header.to_str()?.splitn(2, ' ');
match parts.next() {
- Some(scheme) if scheme == "Basic" => (),
+ Some("Basic") => (),
_ => return Err(ParseError::MissingScheme),
}
diff --git a/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs b/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs
index 4fac1888cf..13068b67f0 100644
--- a/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs
+++ b/actix-web-httpauth/src/headers/authorization/scheme/bearer.rs
@@ -50,7 +50,7 @@ impl Scheme for Bearer {
let mut parts = header.to_str()?.splitn(2, ' ');
match parts.next() {
- Some(scheme) if scheme == "Bearer" => {}
+ Some("Bearer") => {}
_ => return Err(ParseError::MissingScheme),
}
diff --git a/clippy.toml b/clippy.toml
deleted file mode 100644
index 13f202e9e5..0000000000
--- a/clippy.toml
+++ /dev/null
@@ -1 +0,0 @@
-msrv = "1.60"