mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 15:12:23 +00:00
Add auth config
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user