Skip to content

Commit 6e90641

Browse files
committed
Allow usernames in alt registry URLs
We want to forbid secrets since they'll commonly end up checked into source control, but usernames are fine (and are commonly going to be `git`). Closes #6241
1 parent 63cd1cb commit 6e90641

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cargo/util/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ impl Config {
669669
match self.get_string(&format!("registries.{}.index", registry))? {
670670
Some(index) => {
671671
let url = index.val.to_url()?;
672-
if url.username() != "" || url.password().is_some() {
673-
bail!("Registry URLs may not contain credentials");
672+
if url.password().is_some() {
673+
bail!("Registry URLs may not contain passwords");
674674
}
675675
url
676676
}

tests/testsuite/alt_registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ fn publish_with_crates_io_dep() {
458458
}
459459

460460
#[test]
461-
fn credentials_in_url_forbidden() {
461+
fn passwords_in_url_forbidden() {
462462
registry::init();
463463

464464
let config = paths::home().join(".cargo/config");
@@ -489,6 +489,6 @@ fn credentials_in_url_forbidden() {
489489
p.cargo("publish --registry alternative -Zunstable-options")
490490
.masquerade_as_nightly_cargo()
491491
.with_status(101)
492-
.with_stderr_contains("error: Registry URLs may not contain credentials")
492+
.with_stderr_contains("error: Registry URLs may not contain passwords")
493493
.run();
494494
}

0 commit comments

Comments
 (0)