Commit Graph

270 Commits

Author SHA1 Message Date
Simon Ser
b821d8c1ea webdav: introduce MoveOptions 2024-01-18 13:28:50 +01:00
Simon Ser
790ebfc5f8 webdav: rename MoveAll to Move 2024-01-18 13:28:50 +01:00
Simon Ser
4493704689 webdav: introduce CopyOptions 2024-01-18 13:28:50 +01:00
Simon Ser
b043bbd965 internal/server: handle PROPFIND without body
See RFC 4918 section 9.1.
2024-01-08 14:58:24 +01:00
Simon Ser
75d3041b41 webdav: rename Client.Readdir to ReadDir
This is a more idiomatic name, and we've broken the API already
to add the ctx argument.
2024-01-08 14:35:56 +01:00
Simon Ser
751741d87e webdav: add/improve doc comments 2024-01-08 14:35:19 +01:00
Simon Ser
7e076258d6 caldav: add DiscoverContextURL 2023-12-27 23:16:49 +01:00
Simon Ser
174622c1eb carddav: rename Discover to DiscoverContextURL
This only performs part of the discovery process.
2023-12-27 23:11:51 +01:00
Simon Ser
d033e09835 webdav: add context to FileSystem 2023-12-19 21:29:54 +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
Sebastien Binet
7d337ac048 internal: fix always-true interface comparison
This CL corrects the following bug uncovered by staticcheck:

```
  internal/elements.go:148:6: this comparison is always true (SA4023)
    internal/elements.go:146:18: the lhs of the comparison gets its value from here and has a concrete type
```

Signed-off-by: Sebastien Binet <binet@cern.ch>
2023-12-15 15:07:59 +01:00
Simon Ser
dddaf279ed Upgrade dependencies 2023-09-10 14:52:02 +09: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
Simon Ser
b46cbafa6f
readme: switch back to pkg.go.dev for docs 2023-08-15 08:29:01 +02:00
Simon Ser
0fb0a675ab carddav: handle PROPFIND on root
Same as 7dd64908d2 ("caldav: handle PROPFIND on root") but for
CardDAV.
2023-07-06 12:14:17 +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
Simon Ser
150f74a6f0 Add GitHub issue template 2023-01-04 11:00:51 +01: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
d4d56c2707 carddav: use custom type for context keys 2022-11-16 10:37:40 +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
Conrad Hoffmann
561012d30f carddav: switch to one static path layout
See #100 for details. Obsoletes #99.
2022-11-02 19:44:42 +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
58dc8e4982 Update to latest version of go-ical
Needed for handling of recurring events.
2022-08-31 16:57:42 +02:00
Conrad Hoffmann
9adfd95fa9 carddav: run gofmt 2022-08-31 13:53:16 +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
Conrad Hoffmann
4a3cd0510f carddav: end-to-end test address book discovery
As the implementation evolves, it will be necessary to have more tests
to assert we don't break anything when making changes. This commit
introduces a test setup to test that server and client can handle the
address book discovery with various parameters. The test setup should be
easily extendable to cover even more ground as needed.
2022-07-13 08:45:11 +02:00
Simon Ser
987c9eef0b carddav: use "/.well-known/carddav/" as initial context path in Discover
See RFC 6764 section 6 item 3.
2022-07-13 08:43:40 +02:00
myml
e0764c06a3 fix: Response body was not closed causing the goroutine leak 2022-06-20 08:59:55 +02:00
Conrad Hoffmann
db966a275c carddav: do property filtering in match.Filter()
With this commit, the list of AddressObjects returned by `Filter()` will
always be a correct response to the query argument passed to it, even if
the input list contained objects with arbitraty properties present.
2022-06-03 08:36:05 +02:00
Conrad Hoffmann
21aea26c70 carddav: don't filter properties in test queries
As is, the tests in `match_test.go` test wrong behavior. They request
"partial retrieval" (i.e. filtering of returned properties), but compare
the returned result to the original input. They essentially rely on the
fact that property filtering is currently not implemented.

To fix this, simply make all existing test queries request all
properties. If property filtering gets implemented (correctly), the
tests will then continue to work. New tests can be added for testing
the property filtering itself.
2022-06-03 08:36:05 +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
Simon Ser
55a9274ba6 internal: use Namespace instead of "DAV:" 2022-05-31 17:10:30 +02:00
Simon Ser
1c71a7a1c4 internal: add more context to Response.DecodeProp errors 2022-05-31 17:04:44 +02:00
Simon Ser
d0fc22a428 internal: use errors.As in IsNotFound
Allows it to work properly with wrapped errors.
2022-05-31 16:58:45 +02:00
Simon Ser
9bc7a8f15b internal: drop Multistatus.Get
This is now unused.
2022-05-31 16:11:08 +02:00
Conrad Hoffmann
03633121d9 client: support redirects in PropfindFlat()
One common method for CalDAV or CardDAV clients to find the current user
principal URL is to request the `/.well-known` URL (see [RFC 6764,
section 6][1]), expecting a redirect. Such URL is for example a valid
result of the discovery phase described in that RFC. The expectation is
that a client, given such URL, is able to find the principal URL by
following a redirect when sending a PROPFIND request.

This change makes `PropfindFlat()` (and, by extension,
`FindCurrentUserPrincipal()`) handle such a redirect and correctly
return the requested properties, even if their HREF is different from
the original request path.

[1]: https://datatracker.ietf.org/doc/html/rfc6764#section-6
2022-05-31 16:05:54 +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
06ecb0e64c webdav: add TODO about fallback in Client.FindCurrentUserPrincipal 2022-05-25 15:07:20 +02:00
Simon Ser
97e0b10b4f carddav: add Discover TODO about "path" key in TXT record 2022-05-25 14:57:05 +02:00
Conrad Hoffmann
5d845721d8 carddav: add Content-Length support to client 2022-05-24 11:18:11 +02:00
Conrad Hoffmann
1e99b70a62 carddav: 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 11:18:11 +02:00
Conrad Hoffmann
a3e56141d9 carddav: 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 CardDAV 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 11:18:11 +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