Compare commits

..

9 Commits

Author SHA1 Message Date
Lennart
da72aa26cb update README.md 2026-01-24 22:53:51 +01:00
Lennart
b89ff1a2b5 version 0.12.3 2026-01-24 22:49:02 +01:00
Lennart
246a1aa738 Add truncation for automatically derived timezones 2026-01-24 22:48:08 +01:00
Lennart
bb0484ac4a version 0.12.2 2026-01-24 20:09:42 +01:00
Lennart
1b3da2a99b update caldata-rs 2026-01-24 20:07:38 +01:00
Lennart
3b01ae1cf6 update test snapshots 2026-01-24 19:52:13 +01:00
Lennart K
d918a255a9 PUT calendar_object: Allow omission of timezones as in RFC7809 2026-01-24 19:44:58 +01:00
Lennart K
6a31d3000c Update vtimezones-rs 2026-01-24 18:05:42 +01:00
Lennart K
d5892ab56b Migrate ical-rs to caldata-rs 2026-01-22 11:01:00 +01:00
42 changed files with 247 additions and 175 deletions

142
Cargo.lock generated
View File

@@ -181,9 +181,9 @@ dependencies = [
[[package]]
name = "askama_web"
version = "0.15.0"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0d6576f8e59513752a3e2673ca602fb403be7d0d0aacba5cd8b219838ab58fe"
checksum = "5911a65ac3916ef133167a855d52978f9fbf54680a093e0ef29e20b7e94a4523"
dependencies = [
"askama",
"askama_web_derive",
@@ -565,6 +565,24 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
[[package]]
name = "caldata"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36de4a8034d98c95e7fe874b828272d823cfbd68e9571fe7bf6c419e852cbe2"
dependencies = [
"chrono",
"chrono-tz",
"derive_more",
"itertools 0.14.0",
"lazy_static",
"phf 0.13.1",
"regex",
"rrule",
"thiserror 2.0.18",
"vtimezones-rs",
]
[[package]]
name = "cast"
version = "0.3.0"
@@ -573,9 +591,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.2.53"
version = "1.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932"
checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -1768,22 +1786,6 @@ dependencies = [
"cc",
]
[[package]]
name = "ical"
version = "0.12.0-dev"
source = "git+https://github.com/lennart-k/ical-rs?rev=f1ad6456fd6cbd1e6da095297febddd2cfe61422#f1ad6456fd6cbd1e6da095297febddd2cfe61422"
dependencies = [
"chrono",
"chrono-tz",
"derive_more",
"itertools 0.14.0",
"lazy_static",
"phf 0.13.1",
"regex",
"rrule",
"thiserror 2.0.18",
]
[[package]]
name = "icu_collections"
version = "2.1.1"
@@ -2025,9 +2027,9 @@ checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
[[package]]
name = "libm"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libredox"
@@ -2200,9 +2202,9 @@ dependencies = [
[[package]]
name = "num-conv"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050"
[[package]]
name = "num-integer"
@@ -2610,22 +2612,12 @@ dependencies = [
[[package]]
name = "phf_codegen"
version = "0.12.1"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbdcb6f01d193b17f0b9c3360fa7e0e620991b193ff08702f78b3ce365d7e61"
checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1"
dependencies = [
"phf_generator 0.12.1",
"phf_shared 0.12.1",
]
[[package]]
name = "phf_generator"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cbb1126afed61dd6368748dae63b1ee7dc480191c6262a3b4ff1e29d86a6c5b"
dependencies = [
"fastrand",
"phf_shared 0.12.1",
"phf_generator",
"phf_shared 0.13.1",
]
[[package]]
@@ -2644,7 +2636,7 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef"
dependencies = [
"phf_generator 0.13.1",
"phf_generator",
"phf_shared 0.13.1",
"proc-macro2",
"quote",
@@ -2825,9 +2817,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.105"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
@@ -2934,9 +2926,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.43"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
dependencies = [
"proc-macro2",
]
@@ -3317,18 +3309,18 @@ dependencies = [
[[package]]
name = "rustical"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"anyhow",
"argon2",
"async-trait",
"axum",
"axum-extra",
"caldata",
"clap",
"figment",
"headers",
"http",
"ical",
"insta",
"opentelemetry",
"opentelemetry-otlp",
@@ -3364,20 +3356,20 @@ dependencies = [
[[package]]
name = "rustical_caldav"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-std",
"async-trait",
"axum",
"axum-extra",
"base64 0.22.1",
"caldata",
"chrono",
"chrono-tz",
"derive_more",
"futures-util",
"headers",
"http",
"ical",
"insta",
"percent-encoding",
"quick-xml",
@@ -3406,17 +3398,17 @@ dependencies = [
[[package]]
name = "rustical_carddav"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-trait",
"axum",
"axum-extra",
"base64 0.22.1",
"caldata",
"chrono",
"derive_more",
"futures-util",
"http",
"ical",
"insta",
"percent-encoding",
"quick-xml",
@@ -3440,16 +3432,16 @@ dependencies = [
[[package]]
name = "rustical_dav"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-trait",
"axum",
"axum-extra",
"caldata",
"derive_more",
"futures-util",
"headers",
"http",
"ical",
"itertools 0.14.0",
"log",
"matchit 0.9.1",
@@ -3466,7 +3458,7 @@ dependencies = [
[[package]]
name = "rustical_dav_push"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-trait",
"axum",
@@ -3491,7 +3483,7 @@ dependencies = [
[[package]]
name = "rustical_frontend"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"askama",
"askama_web",
@@ -3527,13 +3519,13 @@ dependencies = [
[[package]]
name = "rustical_ical"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"axum",
"caldata",
"chrono",
"chrono-tz",
"derive_more",
"ical",
"regex",
"rrule",
"rstest",
@@ -3546,7 +3538,7 @@ dependencies = [
[[package]]
name = "rustical_oidc"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-trait",
"axum",
@@ -3562,11 +3554,12 @@ dependencies = [
[[package]]
name = "rustical_store"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"anyhow",
"async-trait",
"axum",
"caldata",
"chrono",
"chrono-tz",
"clap",
@@ -3574,7 +3567,6 @@ dependencies = [
"futures-core",
"headers",
"http",
"ical",
"regex",
"rrule",
"rstest",
@@ -3595,13 +3587,13 @@ dependencies = [
[[package]]
name = "rustical_store_sqlite"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"async-trait",
"caldata",
"chrono",
"criterion",
"derive_more",
"ical",
"password-auth",
"password-hash",
"pbkdf2",
@@ -3620,7 +3612,7 @@ dependencies = [
[[package]]
name = "rustical_xml"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"quick-xml",
"thiserror 2.0.18",
@@ -3980,9 +3972,9 @@ dependencies = [
[[package]]
name = "socket2"
version = "0.6.1"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881"
checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
dependencies = [
"libc",
"windows-sys 0.60.2",
@@ -4356,9 +4348,9 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.45"
version = "0.3.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd"
checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5"
dependencies = [
"deranged",
"itoa",
@@ -4371,15 +4363,15 @@ dependencies = [
[[package]]
name = "time-core"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca"
checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
[[package]]
name = "time-macros"
version = "0.2.25"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd"
checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4"
dependencies = [
"num-conv",
"time-core",
@@ -4951,12 +4943,12 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "vtimezones-rs"
version = "0.2.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6728de8767c8dea44f41b88115a205ed23adc3302e1b4342be59d922934dae5"
checksum = "1e4e9cf6888a927b6cec4aa2416f379885b92dd2aa4476bc83718fe58051f67e"
dependencies = [
"glob",
"phf 0.12.1",
"phf 0.13.1",
"phf_codegen",
]
@@ -5442,7 +5434,7 @@ checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
[[package]]
name = "xml_derive"
version = "0.12.1"
version = "0.12.3"
dependencies = [
"darling 0.23.0",
"heck",
@@ -5563,6 +5555,6 @@ dependencies = [
[[package]]
name = "zmij"
version = "1.0.15"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65"

View File

@@ -2,7 +2,7 @@
members = ["crates/*"]
[workspace.package]
version = "0.12.1"
version = "0.12.3"
rust-version = "1.92"
edition = "2024"
description = "A CalDAV server"
@@ -107,9 +107,7 @@ strum = "0.27"
strum_macros = "0.27"
serde_json = { version = "1.0", features = ["raw_value"] }
sqlx-sqlite = { version = "0.8", features = ["bundled"] }
ical = { git = "https://github.com/lennart-k/ical-rs", rev = "f1ad6456fd6cbd1e6da095297febddd2cfe61422", features = [
"chrono-tz",
] }
caldata = { version = "0.14.0", features = ["chrono-tz", "vtimezones-rs"] }
toml = "0.9"
tower = "0.5"
tower-http = { version = "0.6", features = [
@@ -139,7 +137,7 @@ reqwest = { version = "0.12", features = [
openidconnect = "4.0"
clap = { version = "4.5", features = ["derive", "env"] }
matchit-serde = { git = "https://github.com/lennart-k/matchit-serde", rev = "e18e65d7" }
vtimezones-rs = "0.2"
vtimezones-rs = "0.3"
ece = { version = "2.3", default-features = false, features = [
"backend-openssl",
] }
@@ -161,7 +159,7 @@ rustical_store_sqlite.workspace = true
rustical_caldav.workspace = true
rustical_carddav.workspace = true
rustical_frontend.workspace = true
ical.workspace = true
caldata.workspace = true
toml.workspace = true
serde.workspace = true
tokio.workspace = true

View File

@@ -24,6 +24,7 @@ a CalDAV/CardDAV server
- Apple configuration profiles (skip copy-pasting passwords and instead generate the configuration in the frontend)
- **OpenID Connect** support (with option to disable password login)
- Group-based **sharing**
- Partial [RFC 7809](https://datatracker.ietf.org/doc/html/rfc7809) support. RustiCal will accept timezones by reference and handle omitted timezones in objects.
## Getting Started

View File

@@ -34,7 +34,7 @@ rustical_store.workspace = true
chrono.workspace = true
chrono-tz.workspace = true
sha2.workspace = true
ical.workspace = true
caldata.workspace = true
percent-encoding.workspace = true
rustical_xml.workspace = true
uuid.workspace = true

View File

@@ -3,11 +3,11 @@ use crate::calendar::CalendarResourceService;
use axum::body::Body;
use axum::extract::State;
use axum::{extract::Path, response::Response};
use caldata::component::IcalCalendar;
use caldata::generator::Emitter;
use caldata::parser::ContentLine;
use headers::{ContentType, HeaderMapExt};
use http::{HeaderValue, Method, StatusCode, header};
use ical::component::IcalCalendar;
use ical::generator::Emitter;
use ical::property::ContentLine;
use percent_encoding::{CONTROLS, utf8_percent_encode};
use rustical_store::{CalendarStore, SubscriptionStore, auth::Principal};
use std::str::FromStr;

View File

@@ -4,8 +4,9 @@ use axum::{
extract::{Path, State},
response::{IntoResponse, Response},
};
use caldata::component::{Component, ComponentMut};
use caldata::{IcalParser, parser::ParserOptions};
use http::StatusCode;
use ical::parser::{Component, ComponentMut};
use rustical_dav::header::Overwrite;
use rustical_ical::CalendarObjectType;
use rustical_store::{
@@ -25,7 +26,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
return Err(Error::Unauthorized);
}
let parser = ical::IcalParser::from_slice(body.as_bytes());
let parser = IcalParser::from_slice(body.as_bytes());
let mut cal = match parser.expect_one() {
Ok(cal) => cal.mutable(),
Err(err) => return Ok((StatusCode::BAD_REQUEST, err.to_string()).into_response()),
@@ -49,7 +50,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
cal.remove_property("X-WR-CALDESC");
cal.remove_property("X-WR-CALCOLOR");
cal.remove_property("X-WR-TIMEZONE");
let cal = cal.build(None).unwrap();
let cal = cal.build(&ParserOptions::default(), None).unwrap();
// Make sure timezone is valid
if let Some(timezone_id) = timezone_id.as_ref() {

View File

@@ -6,8 +6,8 @@ use crate::calendar::prop::SupportedCalendarComponentSet;
use crate::error::Precondition;
use axum::extract::{Path, State};
use axum::response::{IntoResponse, Response};
use caldata::IcalParser;
use http::{Method, StatusCode};
use ical::IcalParser;
use rustical_dav::xml::HrefElement;
use rustical_ical::CalendarObjectType;
use rustical_store::auth::Principal;

View File

@@ -2,9 +2,12 @@ use crate::calendar::methods::report::calendar_query::{
TimeRangeElement,
prop_filter::{PropFilterElement, PropFilterable},
};
use ical::{
component::{CalendarInnerData, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTodo},
parser::{Component, ical::component::IcalTimeZone},
use caldata::{
component::{
CalendarInnerData, Component, IcalAlarm, IcalCalendarObject, IcalEvent, IcalTimeZone,
IcalTodo,
},
parser::ContentLine,
};
use rustical_xml::XmlDeserialize;
@@ -112,10 +115,7 @@ impl CompFilterable for CalendarInnerData {
}
impl PropFilterable for IcalAlarm {
fn get_named_properties<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
Component::get_named_properties(self, name)
}
}
@@ -139,7 +139,7 @@ impl PropFilterable for CalendarInnerData {
fn get_named_properties<'a>(
&'a self,
name: &'a str,
) -> Box<dyn Iterator<Item = &'a ical::property::ContentLine> + 'a> {
) -> Box<dyn Iterator<Item = &'a ContentLine> + 'a> {
// TODO: If we were pedantic, we would have to do recurrence expansion first
// and take into account the overrides :(
match self {
@@ -151,10 +151,7 @@ impl PropFilterable for CalendarInnerData {
}
impl PropFilterable for IcalCalendarObject {
fn get_named_properties<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
Component::get_named_properties(self, name)
}
}
@@ -185,10 +182,7 @@ impl CompFilterable for IcalCalendarObject {
}
impl PropFilterable for IcalTimeZone {
fn get_named_properties<'a>(
&'a self,
name: &'a str,
) -> impl Iterator<Item = &'a ical::property::ContentLine> {
fn get_named_properties<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a ContentLine> {
Component::get_named_properties(self, name)
}
}

View File

@@ -1,6 +1,6 @@
use super::comp_filter::{CompFilterElement, CompFilterable};
use crate::calendar_object::CalendarObjectPropWrapperName;
use ical::{component::IcalCalendarObject, property::ContentLine};
use caldata::{component::IcalCalendarObject, parser::ContentLine};
use rustical_dav::xml::{PropfindType, TextMatchElement};
use rustical_ical::UtcDateTime;
use rustical_store::calendar_store::CalendarQuery;

View File

@@ -1,5 +1,5 @@
use super::{ParamFilterElement, TimeRangeElement};
use ical::{property::ContentLine, types::CalDateTime};
use caldata::{parser::ContentLine, types::CalDateTime};
use rustical_dav::xml::TextMatchElement;
use rustical_ical::UtcDateTime;
use rustical_xml::XmlDeserialize;

View File

@@ -1,10 +1,10 @@
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
use crate::Error;
use crate::calendar::prop::{ReportMethod, SupportedCollationSet};
use caldata::IcalParser;
use caldata::types::CalDateTime;
use chrono::{DateTime, Utc};
use derive_more::derive::{From, Into};
use ical::IcalParser;
use ical::types::CalDateTime;
use rustical_dav::extensions::{
CommonPropertiesExtension, CommonPropertiesProp, SyncTokenExtension, SyncTokenExtensionProp,
};

View File

@@ -6,7 +6,7 @@ use crate::calendar::methods::report::route_report_calendar;
use crate::calendar::resource::CalendarResource;
use crate::calendar_object::CalendarObjectResourceService;
use crate::calendar_object::resource::CalendarObjectResource;
use crate::{CalDavPrincipalUri, Error};
use crate::{CalDavConfig, CalDavPrincipalUri, Error};
use async_trait::async_trait;
use axum::Router;
use axum::extract::Request;
@@ -23,6 +23,7 @@ use tower::Service;
pub struct CalendarResourceService<C: CalendarStore, S: SubscriptionStore> {
pub(crate) cal_store: Arc<C>,
pub(crate) sub_store: Arc<S>,
pub(crate) config: Arc<CalDavConfig>,
}
impl<C: CalendarStore, S: SubscriptionStore> Clone for CalendarResourceService<C, S> {
@@ -30,15 +31,17 @@ impl<C: CalendarStore, S: SubscriptionStore> Clone for CalendarResourceService<C
Self {
cal_store: self.cal_store.clone(),
sub_store: self.sub_store.clone(),
config: self.config.clone(),
}
}
}
impl<C: CalendarStore, S: SubscriptionStore> CalendarResourceService<C, S> {
pub const fn new(cal_store: Arc<C>, sub_store: Arc<S>) -> Self {
pub const fn new(cal_store: Arc<C>, sub_store: Arc<S>, config: Arc<CalDavConfig>) -> Self {
Self {
cal_store,
sub_store,
config,
}
}
}
@@ -112,7 +115,8 @@ impl<C: CalendarStore, S: SubscriptionStore> ResourceService for CalendarResourc
Router::new()
.nest(
"/{object_id}",
CalendarObjectResourceService::new(self.cal_store.clone()).axum_router(),
CalendarObjectResourceService::new(self.cal_store.clone(), self.config.clone())
.axum_router(),
)
.route_service("/", self.axum_service())
}

View File

@@ -12,7 +12,7 @@ PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
LAST-MODIFIED:20250723T190331Z
LAST-MODIFIED:20260124T185655Z
X-LIC-LOCATION:Europe/Berlin
X-PROLEPTIC-TZNAME:LMT
BEGIN:STANDARD

View File

@@ -5,6 +5,7 @@ use axum::body::Body;
use axum::extract::{Path, State};
use axum::response::{IntoResponse, Response};
use axum_extra::TypedHeader;
use caldata::parser::ParserOptions;
use headers::{ContentType, ETag, HeaderMapExt, IfNoneMatch};
use http::{HeaderMap, HeaderValue, Method, StatusCode};
use rustical_ical::CalendarObject;
@@ -20,7 +21,10 @@ pub async fn get_event<C: CalendarStore>(
calendar_id,
object_id,
}): Path<CalendarObjectPathComponents>,
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
State(CalendarObjectResourceService {
cal_store,
config: _,
}): State<CalendarObjectResourceService<C>>,
user: Principal,
method: Method,
) -> Result<Response, Error> {
@@ -57,7 +61,9 @@ pub async fn put_event<C: CalendarStore>(
calendar_id,
object_id,
}): Path<CalendarObjectPathComponents>,
State(CalendarObjectResourceService { cal_store }): State<CalendarObjectResourceService<C>>,
State(CalendarObjectResourceService { cal_store, config }): State<
CalendarObjectResourceService<C>,
>,
user: Principal,
mut if_none_match: Option<TypedHeader<IfNoneMatch>>,
header_map: HeaderMap,
@@ -94,7 +100,12 @@ pub async fn put_event<C: CalendarStore>(
true
};
let object = match CalendarObject::from_ics(body.clone()) {
let object = match CalendarObject::import(
&body,
Some(ParserOptions {
rfc7809: config.rfc7809,
}),
) {
Ok(object) => object,
Err(err) => {
warn!("invalid calendar data:\n{body}");

View File

@@ -3,8 +3,8 @@ use super::prop::{
CalendarObjectPropWrapperName,
};
use crate::Error;
use caldata::generator::Emitter;
use derive_more::derive::{From, Into};
use ical::generator::Emitter;
use rustical_dav::{
extensions::CommonPropertiesExtension,
privileges::UserPrivilegeSet,

View File

@@ -1,5 +1,5 @@
use crate::{
CalDavPrincipalUri, Error,
CalDavConfig, CalDavPrincipalUri, Error,
calendar_object::{
methods::{get_event, put_event},
resource::CalendarObjectResource,
@@ -24,19 +24,21 @@ pub struct CalendarObjectPathComponents {
pub struct CalendarObjectResourceService<C: CalendarStore> {
pub(crate) cal_store: Arc<C>,
pub(crate) config: Arc<CalDavConfig>,
}
impl<C: CalendarStore> Clone for CalendarObjectResourceService<C> {
fn clone(&self) -> Self {
Self {
cal_store: self.cal_store.clone(),
config: self.config.clone(),
}
}
}
impl<C: CalendarStore> CalendarObjectResourceService<C> {
pub const fn new(cal_store: Arc<C>) -> Self {
Self { cal_store }
pub const fn new(cal_store: Arc<C>, config: Arc<CalDavConfig>) -> Self {
Self { cal_store, config }
}
}

View File

@@ -8,6 +8,7 @@ use rustical_dav::resources::RootResourceService;
use rustical_store::auth::middleware::AuthenticationLayer;
use rustical_store::auth::{AuthenticationProvider, Principal};
use rustical_store::{CalendarStore, SubscriptionStore};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
pub mod calendar;
@@ -34,6 +35,7 @@ pub fn caldav_router<AP: AuthenticationProvider, C: CalendarStore, S: Subscripti
store: Arc<C>,
subscription_store: Arc<S>,
simplified_home_set: bool,
config: Arc<CalDavConfig>,
) -> Router {
Router::new().nest(
prefix,
@@ -42,9 +44,27 @@ pub fn caldav_router<AP: AuthenticationProvider, C: CalendarStore, S: Subscripti
sub_store: subscription_store,
cal_store: store,
simplified_home_set,
config,
})
.axum_router()
.layer(AuthenticationLayer::new(auth_provider))
.layer(Extension(CalDavPrincipalUri(prefix))),
)
}
const fn default_true() -> bool {
true
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct CalDavConfig {
#[serde(default = "default_true")]
rfc7809: bool,
}
impl Default for CalDavConfig {
fn default() -> Self {
Self { rfc7809: true }
}
}

View File

@@ -1,7 +1,7 @@
use crate::calendar::CalendarResourceService;
use crate::calendar::resource::CalendarResource;
use crate::principal::PrincipalResource;
use crate::{CalDavPrincipalUri, Error};
use crate::{CalDavConfig, CalDavPrincipalUri, Error};
use async_trait::async_trait;
use axum::Router;
use rustical_dav::resource::{AxumMethods, ResourceService};
@@ -20,6 +20,7 @@ pub struct PrincipalResourceService<
pub(crate) cal_store: Arc<CS>,
// If true only return the principal as the calendar home set, otherwise also groups
pub(crate) simplified_home_set: bool,
pub(crate) config: Arc<CalDavConfig>,
}
impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
@@ -31,6 +32,7 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Clone
sub_store: self.sub_store.clone(),
cal_store: self.cal_store.clone(),
simplified_home_set: self.simplified_home_set,
config: self.config.clone(),
}
}
}
@@ -84,8 +86,12 @@ impl<AP: AuthenticationProvider, S: SubscriptionStore, CS: CalendarStore> Resour
Router::new()
.nest(
"/{calendar_id}",
CalendarResourceService::new(self.cal_store.clone(), self.sub_store.clone())
.axum_router(),
CalendarResourceService::new(
self.cal_store.clone(),
self.sub_store.clone(),
self.config.clone(),
)
.axum_router(),
)
.route_service("/", self.axum_service())
}

View File

@@ -27,6 +27,7 @@ async fn test_principal_resource(
sub_store: Arc::new(sub_store),
auth_provider: Arc::new(auth_provider),
simplified_home_set: false,
config: Default::default(),
};
// We don't have any calendars here

View File

@@ -32,7 +32,7 @@ rustical_ical.workspace = true
http.workspace = true
tower-http.workspace = true
percent-encoding.workspace = true
ical.workspace = true
caldata.workspace = true
strum.workspace = true
strum_macros.workspace = true
rstest.workspace = true

View File

@@ -7,8 +7,8 @@ use crate::{
AddressObjectPropWrapperName,
},
};
use caldata::property::VcardFNProperty;
use derive_more::derive::{From, Into};
use ical::parser::VcardFNProperty;
use rustical_dav::{
extensions::CommonPropertiesExtension,
privileges::UserPrivilegeSet,

View File

@@ -4,11 +4,12 @@ use axum::{
extract::{Path, State},
response::{IntoResponse, Response},
};
use http::StatusCode;
use ical::{
parser::{Component, ComponentMut, vcard},
property::ContentLine,
use caldata::{
VcardParser,
component::{Component, ComponentMut},
parser::{ContentLine, ParserOptions},
};
use http::StatusCode;
use rustical_store::{Addressbook, AddressbookStore, SubscriptionStore, auth::Principal};
use tracing::instrument;
@@ -23,7 +24,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
return Err(Error::Unauthorized);
}
let parser = vcard::VcardParser::from_slice(body.as_bytes());
let parser = VcardParser::from_slice(body.as_bytes());
let mut objects = vec![];
for res in parser {
@@ -36,7 +37,7 @@ pub async fn route_import<AS: AddressbookStore, S: SubscriptionStore>(
value: Some(uuid::Uuid::new_v4().to_string()),
params: vec![].into(),
});
card = card_mut.build(None).unwrap();
card = card_mut.build(&ParserOptions::default(), None).unwrap();
}
// TODO: Make nicer
let uid = card.get_uid().unwrap();

View File

@@ -2,8 +2,8 @@ use crate::{
address_object::AddressObjectPropWrapperName,
addressbook::methods::report::addressbook_query::PropFilterElement,
};
use caldata::parser::ContentLine;
use derive_more::{From, Into};
use ical::property::ContentLine;
use rustical_dav::xml::{PropfindType, TextMatchElement};
use rustical_ical::{AddressObject, UtcDateTime};
use rustical_xml::{ValueDeserialize, XmlDeserialize, XmlRootTag};

View File

@@ -1,5 +1,5 @@
use super::{Allof, ParamFilterElement};
use ical::{parser::Component, property::ContentLine};
use caldata::{component::Component, parser::ContentLine};
use rustical_dav::xml::TextMatchElement;
use rustical_ical::AddressObject;
use rustical_xml::XmlDeserialize;

View File

@@ -28,7 +28,7 @@ headers.workspace = true
strum.workspace = true
matchit.workspace = true
matchit-serde.workspace = true
ical = { workspace = true, optional = true }
caldata = { workspace = true, optional = true }
[features]
ical = ["dep:ical"]
ical = ["dep:caldata"]

View File

@@ -1,4 +1,4 @@
use ical::property::ContentLine;
use caldata::parser::ContentLine;
use rustical_xml::{ValueDeserialize, XmlDeserialize};
use std::borrow::Cow;

View File

@@ -15,7 +15,7 @@ chrono-tz.workspace = true
thiserror.workspace = true
derive_more.workspace = true
rustical_xml.workspace = true
ical.workspace = true
caldata.workspace = true
regex.workspace = true
rrule.workspace = true
serde.workspace = true

View File

@@ -1,20 +1,23 @@
use crate::{CalendarObject, Error};
use caldata::{
VcardParser,
component::{
CalendarInnerDataBuilder, ComponentMut, IcalAlarmBuilder, IcalCalendarObjectBuilder,
IcalEventBuilder, VcardContact,
},
generator::Emitter,
parser::{ContentLine, ParserOptions},
property::{
Calscale, IcalCALSCALEProperty, IcalDTENDProperty, IcalDTSTAMPProperty,
IcalDTSTARTProperty, IcalPRODIDProperty, IcalRRULEProperty, IcalSUMMARYProperty,
IcalUIDProperty, IcalVERSIONProperty, IcalVersion, VcardANNIVERSARYProperty,
VcardBDAYProperty, VcardFNProperty,
},
types::{CalDate, PartialDate, Timezone},
};
use chrono::{NaiveDate, Utc};
use ical::component::{
CalendarInnerDataBuilder, IcalAlarmBuilder, IcalCalendarObjectBuilder, IcalEventBuilder,
};
use ical::generator::Emitter;
use ical::parser::vcard::{self, component::VcardContact};
use ical::parser::{
Calscale, ComponentMut, IcalCALSCALEProperty, IcalDTENDProperty, IcalDTSTAMPProperty,
IcalDTSTARTProperty, IcalPRODIDProperty, IcalRRULEProperty, IcalSUMMARYProperty,
IcalUIDProperty, IcalVERSIONProperty, IcalVersion, VcardANNIVERSARYProperty, VcardBDAYProperty,
VcardFNProperty,
};
use ical::property::ContentLine;
use ical::types::{CalDate, PartialDate};
use sha2::{Digest, Sha256};
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::str::FromStr;
#[derive(Debug, Clone)]
@@ -32,7 +35,7 @@ impl From<VcardContact> for AddressObject {
impl AddressObject {
pub fn from_vcf(vcf: String) -> Result<Self, Error> {
let parser = vcard::VcardParser::from_slice(vcf.as_bytes());
let parser = VcardParser::from_slice(vcf.as_bytes());
let vcard = parser.expect_one()?;
Ok(Self { vcf, vcard })
}
@@ -70,7 +73,7 @@ impl AddressObject {
let Some(dtstart) = NaiveDate::from_ymd_opt(year.unwrap_or(1900), month, day) else {
return Ok(None);
};
let start_date = CalDate(dtstart, ical::types::Timezone::Local);
let start_date = CalDate(dtstart, Timezone::Local);
let Some(end_date) = start_date.succ_opt() else {
// start_date is MAX_DATE, this should never happen but FAPP also not raise an error
return Ok(None);
@@ -131,9 +134,9 @@ impl AddressObject {
.into(),
],
inner: Some(CalendarInnerDataBuilder::Event(vec![event])),
vtimezones: HashMap::default(),
vtimezones: BTreeMap::default(),
}
.build(None)?
.build(&ParserOptions::default(), None)?
.into(),
))
}

View File

@@ -1,9 +1,13 @@
use std::sync::OnceLock;
use crate::Error;
use caldata::{
IcalObjectParser,
component::{CalendarInnerData, IcalCalendarObject},
generator::Emitter,
parser::ParserOptions,
};
use derive_more::Display;
use ical::IcalObjectParser;
use ical::component::CalendarInnerData;
use ical::component::IcalCalendarObject;
use ical::generator::Emitter;
use serde::Deserialize;
use serde::Serialize;
use sha2::{Digest, Sha256};
@@ -64,15 +68,35 @@ impl rustical_xml::ValueDeserialize for CalendarObjectType {
#[derive(Debug, Clone)]
pub struct CalendarObject {
inner: IcalCalendarObject,
ics: String,
ics: OnceLock<String>,
}
impl CalendarObject {
// This function parses iCalendar data but doesn't cache it
// This is meant for iCalendar data coming from outside that might need to be normalised.
// For example if timezones are omitted this can be fixed by this function.
pub fn import(ics: &str, options: Option<ParserOptions>) -> Result<Self, Error> {
let parser =
IcalObjectParser::from_slice(ics.as_bytes()).with_options(options.unwrap_or_default());
let inner = parser.expect_one()?;
Ok(Self {
inner,
ics: OnceLock::new(),
})
}
// This function parses iCalendar data and then caches the parsed iCalendar data.
// This function is only meant for loading data from a data store where we know the iCalendar
// is already in the desired form.
pub fn from_ics(ics: String) -> Result<Self, Error> {
let parser = IcalObjectParser::from_slice(ics.as_bytes());
let inner = parser.expect_one()?;
Ok(Self { inner, ics })
Ok(Self {
inner,
ics: ics.into(),
})
}
#[must_use]
@@ -95,7 +119,7 @@ impl CalendarObject {
#[must_use]
pub fn get_ics(&self) -> &str {
&self.ics
self.ics.get_or_init(|| self.inner.generate())
}
#[must_use]
@@ -113,7 +137,7 @@ impl From<CalendarObject> for IcalCalendarObject {
impl From<IcalCalendarObject> for CalendarObject {
fn from(value: IcalCalendarObject) -> Self {
Self {
ics: value.generate(),
ics: value.generate().into(),
inner: value,
}
}

View File

@@ -1,7 +1,7 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
mod timestamp;
use ical::parser::ParserError;
use caldata::parser::ParserError;
pub use timestamp::*;
mod calendar_object;

View File

@@ -13,7 +13,7 @@ anyhow.workspace = true
async-trait.workspace = true
serde.workspace = true
sha2.workspace = true
ical.workspace = true
caldata.workspace = true
chrono.workspace = true
regex.workspace = true
thiserror.workspace = true

View File

@@ -26,7 +26,7 @@ pub enum Error {
Other(#[from] anyhow::Error),
#[error(transparent)]
IcalError(#[from] ical::parser::ParserError),
IcalError(#[from] caldata::parser::ParserError),
}
impl Error {

View File

@@ -20,7 +20,7 @@ rstest.workspace = true
criterion.workspace = true
[dependencies]
ical.workspace = true
caldata.workspace = true
tokio.workspace = true
rustical_store.workspace = true
async-trait.workspace = true

View File

@@ -1,8 +1,8 @@
use super::ChangeOperation;
use crate::BEGIN_IMMEDIATE;
use async_trait::async_trait;
use caldata::parser::ParserError;
use derive_more::derive::Constructor;
use ical::parser::ParserError;
use rustical_ical::AddressObject;
use rustical_store::{
Addressbook, AddressbookStore, CollectionMetadata, CollectionOperation,

View File

@@ -1,10 +1,10 @@
use super::ChangeOperation;
use crate::BEGIN_IMMEDIATE;
use async_trait::async_trait;
use caldata::parser::ParserError;
use caldata::types::CalDateTime;
use chrono::TimeDelta;
use derive_more::derive::Constructor;
use ical::parser::ParserError;
use ical::types::CalDateTime;
use regex::Regex;
use rustical_ical::{CalendarObject, CalendarObjectType};
use rustical_store::calendar_store::CalendarQuery;

View File

@@ -9,7 +9,7 @@ use axum_extra::TypedHeader;
use headers::{HeaderMapExt, UserAgent};
use http::header::CONNECTION;
use http::{HeaderValue, StatusCode};
use rustical_caldav::caldav_router;
use rustical_caldav::{CalDavConfig, caldav_router};
use rustical_carddav::carddav_router;
use rustical_frontend::nextcloud_login::nextcloud_login_router;
use rustical_frontend::{FrontendConfig, frontend_router};
@@ -45,6 +45,7 @@ pub fn make_app<
auth_provider: Arc<impl AuthenticationProvider>,
frontend_config: FrontendConfig,
oidc_config: Option<OidcConfig>,
caldav_config: CalDavConfig,
nextcloud_login_config: &NextcloudLoginConfig,
dav_push_enabled: bool,
session_cookie_samesite_strict: bool,
@@ -54,6 +55,8 @@ pub fn make_app<
let combined_cal_store =
Arc::new(CombinedCalendarStore::new(cal_store).with_store(birthday_store));
let caldav_config = Arc::new(caldav_config);
let mut router = Router::new()
// endpoint to be used by healthcheck to see if rustical is online
.route("/ping", axum::routing::get(async || "Pong!"))
@@ -63,6 +66,7 @@ pub fn make_app<
combined_cal_store.clone(),
subscription_store.clone(),
false,
caldav_config.clone(),
))
.merge(caldav_router(
"/caldav-compat",
@@ -70,6 +74,7 @@ pub fn make_app<
combined_cal_store.clone(),
subscription_store.clone(),
true,
caldav_config,
))
.route(
"/.well-known/caldav",

View File

@@ -3,6 +3,7 @@ use crate::config::{
SqliteDataStoreConfig, TracingConfig,
};
use clap::Parser;
use rustical_caldav::CalDavConfig;
use rustical_frontend::FrontendConfig;
pub mod health;
@@ -15,6 +16,7 @@ pub struct GenConfigArgs {}
pub fn cmd_gen_config(_args: GenConfigArgs) -> anyhow::Result<()> {
let config = Config {
http: HttpConfig::default(),
caldav: CalDavConfig::default(),
data_store: DataStoreConfig::Sqlite(SqliteDataStoreConfig {
db_url: "/var/lib/rustical/db.sqlite3".to_owned(),
run_repairs: true,

View File

@@ -1,3 +1,4 @@
use rustical_caldav::CalDavConfig;
use rustical_frontend::FrontendConfig;
use rustical_oidc::OidcConfig;
use serde::{Deserialize, Serialize};
@@ -97,4 +98,6 @@ pub struct Config {
pub dav_push: DavPushConfig,
#[serde(default)]
pub nextcloud_login: NextcloudLoginConfig,
#[serde(default)]
pub caldav: CalDavConfig,
}

View File

@@ -8,7 +8,7 @@ expression: body
<href>/caldav/principal/user/calendar/qwue23489.ics</href>
<propstat>
<prop>
<getetag>&quot;aea50382a7775bb9742bfec277382e3a260b6066f503b5f5ae34548d7215ee46&quot;</getetag>
<getetag>&quot;f781224669f0db2674e9e45a9be2b01774c02136e3fb72792ef217bccf49fafa&quot;</getetag>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>

View File

@@ -14,9 +14,10 @@ expression: body
PRODID:-//github.com/lennart-k/vzic-rs//RustiCal Calendar server//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:America/New_York
LAST-MODIFIED:20250723T190331Z
X-LIC-LOCATION:America/New_York
TZID:US/Eastern
TZID-ALIAS-OF:America/New_York
LAST-MODIFIED:20260124T185655Z
X-LIC-LOCATION:US/Eastern
X-PROLEPTIC-TZNAME:LMT
BEGIN:STANDARD
TZNAME:EST

View File

@@ -2,6 +2,7 @@ use crate::{app::make_app, config::NextcloudLoginConfig};
use axum::extract::Request;
use axum::{body::Body, response::Response};
use rstest::rstest;
use rustical_caldav::CalDavConfig;
use rustical_frontend::FrontendConfig;
use rustical_store_sqlite::tests::{TestStoreContext, test_store_context};
use std::sync::Arc;
@@ -26,6 +27,7 @@ pub fn get_app(context: TestStoreContext) -> axum::Router {
allow_password_login: true,
},
None,
CalDavConfig::default(),
&NextcloudLoginConfig { enabled: false },
false,
true,

View File

@@ -153,6 +153,7 @@ async fn main() -> Result<()> {
principal_store.clone(),
config.frontend.clone(),
config.oidc.clone(),
config.caldav,
&config.nextcloud_login,
config.dav_push.enabled,
config.http.session_cookie_samesite_strict,