use std::str::FromStr;
use serde::{Deserialize, Serialize};
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum Authentication {
BearerToken(String),
BasicHTTP {
username: String,
password: String,
},
CondaToken(String),
}
#[derive(Debug)]
pub enum AuthenticationParseError {
InvalidScheme,
InvalidToken,
}
impl FromStr for Authentication {
type Err = AuthenticationParseError;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
serde_json::from_str(s).map_err(|_err| AuthenticationParseError::InvalidToken)
}
}