56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use std::net::{Ipv6Addr, SocketAddr, SocketAddrV6};
|
|
|
|
use serde::Deserialize;
|
|
use url::Url;
|
|
|
|
use crate::secrets::PadlockGenerationSecret;
|
|
|
|
fn default_listen_addr() -> SocketAddr {
|
|
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, 80, 0, 0))
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
pub struct Config {
|
|
#[serde(default = "default_listen_addr")]
|
|
pub listen: SocketAddr,
|
|
|
|
pub padlock: PadlockConfig,
|
|
pub database: DatabaseConfig,
|
|
#[serde(default)]
|
|
pub auth_backends: Vec<AuthBackendConfig>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
#[allow(clippy::module_name_repetitions)]
|
|
pub enum PadlockConfig {
|
|
Secret(#[serde(with = "hex::serde")] PadlockGenerationSecret),
|
|
Proxy(Url),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
#[allow(clippy::module_name_repetitions)]
|
|
pub struct DatabaseConfig {
|
|
pub connection_string: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(tag = "type")]
|
|
#[allow(clippy::module_name_repetitions)]
|
|
pub enum AuthBackendConfig {
|
|
#[serde(rename = "LDAP")]
|
|
Ldap(LdapBackendConfig),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
#[serde(rename_all = "kebab-case")]
|
|
#[allow(clippy::module_name_repetitions)]
|
|
pub struct LdapBackendConfig {
|
|
pub server_address: String,
|
|
pub search_base: String,
|
|
/// User filter template. All occurences of `%s` will be replaced with the username.
|
|
pub user_filter: String,
|
|
}
|