diff --git a/Cargo.toml b/Cargo.toml index df5b488020f..3df275ff70d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,9 +128,6 @@ anyhow.workspace = true base64.workspace = true bytesize.workspace = true cargo-credential.workspace = true -cargo-credential-libsecret.workspace = true -cargo-credential-macos-keychain.workspace = true -cargo-credential-wincred.workspace = true cargo-platform.workspace = true cargo-util.workspace = true clap = { workspace = true, features = ["wrap_help"] } @@ -189,9 +186,18 @@ unicode-xid.workspace = true url.workspace = true walkdir.workspace = true +[target.'cfg(target_os = "linux")'.dependencies] +cargo-credential-libsecret.workspace = true + +[target.'cfg(target_os = "macos")'.dependencies] +cargo-credential-macos-keychain.workspace = true + [target.'cfg(not(windows))'.dependencies] openssl = { workspace = true, optional = true } +[target.'cfg(windows)'.dependencies] +cargo-credential-wincred.workspace = true + [target.'cfg(windows)'.dependencies.windows-sys] workspace = true features = [ diff --git a/src/cargo/util/auth/mod.rs b/src/cargo/util/auth/mod.rs index ea82dce0cc2..c2f818645f2 100644 --- a/src/cargo/util/auth/mod.rs +++ b/src/cargo/util/auth/mod.rs @@ -529,9 +529,15 @@ fn credential_action( } "cargo:paseto" => bail!("cargo:paseto requires -Zasymmetric-token"), "cargo:token-from-stdout" => Box::new(BasicProcessCredential {}), + #[cfg(windows)] "cargo:wincred" => Box::new(cargo_credential_wincred::WindowsCredential {}), + #[cfg(target_os = "macos")] "cargo:macos-keychain" => Box::new(cargo_credential_macos_keychain::MacKeychain {}), + #[cfg(target_os = "linux")] "cargo:libsecret" => Box::new(cargo_credential_libsecret::LibSecretCredential {}), + name if BUILT_IN_PROVIDERS.contains(&name) => { + Box::new(cargo_credential::UnsupportedCredential {}) + } process => Box::new(CredentialProcessCredential::new(process)), }; config.shell().verbose(|c| {