From ddfb7dffc6b1d64e961d86cf39b5d56e040f4aed Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Tue, 15 Aug 2023 16:15:55 -0500 Subject: [PATCH] credential: make 1password no longer built-in --- Cargo.lock | 1 - Cargo.toml | 2 -- .../src/{lib.rs => main.rs} | 4 +++ src/cargo/util/auth/mod.rs | 1 - src/doc/src/reference/unstable.md | 33 ++++++++++++------- 5 files changed, 25 insertions(+), 16 deletions(-) rename credential/cargo-credential-1password/src/{lib.rs => main.rs} (99%) diff --git a/Cargo.lock b/Cargo.lock index e1a31d62bea8..481ab9ba9f0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,7 +263,6 @@ dependencies = [ "base64", "bytesize", "cargo-credential", - "cargo-credential-1password", "cargo-credential-macos-keychain", "cargo-credential-wincred", "cargo-platform 0.1.4", diff --git a/Cargo.toml b/Cargo.toml index 96fbaea309e0..1d844f9b68ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ base64 = "0.21.2" bytesize = "1.2" cargo = { path = "" } cargo-credential = { version = "0.3.0", path = "credential/cargo-credential" } -cargo-credential-1password = { version = "0.3.0", path = "credential/cargo-credential-1password" } cargo-credential-wincred = { version = "0.3.0", path = "credential/cargo-credential-wincred" } cargo-credential-macos-keychain = { version = "0.3.0", path = "credential/cargo-credential-macos-keychain" } cargo-platform = { path = "crates/cargo-platform", version = "0.1.4" } @@ -123,7 +122,6 @@ base64.workspace = true bytesize.workspace = true cargo-platform.workspace = true cargo-credential.workspace = true -cargo-credential-1password.workspace = true cargo-credential-macos-keychain.workspace = true cargo-credential-wincred.workspace = true cargo-util.workspace = true diff --git a/credential/cargo-credential-1password/src/lib.rs b/credential/cargo-credential-1password/src/main.rs similarity index 99% rename from credential/cargo-credential-1password/src/lib.rs rename to credential/cargo-credential-1password/src/main.rs index 3e16bf310914..a2607fd2f602 100644 --- a/credential/cargo-credential-1password/src/lib.rs +++ b/credential/cargo-credential-1password/src/main.rs @@ -301,3 +301,7 @@ impl Credential for OnePasswordCredential { } } } + +fn main() { + cargo_credential::main(OnePasswordCredential {}); +} diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index e1e672994a16..4b4703910672 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -449,7 +449,6 @@ fn credential_action( "cargo:token" => Box::new(TokenCredential::new(config)), "cargo:paseto" => Box::new(PasetoCredential::new(config)), "cargo:basic" => 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 {}), process => Box::new(CredentialProcessCredential::new(process)), diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 704f933d9f19..abe42d41a614 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -1108,18 +1108,27 @@ executed within the Cargo process. They are identified with the `cargo:` prefix. * `CARGO_REGISTRY_NAME_OPT` --- Optional name of the registry. Should not be used as a storage key. Not always available. * `cargo:paseto` - implements asymmetric token support (RFC3231) as a credential provider. -* `cargo:1password`: Uses the 1password `op` CLI to store the token. You must - install the `op` CLI from the [1password - website](https://1password.com/downloads/command-line/). You must run `op - signin` at least once with the appropriate arguments (such as `op signin - my.1password.com user@example.com`), unless you provide the sign-in-address - and email arguments. The master password will be required on each request - unless the appropriate `OP_SESSION` environment variable is set. It supports - the following command-line arguments: - * `--account`: The account shorthand name to use. - * `--vault`: The vault name to use. - * `--sign-in-address`: The sign-in-address, which is a web address such as `my.1password.com`. - * `--email`: The email address to sign in with. + + +`cargo-credential-1password` uses the 1password `op` CLI to store the token. You must +install the `op` CLI from the [1password +website](https://1password.com/downloads/command-line/). You must run `op +signin` at least once with the appropriate arguments (such as `op signin +my.1password.com user@example.com`), unless you provide the sign-in-address +and email arguments. The master password will be required on each request +unless the appropriate `OP_SESSION` environment variable is set. It supports +the following command-line arguments: +* `--account`: The account shorthand name to use. +* `--vault`: The vault name to use. +* `--sign-in-address`: The sign-in-address, which is a web address such as `my.1password.com`. +* `--email`: The email address to sign in with. + +Install the provider with `cargo install cargo-credential-1password` +In the config, add it to `global-credential-providers`: +```toml +[registry] +global-credential-providers = ["cargo-credential-1password"] +``` A wrapper is available for GNOME [libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on