Skip to content

Commit

Permalink
fix(proxy): support url-encoded auth values (#20868)
Browse files Browse the repository at this point in the history
* fix(proxy): support url-encoded auth values

* spellcheck allow

* update expect message
  • Loading branch information
neuronull authored Jul 17, 2024
1 parent 6d179e5 commit e9b4fe1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ upstreaminfo
useragents
usergroups
userguide
urlencoding
webhdfs
winapi
workarounds
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions changelog.d/17125_proxy_auth_url_encoded.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Proxy configuration now supports URL-encoded values.
1 change: 1 addition & 0 deletions lib/vector-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ tracing-core = { version = "0.1.26", default-features = false }
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std"] }
typetag = { version = "0.2.16", default-features = false }
url = { version = "2", default-features = false }
urlencoding = { version = "2.1.3", default-features = false }
vector-buffers = { path = "../vector-buffers", default-features = false }
vector-common = { path = "../vector-common" }
vector-config = { path = "../vector-config" }
Expand Down
9 changes: 6 additions & 3 deletions lib/vector-core/src/config/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,13 @@ impl ProxyConfig {
let mut proxy = Proxy::new(self.interceptor().intercept(proxy_scheme), parsed);
if let Ok(authority) = Url::parse(url) {
if let Some(password) = authority.password() {
let decoded_user = urlencoding::decode(authority.username())
.expect("username must be valid UTF-8.");
let decoded_pw = urlencoding::decode(password)
.expect("Password must be valid UTF-8.");
proxy.set_authorization(Authorization::basic(
authority.username(),
password,
&decoded_user,
&decoded_pw,
));
}
}
Expand Down Expand Up @@ -397,7 +401,6 @@ mod tests {
}
}

#[ignore]
#[test]
fn build_proxy_with_special_chars_url_encoded() {
let config = ProxyConfig {
Expand Down

0 comments on commit e9b4fe1

Please sign in to comment.