Skip to content

Commit c67dced

Browse files
committed
Auto merge of rust-lang#12994 - ehuss:beta-1pass, r=weihanglo
[beta 1.75] Backport 1password fixes This backports these fixes to 1.75 for the cargo-credential-1password helper. I'd like to publish these fixes and get the docs updated sooner rather than later. Unfortunately it uses an unpublished version of cargo-credential, so I can't publish directly from master. Backports: * rust-lang#12985 — cargo-credential-1password: Add missing `--account` argument to `op signin` command * rust-lang#12986 — cargo-credential-1password: Fix README
2 parents 6790a51 + 8862fd3 commit c67dced

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

credential/cargo-credential-1password/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-credential-1password"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition.workspace = true
55
license.workspace = true
66
rust-version = "1.70.0" # MSRV:3

credential/cargo-credential-1password/README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@
22

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

5-
`cargo-credential-1password` uses the 1password `op` CLI to store the token. You must
6-
install the `op` CLI from the [1password
7-
website](https://1password.com/downloads/command-line/). You must run `op signin`
8-
at least once with the appropriate arguments (such as `op signin my.1password.com [email protected]`),
9-
unless you provide the sign-in-address and email arguments. The master password will be required on each request
10-
unless the appropriate `OP_SESSION` environment variable is set. It supports
11-
the following command-line arguments:
12-
* `--account`: The account shorthand name to use.
13-
* `--vault`: The vault name to use.
14-
* `--sign-in-address`: The sign-in-address, which is a web address such as `my.1password.com`.
15-
* `--email`: The email address to sign in with.
5+
## Usage
6+
7+
`cargo-credential-1password` uses the 1password `op` CLI to store the token. You
8+
must install the `op` CLI from the [1password
9+
website](https://1password.com/downloads/command-line/).
10+
11+
Afterward you need to configure `cargo` to use `cargo-credential-1password` as
12+
the credential provider. You can do this by adding something like the following
13+
to your [cargo config file][credential provider]:
14+
15+
```toml
16+
[registry]
17+
global-credential-providers = ["cargo-credential-1password --account my.1password.com"]
18+
```
19+
20+
Finally, run `cargo login` to save your registry token in 1password.
21+
22+
## CLI Arguments
23+
24+
`cargo-credential-1password` supports the following command-line arguments:
25+
26+
* `--account`: The account name to use. For a list of available accounts,
27+
run `op account list`.
28+
* `--vault`: The vault name to use. For a list of available vaults,
29+
run `op vault list`.
1630

1731
[1password]: https://1password.com/
18-
[credential provider]: https://doc.rust-lang.org/nightly/cargo/reference/registry-authentication.html
32+
[credential provider]: https://doc.rust-lang.org/stable/cargo/reference/registry-authentication.html

credential/cargo-credential-1password/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ impl OnePasswordKeychain {
7979
}
8080
let mut cmd = Command::new("op");
8181
cmd.args(["signin", "--raw"]);
82+
if let Some(account) = &self.account {
83+
cmd.arg("--account");
84+
cmd.arg(account);
85+
}
8286
cmd.stdout(Stdio::piped());
8387
let mut child = cmd
8488
.spawn()

src/doc/src/reference/registry-authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Install the provider with `cargo install cargo-credential-1password`
103103
In the config, add to (or create) `registry.global-credential-providers`:
104104
```toml
105105
[registry]
106-
global-credential-providers = ["cargo:token", "cargo-credential-1password --email you@example.com"]
106+
global-credential-providers = ["cargo:token", "cargo-credential-1password --account my.1password.com"]
107107
```
108108

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

0 commit comments

Comments
 (0)