Skip to content

Commit

Permalink
Auto merge of #6242 - sfackler:registry-username, r=alexcrichton
Browse files Browse the repository at this point in the history
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

r? @alexcrichton
  • Loading branch information
bors committed Nov 1, 2018
2 parents 56d630f + 6e90641 commit fd9cb98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ impl Config {
match self.get_string(&format!("registries.{}.index", registry))? {
Some(index) => {
let url = index.val.to_url()?;
if url.username() != "" || url.password().is_some() {
bail!("Registry URLs may not contain credentials");
if url.password().is_some() {
bail!("Registry URLs may not contain passwords");
}
url
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ fn publish_with_crates_io_dep() {
}

#[test]
fn credentials_in_url_forbidden() {
fn passwords_in_url_forbidden() {
registry::init();

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

0 comments on commit fd9cb98

Please sign in to comment.