Commit Graph

59 Commits

Author SHA1 Message Date
757f4a8c2a
AddCurrentUserPrivilegeSet to find caldav 2024-09-26 20:53:10 +01:00
Thomas Müller
3ed9a4f052 carddav, caldav: add missing headers on PUT
ETag and Last-Modified should be set to the new calendar object or
address object properties.
2024-03-28 11:22:46 +01:00
Conrad Hoffmann
ad1fe1c5a8
caldav, carddav: displayname and desription are optional
Both the displayname and the description can be absent for both
calendars and address books. If this is the case they should not show up
in PROPFIND responses as empty string.
2024-02-08 17:15:04 +01:00
Thomas Müller
0ea114ec79
caldav: add MKCOL support 2024-02-08 17:08:41 +01:00
Dan Berglund
12d8b4bf62
caldav: return proper HTTP 501 instead of panicing
It seems like e.g. Apples reminders likes to send `PropPatch`, and
currently this just fills up my logs because of the panic. I thought it
would be better to signal that this isn't supported yet, which should
hopefully make it easier to dig through the logs.
2024-02-07 17:25:57 +01:00
Conrad Hoffmann
e3ba95cd77 caldav: add path to interface QueryCalendarObjects
This was missing for proper multi-calendar support.
2024-02-02 14:28:22 +01:00
Conrad Hoffmann
5b5b542f2f caldav: fix match on open time ranges
Matches on open time ranges (i.e. no end date) were not properly
handled, as `end` is simply the zero time, which confuses the
`.Before()` and `.After()` logic employed here.

This commit fixes that by adding the appropriate `.IsZero()` checks and
also adds a test case.

The current behavior unfortunately broke compatibility with DAVx5, which
by default queries only events less than 90 days ago (by using an open
time range).
2024-02-01 14:36:51 +01:00
Simon Ser
7e076258d6 caldav: add DiscoverContextURL 2023-12-27 23:16:49 +01:00
Simon Ser
379a418130 Add context for clients 2023-12-19 21:29:37 +01:00
Simon Ser
0e58dbb003 caldav, carddav: take header when populating object
References: https://github.com/emersion/go-webdav/pull/134
2023-12-18 18:18:56 +01:00
Simon Ser
fc4ea1aae2 caldav, carddav: drop unnecessary nil check
Closes: https://github.com/emersion/go-webdav/issues/92
2023-08-25 13:35:33 +02:00
Dan Berglund
571eba7c02
caldav: add multi-calendar support 2023-08-21 13:06:59 +02:00
Dan Berglund
7dd64908d2
caldav: handle PROPFIND on root
It seems like the Reminders app in iOS/macOS does this request as
the first thing when setting up an account, so it seems reasonable to
handle it for us.

This just returns the most basic current-user-principal now, but that
should hopefully be enough to continue the process.
2023-07-06 12:12:07 +02:00
Dan Berglund
46dbba12fe
caldav: return SupportedComponentSet in PROPFIND
I started using this project to export tasks over CalDav, more
specifically to Reminders on iOS/macOS. I quickly realized that
even if you specify that `SupportedComponentSet` contains `VTODO`, that
isn't reflected properly when doing the `PROPFIND`.

This patch should fix that, while keeping the behaviour of defaulting to
`VEVENT` for propfind. Also added some tests to make sure that I didn't
break anything (Which I hope I didn't 😅).
2023-07-03 10:47:34 +02:00
Conrad Hoffmann
0456b28ba3 Support setting capabilities in ServePrincipal()
This is done properly in the carddav and caldav packages, but the custom
function does not know what the user intends to serve, so it must be
passed in from the user. Without this, certain clients (e.g. DAVx5)
will be unable to discover endpoints served this way.

Also slightly extend the supported methods returned on OPTIONS requests.
REPORT is properly supported, the others are mostly for not giving
clients the impression that the resources are read-only.
2022-12-13 15:46:51 +01:00
Conrad Hoffmann
ac9af45270 Dedicated type for conditional match header fields
The `If-Match` and `If-None-Match` conditional headers can have either a
wildcard or a (quoted) ETag as value. However, the ETag _could_ be a
literal `*`, so care must be taken to allow these cases to be
distinguished. The values of these headers have to be handled by the
backend, so export a type that facilitates working with these values.
2022-11-22 11:58:13 +01:00
Conrad Hoffmann
5bfd6f54b2 caldav: use same static path layout as carddav 2022-11-16 10:37:40 +01:00
Conrad Hoffmann
54f2a6355b caldav: implement Propfind
It did not handle Depth or requests to calendar components. This brings
the implementation on par with the one CardDAV one.
2022-11-02 19:49:53 +01:00
Conrad Hoffmann
001e5953f7 caldav: support deletion of calendar objects
Has to be implemented by the backend.
2022-11-02 19:49:01 +01:00
Krystian Chachuła
6f22a649ac caldav: fix validation error when VTIMEZONE is after VEVENT 2022-09-16 09:04:14 +02:00
Conrad Hoffmann
dc63df9058 carddav: evaluate recurrence in match helper
The match helper will now properly return recurring events if any of
their recurrences fall into the queried time range. A test for this was
added as well.
2022-08-31 16:57:42 +02:00
Conrad Hoffmann
4264d321a5 caldav: fix match test example from RFC
See https://www.rfc-editor.org/errata/eid4164

The original RFC's appendix was missing a part of the calendar data used
in the examples. This will become relevant when adding tests for
retrieving recurring events.
2022-08-31 10:13:02 +02:00
Simon Ser
d7891ce50c internal: fix XML element struct naming
We were sometimes using TitleCase, sometimes Lowercase. Let's align
on the idiomatic Go naming and pick TitleCase everywhere.
2022-05-31 23:04:42 +02:00
Conrad Hoffmann
13fa812f94 caldav: implement filter function for queries
This is not yet complete (see TODOs in code), but basic filtering of a
list of CaledarObjects works.

Includes test data from the RFC, which allows to use the RFCs examples
as test cases.
2022-05-25 18:57:16 +02:00
Simon Ser
9ed4abce57 caldav: add Content-Length support to client
Follow-up for https://github.com/emersion/go-webdav/pull/83.
2022-05-24 10:47:40 +02:00
Conrad Hoffmann
757a615e9f caldav: set content length header for HEAD/GET requests
Now that the backend can supply this value, use it for explicitly
setting the header in GET/HEAD responses if available.
2022-05-24 10:08:32 +02:00
Conrad Hoffmann
491af8e42c caldav: add support for getcontentlength property
Allow the backend to provide a value for the `getcontentlength` property
as described in [RFC 2518 section 13.4][1].

The implementation treats is as optional, allthough it is a required
property per RFC. Most clients do perfectly fine without it, though.

Properly setting this in the backend makes the CalDAV collection
listable with clients that do require it, e.g. cadaver.

[1]: https://datatracker.ietf.org/doc/html/rfc2518#section-13.4
2022-05-24 10:08:32 +02:00
Conrad Hoffmann
b0c59cdea1 carddav/caldav: use 308 for .well-known redirects
This makes it a little less ambiguous (and, in case of Go clients, a lot
easier) that clients should follow the redirect by sending the same
PROPFIND request, including body, to the new location.

See also the documentation of [http.Client.Do()][1] and the comments in
[http.redirectBehavior()][2].

Confirmed to not make a difference for Evolution and Thunderbird
clients.

[1]: https://pkg.go.dev/net/http#Client.Do
[2]: https://cs.opensource.google/go/go/+/refs/tags/go1.18.2:src/net/http/client.go;drc=d8762b2f4532cc2e5ec539670b88bbc469a13938;l=502
2022-05-23 09:54:10 +02:00
Simon Ser
a346d42f42 caldav: only call CurrentUserPrincipal when necessary 2022-05-13 15:29:55 +02:00
Conrad Hoffmann
e971269ffb Add function to validate calendar for CalDAV
CalDAV imposes a set of constraints on iCal Calendar objects. They are
spelled out in RFC 4791, section 4.1 [1]. Add an exported function to
validate a calendar according to those constraints, and return data that
is necessary for further CalDAV processing and which can only be
extracted if the calendar meets these constraints.

[1]: https://datatracker.ietf.org/doc/html/rfc4791#section-4.1
2022-05-13 09:20:23 +02:00
Conrad Hoffmann
303aef52f3 caldav: implement handleMultiget()
The implementation has feature parity with the CardDAV one.
2022-05-12 17:32:30 +02:00
Conrad Hoffmann
585b01a7a8 Implement GET/HEAD/PUT for calendar objects
Still missing a few features, but works to a certain extend. Requires
an update to the backend interface to support the operations
2022-05-12 14:50:26 +02:00
Conrad Hoffmann
cdb0de3b99 Return calendar description in PROPFIND 2022-05-12 14:50:26 +02:00
Conrad Hoffmann
6887b6b812 Support custom user principal and home set paths
Currently, the user principal path and the home set path are both
hardcoded to "/", for both CalDAV and CardDAV. This poses a challenge if
one wishes to run a CardDAV and CalDAV server in the same server.

This commit introduces the concept of a UserPrincipalBackend. This
backend must provide the path of the current user's principal URL from
the given request context.

The CalDAV and CardDAV backends are extended to also function as
UserPrincipalBackend. In addition, they are required to supply the path
of the respective home set (`calendar-home-set` and
`addressbook-home-set`). The CardDAV and CalDAV servers act accordingly.

The individual servers will continue to work as before (including the
option of keeping everything at "/"). If one wishes to run CardDAV and
CalDAV in parallel, the new `webdav.ServeUserPrincipal()` can be used as
a convenience function to serve a common user principal URL for both
servers. The input for this function can be easily computed by the
application by getting the home set paths from the backends and using
`caldav.NewCalendarHomeSet()` and `carddav.NewAddressbookHomeSet()` to
create the home sets.

Note that the storage backend will have to know about these paths as
well. For any non-trivial use case, a storage backend should probably
have access to the same UserPrincipalBackend. That is, however, an
implementation detail and doesn't have to be reflected in the
interfaces.
2022-05-11 11:12:04 +02:00
Conrad Hoffmann
8931e14cf6 caldav: use Calendar.Path in PROPFIND response 2022-05-02 20:56:38 +02:00
Simon Ser
4e8c5effe3 Replace DAVError with HTTPError + Error
That way we can avoid having different ways of representing the
same error value.
2022-05-02 15:43:43 +02:00
Konstantinos Koukas
25dfbaf95e caldav: add supported-calendar-component-set field 2022-04-12 09:38:26 +02:00
Conrad Hoffmann
6401d9ed45 caldav: extend query filter types
The basic types related to queries and filtering are missing some
features specified in the RFC (as also noted in the TODO comments). This
adds several of the missing elements, working towards being able to
handle all RFC-compliant queries.

The work is not fully done, e.g. the collation for text-match is still
not handled, but it's getting pretty close.
2022-04-01 18:29:58 +02:00
Conrad Hoffmann
7dafedd290 Add type-safe precondition errors for CalDAV 2022-04-01 16:22:04 +02:00
Conrad Hoffmann
52215c1690 Pass request context to backend interface
This aligns the caldav interface with the carddav one (see #53).
2022-03-16 20:11:00 +01:00
Simon Ser
106d4e1c88 caldav: add basic server
A lot of features a still missing, but basic discovery works.

Co-authored-by: Conrad Hoffmann <ch@bitfehler.net>
2022-03-16 16:47:29 +01:00
Simon Ser
9caa4ff356 caldav: add support for reports
Co-authored-by: Conrad Hoffmann <ch@bitfehler.net>
2022-03-16 16:47:29 +01:00
Simon Ser
a4e0e81003
caldav: add Client.MultiGetCalendar 2020-05-13 16:45:25 +02:00
Simon Ser
5328b4c493
caldav: set Depth to 1 for calendar-query REPORT requests
SabreDAV chokes on an unset Depth header field.
2020-05-13 15:06:16 +02:00
Simon Ser
514296664c
caldav: upgrade to latest go-ical API 2020-02-24 21:16:45 +01:00
Simon Ser
4c419a961d
caldav: add Client.GetCalendarObject 2020-02-24 18:19:39 +01:00
Simon Ser
7bb9b3aa0b
caldav: add Client.PutCalendarObject 2020-02-24 18:13:24 +01:00
Simon Ser
07d4dfae5e
Use new ical library 2020-02-24 17:52:25 +01:00
Simon Ser
ddf2a85958
Introduce HTTPClient, remove Client.SetBasicAuth 2020-02-19 16:02:49 +01:00
Simon Ser
1d93353e3d
caldav: add prop-filter support to client 2020-02-05 18:38:46 +01:00