diff --git a/.editorconfig b/.editorconfig index 74c73a970..dc6e34dda 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ trim_trailing_whitespace = true [*.yml] indent_size = 2 + +[*.md] +indent_size = 2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ea50a810..0522c1bfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,31 +5,45 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [0.3.2] - 2019-07-19 +## [0.4.0] - 2020-01 + ### Changed - - Middleware accepts any `Fn` as a validator function instead of `FnMut` ([#11](https://github.com/actix/actix-web-httpauth/pull/11)) + - 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 + +### Changed + - Middleware accepts any `Fn` as a validator function instead of `FnMut` ([#11](https://github.com/actix/actix-web-httpauth/pull/11)) ## [0.3.1] - 2019-06-09 + ### Fixed - - Multiple calls to the middleware would result in panic + - Multiple calls to the middleware would result in panic ## [0.3.0] - 2019-06-05 + ### Changed - - 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 + - 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 + ### Changed - - `actix-web` dependency is used without default features now ([#6](https://github.com/actix/actix-web-httpauth/pull/6)) - - `base64` dependency version was bumped to `0.10` + - `actix-web` dependency is used without default features now ([#6](https://github.com/actix/actix-web-httpauth/pull/6)) + - `base64` dependency version was bumped to `0.10` ## [0.1.0] - 2018-09-08 + ### Changed - - Update to `actix-web = "0.7"` version + - Update to `actix-web = "0.7"` version ## [0.0.4] - 2018-07-01 + ### Fixed - - Fix possible panic at `IntoHeaderValue` implementation for `headers::authorization::Basic` - - Fix possible panic at `headers::www_authenticate::challenge::bearer::Bearer::to_bytes` call + - Fix possible panic at `IntoHeaderValue` implementation for `headers::authorization::Basic` + - Fix possible panic at `headers::www_authenticate::challenge::bearer::Bearer::to_bytes` call diff --git a/Cargo.toml b/Cargo.toml index 10858ca48..0d92f75de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ edition = "2018" actix-web = { version = "^2.0", default_features = false } actix-service = "1.0" futures = "0.3" -bytes = "0.4" -base64 = "0.10" +bytes = "0.5" +base64 = "0.11" [dev-dependencies] actix-rt = "1.0" diff --git a/src/headers/authorization/scheme/basic.rs b/src/headers/authorization/scheme/basic.rs index 700dd6b24..0cea7e18b 100644 --- a/src/headers/authorization/scheme/basic.rs +++ b/src/headers/authorization/scheme/basic.rs @@ -120,8 +120,8 @@ impl IntoHeaderValue for Basic { // directly to `value` let encoded = base64::encode(&credentials); let mut value = BytesMut::with_capacity(6 + encoded.len()); - value.put("Basic "); - value.put(&encoded); + value.put(&b"Basic "[..]); + value.put(&encoded.as_bytes()[..]); HeaderValue::from_maybe_shared(value.freeze()) } diff --git a/src/headers/authorization/scheme/bearer.rs b/src/headers/authorization/scheme/bearer.rs index c163fbdda..a1bd3434f 100644 --- a/src/headers/authorization/scheme/bearer.rs +++ b/src/headers/authorization/scheme/bearer.rs @@ -80,7 +80,7 @@ impl IntoHeaderValue for Bearer { fn try_into(self) -> Result::Error> { let mut buffer = BytesMut::with_capacity(7 + self.token.len()); - buffer.put("Bearer "); + buffer.put(&b"Bearer "[..]); buffer.extend_from_slice(self.token.as_bytes()); HeaderValue::from_maybe_shared(buffer.freeze()) diff --git a/src/headers/www_authenticate/challenge/basic.rs b/src/headers/www_authenticate/challenge/basic.rs index b4cfa3d7a..a1d066590 100644 --- a/src/headers/www_authenticate/challenge/basic.rs +++ b/src/headers/www_authenticate/challenge/basic.rs @@ -82,11 +82,11 @@ impl Challenge for Basic { // 5 is for `"Basic"`, 9 is for `"realm=\"\""` let length = 5 + self.realm.as_ref().map_or(0, |realm| realm.len() + 9); let mut buffer = BytesMut::with_capacity(length); - buffer.put("Basic"); + buffer.put(&b"Basic"[..]); if let Some(ref realm) = self.realm { - buffer.put(" realm=\""); + buffer.put(&b" realm=\""[..]); utils::put_quoted(&mut buffer, realm); - buffer.put("\""); + buffer.put_u8(b'"'); } buffer.freeze() diff --git a/src/headers/www_authenticate/challenge/bearer/challenge.rs b/src/headers/www_authenticate/challenge/bearer/challenge.rs index b6f85c1de..d30883263 100644 --- a/src/headers/www_authenticate/challenge/bearer/challenge.rs +++ b/src/headers/www_authenticate/challenge/bearer/challenge.rs @@ -78,18 +78,18 @@ impl Challenge for Bearer { + self.scope.as_ref().map_or(0, |scope| scope.len() + 9) + desc_uri_required; let mut buffer = BytesMut::with_capacity(capacity); - buffer.put("Bearer"); + buffer.put(&b"Bearer"[..]); if let Some(ref realm) = self.realm { - buffer.put(" realm=\""); + buffer.put(&b" realm=\""[..]); utils::put_quoted(&mut buffer, realm); - buffer.put("\""); + buffer.put_u8(b'"'); } if let Some(ref scope) = self.scope { - buffer.put(" scope=\""); + buffer.put(&b" scope=\""[..]); utils::put_quoted(&mut buffer, scope); - buffer.put("\""); + buffer.put_u8(b'"'); } if let Some(ref error) = self.error { @@ -99,21 +99,21 @@ impl Challenge for Bearer { if remaining < required { buffer.reserve(required); } - buffer.put(" error=\""); + buffer.put(&b" error=\""[..]); utils::put_quoted(&mut buffer, error_repr); - buffer.put("\"") + buffer.put_u8(b'"') } if let Some(ref error_description) = self.error_description { - buffer.put(" error_description=\""); + buffer.put(&b" error_description=\""[..]); utils::put_quoted(&mut buffer, error_description); - buffer.put("\""); + buffer.put_u8(b'"'); } if let Some(ref error_uri) = self.error_uri { - buffer.put(" error_uri=\""); + buffer.put(&b" error_uri=\""[..]); utils::put_quoted(&mut buffer, error_uri); - buffer.put("\""); + buffer.put_u8(b'"'); } buffer.freeze()