Files
uv/crates/uv-configuration/src/authentication.rs
T

29 lines
1023 B
Rust
Raw Normal View History

2024-04-16 11:48:37 -05:00
use uv_auth::{self, KeyringProvider};
/// Keyring provider type to use for credential lookup.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
2024-04-16 11:48:37 -05:00
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
2024-04-17 13:24:41 -04:00
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
2024-04-16 11:48:37 -05:00
pub enum KeyringProviderType {
/// Do not use keyring for credential lookup.
#[default]
Disabled,
/// Use the `keyring` command for credential lookup.
Subprocess,
// /// Not yet implemented
// Auto,
// /// Not implemented yet. Maybe use <https://docs.rs/keyring/latest/keyring/> for this?
// Import,
}
// See <https://pip.pypa.io/en/stable/topics/authentication/#keyring-support> for details.
impl KeyringProviderType {
2024-12-25 14:18:01 -05:00
pub fn to_provider(&self) -> Option<KeyringProvider> {
2024-04-16 11:48:37 -05:00
match self {
Self::Disabled => None,
Self::Subprocess => Some(KeyringProvider::subprocess()),
}
}
}