#[cfg(feature = "microsoft-auth")]
pub mod microsoft;
pub mod offline;
#[cfg(feature = "yggdrasil-auth")]
pub mod yggdrasil;
use std::any::Any;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::auth::credential::Credential;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[serde(transparent)]
pub struct AccountId(Uuid);
impl AccountId {
pub fn new() -> Self {
Self(Uuid::new_v4())
}
pub fn from_uuid(uuid: Uuid) -> Self {
Self(uuid)
}
pub fn derive(authorizer_id: &str, identity: &str) -> Self {
Self(Uuid::new_v5(
&Uuid::NAMESPACE_URL,
format!("elemental:{authorizer_id}:{identity}").as_bytes(),
))
}
}
impl Default for AccountId {
fn default() -> Self {
Self::new()
}
}
impl std::fmt::Display for AccountId {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(formatter)
}
}
pub trait Account: Send + Sync + erased_serde::Serialize + Any {
fn account_id(&self) -> AccountId;
fn authorizer_id(&self) -> &'static str;
fn display_name(&self) -> &str;
fn needs_refresh(&self) -> bool {
false
}
fn credential(&self) -> Credential;
}