Skip to content

Commit b6254ca

Browse files
committed
Auto merge of #12512 - arlosi:rename-basic-cred-provider, r=epage
credential: rename cargo:basic to cargo:token-from-stdout Multiple people have said that the name of the `cargo:basic` credential provider is confusing, since it's not doing HTTP Basic authentication. Rename `cargo:basic` to `cargo:token-from-stdout`, which more accurately describes what it does.
2 parents 11870e3 + 1065f21 commit b6254ca

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/cargo/util/auth/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn credential_action(
448448
let provider: Box<dyn Credential> = match process {
449449
"cargo:token" => Box::new(TokenCredential::new(config)),
450450
"cargo:paseto" => Box::new(PasetoCredential::new(config)),
451-
"cargo:basic" => Box::new(BasicProcessCredential {}),
451+
"cargo:token-from-stdout" => Box::new(BasicProcessCredential {}),
452452
"cargo:1password" => Box::new(cargo_credential_1password::OnePasswordCredential {}),
453453
"cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}),
454454
"cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}),

src/cargo/util/credential/adaptor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Credential for BasicProcessCredential {
2323
Action::Get(_) => {
2424
let mut args = args.iter();
2525
let exe = args.next()
26-
.ok_or("The first argument to the `cargo:basic` adaptor must be the path to the credential provider executable.")?;
26+
.ok_or("The first argument to `cargo:token-from-stdout` must be a command that prints a token on stdout")?;
2727
let args = args.map(|arg| arg.replace("{index_url}", registry.index_url));
2828

2929
let mut cmd = Command::new(exe);

src/doc/src/reference/unstable.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,9 @@ executed within the Cargo process. They are identified with the `cargo:` prefix.
10941094
* `cargo:token` - Uses Cargo's config and `credentials.toml` to store the token (default).
10951095
* `cargo:wincred` - Uses the Windows Credential Manager to store the token.
10961096
* `cargo:macos-keychain` - Uses the macOS Keychain to store the token.
1097-
* `cargo:basic` - A basic authenticator is a process that returns a token on stdout. Newlines
1098-
will be trimmed. The process inherits the user's stdin and stderr. It should
1099-
exit 0 on success, and nonzero on error.
1097+
* `cargo:token-from-stdout <command>` - Launch a subprocess that returns a token
1098+
on stdout. Newlines will be trimmed. The process inherits the user's stdin and stderr.
1099+
It should exit 0 on success, and nonzero on error.
11001100

11011101
With this form, [`cargo login`] and [`cargo logout`] are not supported and
11021102
return an error if used.

tests/testsuite/credential_process.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn basic_unsupported() {
148148
// Non-action commands don't support login/logout.
149149
let registry = registry::RegistryBuilder::new()
150150
.no_configure_token()
151-
.credential_provider(&["cargo:basic", "false"])
151+
.credential_provider(&["cargo:token-from-stdout", "false"])
152152
.build();
153153

154154
cargo_process("login -Z credential-process abcdefg")
@@ -158,7 +158,7 @@ fn basic_unsupported() {
158158
.with_stderr(
159159
"\
160160
[UPDATING] crates.io index
161-
[ERROR] credential provider `cargo:basic false` failed action `login`
161+
[ERROR] credential provider `cargo:token-from-stdout false` failed action `login`
162162
163163
Caused by:
164164
requested operation not supported
@@ -172,7 +172,7 @@ Caused by:
172172
.with_status(101)
173173
.with_stderr(
174174
"\
175-
[ERROR] credential provider `cargo:basic false` failed action `logout`
175+
[ERROR] credential provider `cargo:token-from-stdout false` failed action `logout`
176176
177177
Caused by:
178178
requested operation not supported
@@ -262,7 +262,10 @@ fn invalid_token_output() {
262262
cred_proj.cargo("build").run();
263263
let _server = registry::RegistryBuilder::new()
264264
.alternative()
265-
.credential_provider(&["cargo:basic", &toml_bin(&cred_proj, "test-cred")])
265+
.credential_provider(&[
266+
"cargo:token-from-stdout",
267+
&toml_bin(&cred_proj, "test-cred"),
268+
])
266269
.no_configure_token()
267270
.build();
268271

@@ -523,7 +526,10 @@ fn basic_provider() {
523526

524527
let _server = registry::RegistryBuilder::new()
525528
.no_configure_token()
526-
.credential_provider(&["cargo:basic", &toml_bin(&cred_proj, "test-cred")])
529+
.credential_provider(&[
530+
"cargo:token-from-stdout",
531+
&toml_bin(&cred_proj, "test-cred"),
532+
])
527533
.token(cargo_test_support::registry::Token::Plaintext(
528534
"sekrit".to_string(),
529535
))

0 commit comments

Comments
 (0)