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

[beta 1.75] Backport 1password fixes #12994

Merged
merged 2 commits into from
Nov 17, 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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion credential/cargo-credential-1password/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-credential-1password"
version = "0.4.1"
version = "0.4.2"
edition.workspace = true
license.workspace = true
rust-version = "1.70.0" # MSRV:3
Expand Down
38 changes: 26 additions & 12 deletions credential/cargo-credential-1password/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@

A Cargo [credential provider] for [1password].

`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 [email protected]`),
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.
## Usage

`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/).

Afterward you need to configure `cargo` to use `cargo-credential-1password` as
the credential provider. You can do this by adding something like the following
to your [cargo config file][credential provider]:

```toml
[registry]
global-credential-providers = ["cargo-credential-1password --account my.1password.com"]
```

Finally, run `cargo login` to save your registry token in 1password.

## CLI Arguments

`cargo-credential-1password` supports the following command-line arguments:

* `--account`: The account name to use. For a list of available accounts,
run `op account list`.
* `--vault`: The vault name to use. For a list of available vaults,
run `op vault list`.

[1password]: https://1password.com/
[credential provider]: https://doc.rust-lang.org/nightly/cargo/reference/registry-authentication.html
[credential provider]: https://doc.rust-lang.org/stable/cargo/reference/registry-authentication.html
4 changes: 4 additions & 0 deletions credential/cargo-credential-1password/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ impl OnePasswordKeychain {
}
let mut cmd = Command::new("op");
cmd.args(["signin", "--raw"]);
if let Some(account) = &self.account {
cmd.arg("--account");
cmd.arg(account);
}
cmd.stdout(Stdio::piped());
let mut child = cmd
.spawn()
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/registry-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Install the provider with `cargo install cargo-credential-1password`
In the config, add to (or create) `registry.global-credential-providers`:
```toml
[registry]
global-credential-providers = ["cargo:token", "cargo-credential-1password --email you@example.com"]
global-credential-providers = ["cargo:token", "cargo-credential-1password --account my.1password.com"]
```

The values in `global-credential-providers` are split on spaces into path and command-line arguments. To
Expand Down
Loading