mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
DAV Push: Configurable list of allowed push targets
This commit is contained in:
@@ -7,7 +7,8 @@ use rustical_frontend::FrontendConfig;
|
||||
use rustical_store::auth::{static_user_store::UserEntry, StaticUserStoreConfig, User};
|
||||
|
||||
use crate::config::{
|
||||
AuthConfig, Config, DataStoreConfig, HttpConfig, SqliteDataStoreConfig, TracingConfig,
|
||||
AuthConfig, Config, DataStoreConfig, DavPushConfig, HttpConfig, SqliteDataStoreConfig,
|
||||
TracingConfig,
|
||||
};
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
@@ -46,6 +47,7 @@ pub fn cmd_gen_config(_args: GenConfigArgs) -> anyhow::Result<()> {
|
||||
frontend: FrontendConfig {
|
||||
secret_key: generate_frontend_secret(),
|
||||
},
|
||||
dav_push: DavPushConfig::default(),
|
||||
};
|
||||
let generated_config = toml::to_string(&config)?;
|
||||
println!("{generated_config}");
|
||||
|
||||
@@ -44,6 +44,25 @@ pub struct TracingConfig {
|
||||
pub opentelemetry: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub struct DavPushConfig {
|
||||
pub enable: bool,
|
||||
#[serde(default)]
|
||||
// Allowed Push servers, accepts any by default
|
||||
// Specify as URL origins
|
||||
pub allowed_push_servers: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl Default for DavPushConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enable: true,
|
||||
allowed_push_servers: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Config {
|
||||
@@ -54,4 +73,6 @@ pub struct Config {
|
||||
pub frontend: FrontendConfig,
|
||||
#[serde(default)]
|
||||
pub tracing: TracingConfig,
|
||||
#[serde(default)]
|
||||
pub dav_push: DavPushConfig,
|
||||
}
|
||||
|
||||
@@ -82,7 +82,13 @@ async fn main() -> Result<()> {
|
||||
let (addr_store, cal_store, subscription_store, update_recv) =
|
||||
get_data_stores(!args.no_migrations, &config.data_store).await?;
|
||||
|
||||
tokio::spawn(push_notifier(update_recv, subscription_store.clone()));
|
||||
if config.dav_push.enable {
|
||||
tokio::spawn(push_notifier(
|
||||
config.dav_push.allowed_push_servers,
|
||||
update_recv,
|
||||
subscription_store.clone(),
|
||||
));
|
||||
}
|
||||
|
||||
let user_store = Arc::new(match config.auth {
|
||||
config::AuthConfig::Static(config) => StaticUserStore::new(config),
|
||||
|
||||
Reference in New Issue
Block a user