1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 15:51:06 +01:00

Update bytes to 0.5 and base64 to 0.11 (#18)

* Update bytes to 0.5 and base64 to 0.11

* Update changelog
This commit is contained in:
Yuki Okushi 2020-01-10 05:57:42 +09:00 committed by GitHub
parent cfaa307d47
commit 4d9fb6825c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 31 deletions

View File

@ -10,3 +10,6 @@ trim_trailing_whitespace = true
[*.yml] [*.yml]
indent_size = 2 indent_size = 2
[*.md]
indent_size = 2

View File

@ -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/) 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). 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 ### 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 ## [0.3.1] - 2019-06-09
### Fixed ### 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 ## [0.3.0] - 2019-06-05
### Changed ### Changed
- Crate edition was changed to `2018`, same as `actix-web` - Crate edition was changed to `2018`, same as `actix-web`
- Depends on `actix-web = "^1.0"` version now - Depends on `actix-web = "^1.0"` version now
- `WWWAuthenticate` header struct was renamed into `WwwAuthenticate` - `WWWAuthenticate` header struct was renamed into `WwwAuthenticate`
- Challenges and extractor configs are now operating with `Cow<'static, str>` types instead of `String` types - Challenges and extractor configs are now operating with `Cow<'static, str>` types instead of `String` types
## [0.2.0] - 2019-04-26 ## [0.2.0] - 2019-04-26
### Changed ### Changed
- `actix-web` dependency is used without default features now ([#6](https://github.com/actix/actix-web-httpauth/pull/6)) - `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` - `base64` dependency version was bumped to `0.10`
## [0.1.0] - 2018-09-08 ## [0.1.0] - 2018-09-08
### Changed ### Changed
- Update to `actix-web = "0.7"` version - Update to `actix-web = "0.7"` version
## [0.0.4] - 2018-07-01 ## [0.0.4] - 2018-07-01
### Fixed ### Fixed
- Fix possible panic at `IntoHeaderValue` implementation for `headers::authorization::Basic` - 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 `headers::www_authenticate::challenge::bearer::Bearer::to_bytes` call

View File

@ -17,8 +17,8 @@ edition = "2018"
actix-web = { version = "^2.0", default_features = false } actix-web = { version = "^2.0", default_features = false }
actix-service = "1.0" actix-service = "1.0"
futures = "0.3" futures = "0.3"
bytes = "0.4" bytes = "0.5"
base64 = "0.10" base64 = "0.11"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0" actix-rt = "1.0"

View File

@ -120,8 +120,8 @@ impl IntoHeaderValue for Basic {
// directly to `value` // directly to `value`
let encoded = base64::encode(&credentials); let encoded = base64::encode(&credentials);
let mut value = BytesMut::with_capacity(6 + encoded.len()); let mut value = BytesMut::with_capacity(6 + encoded.len());
value.put("Basic "); value.put(&b"Basic "[..]);
value.put(&encoded); value.put(&encoded.as_bytes()[..]);
HeaderValue::from_maybe_shared(value.freeze()) HeaderValue::from_maybe_shared(value.freeze())
} }

View File

@ -80,7 +80,7 @@ impl IntoHeaderValue for Bearer {
fn try_into(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> { fn try_into(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
let mut buffer = BytesMut::with_capacity(7 + self.token.len()); 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()); buffer.extend_from_slice(self.token.as_bytes());
HeaderValue::from_maybe_shared(buffer.freeze()) HeaderValue::from_maybe_shared(buffer.freeze())

View File

@ -82,11 +82,11 @@ impl Challenge for Basic {
// 5 is for `"Basic"`, 9 is for `"realm=\"\""` // 5 is for `"Basic"`, 9 is for `"realm=\"\""`
let length = 5 + self.realm.as_ref().map_or(0, |realm| realm.len() + 9); let length = 5 + self.realm.as_ref().map_or(0, |realm| realm.len() + 9);
let mut buffer = BytesMut::with_capacity(length); let mut buffer = BytesMut::with_capacity(length);
buffer.put("Basic"); buffer.put(&b"Basic"[..]);
if let Some(ref realm) = self.realm { if let Some(ref realm) = self.realm {
buffer.put(" realm=\""); buffer.put(&b" realm=\""[..]);
utils::put_quoted(&mut buffer, realm); utils::put_quoted(&mut buffer, realm);
buffer.put("\""); buffer.put_u8(b'"');
} }
buffer.freeze() buffer.freeze()

View File

@ -78,18 +78,18 @@ impl Challenge for Bearer {
+ self.scope.as_ref().map_or(0, |scope| scope.len() + 9) + self.scope.as_ref().map_or(0, |scope| scope.len() + 9)
+ desc_uri_required; + desc_uri_required;
let mut buffer = BytesMut::with_capacity(capacity); let mut buffer = BytesMut::with_capacity(capacity);
buffer.put("Bearer"); buffer.put(&b"Bearer"[..]);
if let Some(ref realm) = self.realm { if let Some(ref realm) = self.realm {
buffer.put(" realm=\""); buffer.put(&b" realm=\""[..]);
utils::put_quoted(&mut buffer, realm); utils::put_quoted(&mut buffer, realm);
buffer.put("\""); buffer.put_u8(b'"');
} }
if let Some(ref scope) = self.scope { if let Some(ref scope) = self.scope {
buffer.put(" scope=\""); buffer.put(&b" scope=\""[..]);
utils::put_quoted(&mut buffer, scope); utils::put_quoted(&mut buffer, scope);
buffer.put("\""); buffer.put_u8(b'"');
} }
if let Some(ref error) = self.error { if let Some(ref error) = self.error {
@ -99,21 +99,21 @@ impl Challenge for Bearer {
if remaining < required { if remaining < required {
buffer.reserve(required); buffer.reserve(required);
} }
buffer.put(" error=\""); buffer.put(&b" error=\""[..]);
utils::put_quoted(&mut buffer, error_repr); utils::put_quoted(&mut buffer, error_repr);
buffer.put("\"") buffer.put_u8(b'"')
} }
if let Some(ref error_description) = self.error_description { 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); utils::put_quoted(&mut buffer, error_description);
buffer.put("\""); buffer.put_u8(b'"');
} }
if let Some(ref error_uri) = self.error_uri { 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); utils::put_quoted(&mut buffer, error_uri);
buffer.put("\""); buffer.put_u8(b'"');
} }
buffer.freeze() buffer.freeze()