Add auth config

This commit is contained in:
Lennart
2023-09-07 18:53:12 +02:00
parent 7f5df657d2
commit 5ee509b7bc
3 changed files with 29 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
use rustical_auth::{AuthProvider, HtpasswdAuthConfig};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
@@ -11,7 +12,26 @@ pub enum CalendarStoreConfig {
Toml(TomlCalendarStoreConfig),
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "backend", rename_all = "snake_case")]
pub enum AuthConfig {
Htpasswd(HtpasswdAuthConfig),
None,
}
impl From<AuthConfig> for AuthProvider {
fn from(value: AuthConfig) -> Self {
match value {
AuthConfig::Htpasswd(config) => {
Self::Htpasswd(rustical_auth::htpasswd::HtpasswdAuth { config })
}
AuthConfig::None => Self::None(rustical_auth::none::NoneAuth),
}
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Config {
pub calendar_store: CalendarStoreConfig,
pub auth: AuthConfig,
}