Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credential: rename cargo:basic to cargo:token-from-stdout #12512

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/util/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ fn credential_action(
let provider: Box<dyn Credential> = match process {
"cargo:token" => Box::new(TokenCredential::new(config)),
"cargo:paseto" => Box::new(PasetoCredential::new(config)),
"cargo:basic" => Box::new(BasicProcessCredential {}),
"cargo:token-from-stdout" => Box::new(BasicProcessCredential {}),
"cargo:1password" => Box::new(cargo_credential_1password::OnePasswordCredential {}),
"cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}),
"cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}),
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/credential/adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Credential for BasicProcessCredential {
Action::Get(_) => {
let mut args = args.iter();
let exe = args.next()
.ok_or("The first argument to the `cargo:basic` adaptor must be the path to the credential provider executable.")?;
.ok_or("The first argument to `cargo:token-from-stdout` must be a command that prints a token on stdout")?;
let args = args.map(|arg| arg.replace("{index_url}", registry.index_url));

let mut cmd = Command::new(exe);
Expand Down
6 changes: 3 additions & 3 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,9 @@ executed within the Cargo process. They are identified with the `cargo:` prefix.
* `cargo:token` - Uses Cargo's config and `credentials.toml` to store the token (default).
* `cargo:wincred` - Uses the Windows Credential Manager to store the token.
* `cargo:macos-keychain` - Uses the macOS Keychain to store the token.
* `cargo:basic` - A basic authenticator is a process that returns a token on stdout. Newlines
will be trimmed. The process inherits the user's stdin and stderr. It should
exit 0 on success, and nonzero on error.
* `cargo:token-from-stdout <command>` - Launch a subprocess that returns a token
on stdout. Newlines will be trimmed. The process inherits the user's stdin and stderr.
It should exit 0 on success, and nonzero on error.

With this form, [`cargo login`] and [`cargo logout`] are not supported and
return an error if used.
Expand Down
16 changes: 11 additions & 5 deletions tests/testsuite/credential_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn basic_unsupported() {
// Non-action commands don't support login/logout.
let registry = registry::RegistryBuilder::new()
.no_configure_token()
.credential_provider(&["cargo:basic", "false"])
.credential_provider(&["cargo:token-from-stdout", "false"])
.build();

cargo_process("login -Z credential-process abcdefg")
Expand All @@ -158,7 +158,7 @@ fn basic_unsupported() {
.with_stderr(
"\
[UPDATING] crates.io index
[ERROR] credential provider `cargo:basic false` failed action `login`
[ERROR] credential provider `cargo:token-from-stdout false` failed action `login`

Caused by:
requested operation not supported
Expand All @@ -172,7 +172,7 @@ Caused by:
.with_status(101)
.with_stderr(
"\
[ERROR] credential provider `cargo:basic false` failed action `logout`
[ERROR] credential provider `cargo:token-from-stdout false` failed action `logout`

Caused by:
requested operation not supported
Expand Down Expand Up @@ -262,7 +262,10 @@ fn invalid_token_output() {
cred_proj.cargo("build").run();
let _server = registry::RegistryBuilder::new()
.alternative()
.credential_provider(&["cargo:basic", &toml_bin(&cred_proj, "test-cred")])
.credential_provider(&[
"cargo:token-from-stdout",
&toml_bin(&cred_proj, "test-cred"),
])
.no_configure_token()
.build();

Expand Down Expand Up @@ -523,7 +526,10 @@ fn basic_provider() {

let _server = registry::RegistryBuilder::new()
.no_configure_token()
.credential_provider(&["cargo:basic", &toml_bin(&cred_proj, "test-cred")])
.credential_provider(&[
"cargo:token-from-stdout",
&toml_bin(&cred_proj, "test-cred"),
])
.token(cargo_test_support::registry::Token::Plaintext(
"sekrit".to_string(),
))
Expand Down