Skip to content

Commit 073e39e

Browse files
committed
credential: make gnome-secret built-in as cargo:libsecret
1 parent 937b930 commit 073e39e

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ base64 = "0.21.2"
2020
bytesize = "1.2"
2121
cargo = { path = "" }
2222
cargo-credential = { version = "0.3.0", path = "credential/cargo-credential" }
23+
cargo-credential-gnome-secret = { version = "0.3.1", path = "credential/cargo-credential-gnome-secret" }
2324
cargo-credential-wincred = { version = "0.3.0", path = "credential/cargo-credential-wincred" }
2425
cargo-credential-macos-keychain = { version = "0.3.0", path = "credential/cargo-credential-macos-keychain" }
2526
cargo-platform = { path = "crates/cargo-platform", version = "0.1.4" }
@@ -123,6 +124,7 @@ base64.workspace = true
123124
bytesize.workspace = true
124125
cargo-platform.workspace = true
125126
cargo-credential.workspace = true
127+
cargo-credential-gnome-secret.workspace = true
126128
cargo-credential-macos-keychain.workspace = true
127129
cargo-credential-wincred.workspace = true
128130
cargo-util.workspace = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[cfg(target_os = "linux")]
2+
mod libsecret;
3+
#[cfg(not(target_os = "linux"))]
4+
pub use cargo_credential::UnsupportedCredential as GnomeSecret;
5+
#[cfg(target_os = "linux")]
6+
pub use libsecret::GnomeSecret;
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
//! Cargo registry gnome libsecret credential process.
22
3-
#[cfg(target_os = "linux")]
4-
mod libsecret;
5-
#[cfg(not(target_os = "linux"))]
6-
use cargo_credential::UnsupportedCredential as GnomeSecret;
7-
#[cfg(target_os = "linux")]
8-
use libsecret::GnomeSecret;
9-
103
fn main() {
114
cargo_credential::main(GnomeSecret);
125
}

src/cargo/util/auth/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ fn credential_action(
451451
"cargo:token-from-stdout" => Box::new(BasicProcessCredential {}),
452452
"cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}),
453453
"cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}),
454+
"cargo:libsecret" => Box::new(cargo_credential_gnome_secret::GnomeSecret {}),
454455
process => Box::new(CredentialProcessCredential::new(process)),
455456
};
456457
config.shell().verbose(|c| {

src/doc/src/reference/unstable.md

+1-14
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ 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:libsecret` - Uses [libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on Linux systems.
10971098
* `cargo:token-from-stdout <command>` - Launch a subprocess that returns a token
10981099
on stdout. Newlines will be trimmed. The process inherits the user's stdin and stderr.
10991100
It should exit 0 on success, and nonzero on error.
@@ -1130,20 +1131,6 @@ In the config, add it to `global-credential-providers`:
11301131
global-credential-providers = ["cargo-credential-1password"]
11311132
```
11321133

1133-
A wrapper is available for GNOME
1134-
[libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on
1135-
Linux systems. Due to build limitations, this wrapper is not available as a
1136-
pre-compiled binary. This can be built and installed manually. First, install
1137-
libsecret using your system package manager (for example, `sudo apt install
1138-
libsecret-1-dev`). Then build and install the wrapper with `cargo install
1139-
cargo-credential-gnome-secret`.
1140-
In the config, use a path to the binary like this:
1141-
1142-
```toml
1143-
[registry]
1144-
global-credential-providers = ["cargo-credential-gnome-secret"]
1145-
```
1146-
11471134
#### JSON Interface
11481135
When using an external credential provider, Cargo communicates with the credential
11491136
provider using stdin/stdout messages passed as a single line of JSON.

0 commit comments

Comments
 (0)