2024-04-16 11:48:37 -05:00
|
|
|
use uv_auth::{self, KeyringProvider};
|
|
|
|
|
|
|
|
|
|
/// Keyring provider type to use for credential lookup.
|
2024-08-09 14:21:49 -04:00
|
|
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
2024-05-03 10:21:03 -04:00
|
|
|
#[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()),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|