mirror of https://github.com/fafhrd91/actix-web
Update base64 dependency to the latest 0.21
This commit is contained in:
parent
6627109984
commit
101a830668
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Unreleased - 2022-xx-xx
|
## Unreleased - 2022-xx-xx
|
||||||
- Minimum supported Rust version (MSRV) is now 1.59.
|
- Minimum supported Rust version (MSRV) is now 1.59.
|
||||||
|
- Upgrade `base64` dependency to `0.21`.
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0 - 2022-07-24
|
## 3.0.0 - 2022-07-24
|
||||||
|
|
|
@ -37,7 +37,7 @@ actix-rt = "2.2"
|
||||||
actix-server = "2"
|
actix-server = "2"
|
||||||
awc = { version = "3", default-features = false }
|
awc = { version = "3", default-features = false }
|
||||||
|
|
||||||
base64 = "0.13"
|
base64 = "0.21"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
futures-core = { version = "0.3.17", default-features = false }
|
futures-core = { version = "0.3.17", default-features = false }
|
||||||
http = "0.2.5"
|
http = "0.2.5"
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
[#2955]: https://github.com/actix/actix-web/pull/2955
|
[#2955]: https://github.com/actix/actix-web/pull/2955
|
||||||
[#2956]: https://github.com/actix/actix-web/pull/2956
|
[#2956]: https://github.com/actix/actix-web/pull/2956
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Upgrade `base64` dependency to `0.21`.
|
||||||
|
|
||||||
|
|
||||||
## 3.2.2 - 2022-09-11
|
## 3.2.2 - 2022-09-11
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -86,7 +86,7 @@ h2 = { version = "0.3.9", optional = true }
|
||||||
|
|
||||||
# websockets
|
# websockets
|
||||||
local-channel = { version = "0.1", optional = true }
|
local-channel = { version = "0.1", optional = true }
|
||||||
base64 = { version = "0.13", optional = true }
|
base64 = { version = "0.21", optional = true }
|
||||||
rand = { version = "0.8", optional = true }
|
rand = { version = "0.8", optional = true }
|
||||||
sha1 = { version = "0.10", optional = true }
|
sha1 = { version = "0.10", optional = true }
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,12 @@ pub fn hash_key(key: &[u8]) -> [u8; 28] {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut hash_b64 = [0; 28];
|
let mut hash_b64 = [0; 28];
|
||||||
let n = base64::encode_config_slice(hash, base64::STANDARD, &mut hash_b64);
|
let n = base64::Engine::encode_slice(
|
||||||
|
&base64::engine::general_purpose::STANDARD,
|
||||||
|
hash,
|
||||||
|
&mut hash_b64,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
assert_eq!(n, 28);
|
assert_eq!(n, 28);
|
||||||
|
|
||||||
hash_b64
|
hash_b64
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
## Unreleased - 2022-xx-xx
|
## Unreleased - 2022-xx-xx
|
||||||
### Changed
|
### Changed
|
||||||
- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency.
|
- Minimum supported Rust version (MSRV) is now 1.59 due to transitive `time` dependency.
|
||||||
|
- Upgrade `base64` dependency to `0.21`.
|
||||||
|
|
||||||
|
|
||||||
## 3.0.1 - 2022-08-25
|
## 3.0.1 - 2022-08-25
|
||||||
|
|
|
@ -63,7 +63,7 @@ actix-tls = { version = "3", features = ["connect", "uri"] }
|
||||||
actix-utils = "3"
|
actix-utils = "3"
|
||||||
|
|
||||||
ahash = "0.7"
|
ahash = "0.7"
|
||||||
base64 = "0.13"
|
base64 = "0.21"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
|
|
|
@ -204,14 +204,11 @@ where
|
||||||
where
|
where
|
||||||
N: fmt::Display,
|
N: fmt::Display,
|
||||||
{
|
{
|
||||||
let auth = match password {
|
let auth = base64::Engine::encode(
|
||||||
Some(password) => format!("{}:{}", username, password),
|
&base64::engine::general_purpose::STANDARD,
|
||||||
None => format!("{}:", username),
|
format!("{}:{}", username, password.unwrap_or("")),
|
||||||
};
|
);
|
||||||
self.add_default_header((
|
self.add_default_header((header::AUTHORIZATION, format!("Basic {auth}")))
|
||||||
header::AUTHORIZATION,
|
|
||||||
format!("Basic {}", base64::encode(auth)),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set client wide HTTP bearer authentication header
|
/// Set client wide HTTP bearer authentication header
|
||||||
|
|
|
@ -234,12 +234,11 @@ impl ClientRequest {
|
||||||
///
|
///
|
||||||
/// If no password is needed, just provide an empty string.
|
/// If no password is needed, just provide an empty string.
|
||||||
pub fn basic_auth(self, username: impl fmt::Display, password: impl fmt::Display) -> Self {
|
pub fn basic_auth(self, username: impl fmt::Display, password: impl fmt::Display) -> Self {
|
||||||
let auth = format!("{}:{}", username, password);
|
let auth = base64::Engine::encode(
|
||||||
|
&base64::engine::general_purpose::STANDARD,
|
||||||
self.insert_header((
|
format!("{}:{}", username, password),
|
||||||
header::AUTHORIZATION,
|
);
|
||||||
format!("Basic {}", base64::encode(auth)),
|
self.insert_header((header::AUTHORIZATION, format!("Basic {auth}")))
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set HTTP bearer authentication header
|
/// Set HTTP bearer authentication header
|
||||||
|
|
|
@ -232,11 +232,11 @@ impl WebsocketsRequest {
|
||||||
where
|
where
|
||||||
U: fmt::Display,
|
U: fmt::Display,
|
||||||
{
|
{
|
||||||
let auth = match password {
|
let auth = base64::Engine::encode(
|
||||||
Some(password) => format!("{}:{}", username, password),
|
&base64::engine::general_purpose::STANDARD,
|
||||||
None => format!("{}:", username),
|
format!("{}:{}", username, password.unwrap_or("")),
|
||||||
};
|
);
|
||||||
self.header(AUTHORIZATION, format!("Basic {}", base64::encode(auth)))
|
self.header(AUTHORIZATION, format!("Basic {auth}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set HTTP bearer authentication header
|
/// Set HTTP bearer authentication header
|
||||||
|
@ -320,8 +320,10 @@ impl WebsocketsRequest {
|
||||||
|
|
||||||
// Generate a random key for the `Sec-WebSocket-Key` header which is a base64-encoded
|
// Generate a random key for the `Sec-WebSocket-Key` header which is a base64-encoded
|
||||||
// (see RFC 4648 §4) value that, when decoded, is 16 bytes in length (RFC 6455 §1.3).
|
// (see RFC 4648 §4) value that, when decoded, is 16 bytes in length (RFC 6455 §1.3).
|
||||||
let sec_key: [u8; 16] = rand::random();
|
let key = base64::Engine::encode(
|
||||||
let key = base64::encode(sec_key);
|
&base64::engine::general_purpose::STANDARD,
|
||||||
|
rand::random::<[u8; 16]>(),
|
||||||
|
);
|
||||||
|
|
||||||
self.head.headers.insert(
|
self.head.headers.insert(
|
||||||
header::SEC_WEBSOCKET_KEY,
|
header::SEC_WEBSOCKET_KEY,
|
||||||
|
|
|
@ -777,13 +777,20 @@ async fn client_basic_auth() {
|
||||||
App::new().route(
|
App::new().route(
|
||||||
"/",
|
"/",
|
||||||
web::to(|req: HttpRequest| {
|
web::to(|req: HttpRequest| {
|
||||||
|
let auth = format!(
|
||||||
|
"Basic {}",
|
||||||
|
base64::Engine::encode(
|
||||||
|
&base64::engine::general_purpose::STANDARD,
|
||||||
|
"username:password",
|
||||||
|
)
|
||||||
|
);
|
||||||
if req
|
if req
|
||||||
.headers()
|
.headers()
|
||||||
.get(header::AUTHORIZATION)
|
.get(header::AUTHORIZATION)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
== format!("Basic {}", base64::encode("username:password"))
|
== auth
|
||||||
{
|
{
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue