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

Make cargo-credential-gnome-secret built-in as cargo:libsecret #12521

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ base64 = "0.21.2"
bytesize = "1.2"
cargo = { path = "" }
cargo-credential = { version = "0.3.0", path = "credential/cargo-credential" }
cargo-credential-gnome-secret = { version = "0.3.1", path = "credential/cargo-credential-gnome-secret" }
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" }
Expand Down Expand Up @@ -123,6 +124,7 @@ base64.workspace = true
bytesize.workspace = true
cargo-platform.workspace = true
cargo-credential.workspace = true
cargo-credential-gnome-secret.workspace = true
arlosi marked this conversation as resolved.
Show resolved Hide resolved
cargo-credential-macos-keychain.workspace = true
cargo-credential-wincred.workspace = true
cargo-util.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions credential/cargo-credential-gnome-secret/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[cfg(target_os = "linux")]
mod libsecret;
#[cfg(not(target_os = "linux"))]
pub use cargo_credential::UnsupportedCredential as GnomeSecret;
#[cfg(target_os = "linux")]
pub use libsecret::GnomeSecret;
7 changes: 0 additions & 7 deletions credential/cargo-credential-gnome-secret/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
//! Cargo registry gnome libsecret credential process.

#[cfg(target_os = "linux")]
mod libsecret;
#[cfg(not(target_os = "linux"))]
use cargo_credential::UnsupportedCredential as GnomeSecret;
#[cfg(target_os = "linux")]
use libsecret::GnomeSecret;

fn main() {
arlosi marked this conversation as resolved.
Show resolved Hide resolved
cargo_credential::main(GnomeSecret);
}
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ allow = [
"MPL-2.0",
"Unicode-DFS-2016",
"CC0-1.0",
"ISC",
]
# List of explicitly disallowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
Expand Down
1 change: 1 addition & 0 deletions src/cargo/util/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ fn credential_action(
"cargo:token-from-stdout" => Box::new(BasicProcessCredential {}),
"cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}),
"cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}),
"cargo:libsecret" => Box::new(cargo_credential_gnome_secret::GnomeSecret {}),
process => Box::new(CredentialProcessCredential::new(process)),
};
config.shell().verbose(|c| {
Expand Down
15 changes: 1 addition & 14 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ 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:libsecret` - Uses [libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on Linux systems.
* `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.
Expand Down Expand Up @@ -1130,20 +1131,6 @@ In the config, add it to `global-credential-providers`:
global-credential-providers = ["cargo-credential-1password"]
```

A wrapper is available for GNOME
[libsecret](https://wiki.gnome.org/Projects/Libsecret) to store tokens on
Linux systems. Due to build limitations, this wrapper is not available as a
pre-compiled binary. This can be built and installed manually. First, install
libsecret using your system package manager (for example, `sudo apt install
libsecret-1-dev`). Then build and install the wrapper with `cargo install
cargo-credential-gnome-secret`.
In the config, use a path to the binary like this:

```toml
[registry]
global-credential-providers = ["cargo-credential-gnome-secret"]
```

#### JSON Interface
When using an external credential provider, Cargo communicates with the credential
provider using stdin/stdout messages passed as a single line of JSON.
Expand Down