use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum AuthType {
Bearer,
Basic,
ApiKey,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleAuthProfile {
pub auth_type: AuthType,
pub token: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub header: Option<String>,
}
impl SimpleAuthProfile {
#[allow(dead_code)]
pub fn bearer(token: String) -> Self {
Self {
auth_type: AuthType::Bearer,
token: Some(token),
username: None,
password: None,
header: None,
}
}
#[allow(dead_code)]
pub fn basic(username: String, password: String) -> Self {
Self {
auth_type: AuthType::Basic,
token: None,
username: Some(username),
password: Some(password),
header: None,
}
}
#[allow(dead_code)]
pub fn api_key(header: String, token: String) -> Self {
Self {
auth_type: AuthType::ApiKey,
token: Some(token),
username: None,
password: None,
header: Some(header),
}
}
}