Skip to content

Commit cc76085

Browse files
committed
change: don’t send plaintext credentials even with debug_assertions
This should hopefully not be a breaking change, as the same code could produce the same behaviour if compiled with different flags. However, it’s possible some downstream test suites could be affected and will need to opt in to the feature.
1 parent 9800e9c commit cc76085

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

gix-transport/Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ http-client-reqwest-rust-tls-trust-dns = [
4747
]
4848
## Stacks with `blocking-http-transport-reqwest` and enables `https://` via the `native-tls` crate.
4949
http-client-reqwest-native-tls = ["http-client-reqwest", "reqwest/default-tls"]
50+
## Allows sending credentials over cleartext HTTP. For testing purposes only.
51+
http-client-insecure-credentials = []
5052
## If set, an async implementations of the git transports becomes available in `crate::client`.
5153
## Suitable for implementing your own transports while using git's way of communication, typically in conjunction with a custom server.
5254
## **Note** that the _blocking_ client has a wide range of available transports, with the _async_ version of it supporting only the TCP based `git` transport leaving you
@@ -66,12 +68,12 @@ serde = ["dep:serde"]
6668
[[test]]
6769
name = "blocking-transport"
6870
path = "tests/blocking-transport.rs"
69-
required-features = ["blocking-client", "maybe-async/is_sync"]
71+
required-features = ["blocking-client", "http-client-insecure-credentials", "maybe-async/is_sync"]
7072

7173
[[test]]
7274
name = "blocking-transport-http-only"
7375
path = "tests/blocking-transport-http.rs"
74-
required-features = ["http-client-curl", "maybe-async/is_sync"]
76+
required-features = ["http-client-curl", "http-client-insecure-credentials", "maybe-async/is_sync"]
7577

7678
[[test]]
7779
name = "async-transport"

gix-transport/src/client/blocking_io/http/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<H: Http> Transport<H> {
297297
#[allow(clippy::unnecessary_wraps, unknown_lints)]
298298
fn add_basic_auth_if_present(&self, headers: &mut Vec<Cow<'_, str>>) -> Result<(), client::Error> {
299299
if let Some(gix_sec::identity::Account { username, password }) = &self.identity {
300-
#[cfg(not(debug_assertions))]
300+
#[cfg(not(feature = "http-client-insecure-credentials"))]
301301
if self.url.starts_with("http://") {
302302
return Err(client::Error::AuthenticationRefused(
303303
"Will not send credentials in clear text over http",

0 commit comments

Comments
 (0)