Commit Graph

46 Commits

Author SHA1 Message Date
Simon Ser
4493704689 webdav: introduce CopyOptions 2024-01-18 13:28:50 +01:00
Simon Ser
751741d87e webdav: add/improve doc comments 2024-01-08 14:35:19 +01:00
Simon Ser
d033e09835 webdav: add context to FileSystem 2023-12-19 21:29:54 +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
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
346cfadd34 webdav: rename ServeUserPrincipal to ServePrincipal
A principal may represent something else than a user, for instance
it may represent a group.

Also rename UserPrincipalPath to CurrentUserPrincipalPath, because
the principal being served may not represent the current user.
2022-05-12 18:44:43 +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
b5c6f8927c Add exported function to create HTTPError
This can be used by backends to influence the status code returned to
clients for errors that occurred in the backend.
2022-05-03 16:56:13 +02:00
Simon Ser
25678476db internal: add ETag 2020-02-03 21:48:31 +01:00
Simon Ser
dd1527b97e carddav: allow created address book objects to have a different path
Closes: https://github.com/emersion/go-webdav/issues/32
2020-01-30 15:20:10 +01:00
Simon Ser
8937358ac1 Allow servers to return DAV capabilities in OPTIONS 2020-01-29 18:03:47 +01:00
Simon Ser
6d229f4e8a webdav: add COPY support to server 2020-01-22 13:00:42 +01:00
Simon Ser
f04c1c9421 webdav: add support for ETag to client & server 2020-01-22 12:03:58 +01:00
Simon Ser
3268102d5a webdav: add MOVE support to server 2020-01-22 11:43:36 +01:00
Simon Ser
6eeeccb96e all: encode hrefs, replace hrefs with path in public API
Closes: https://github.com/emersion/go-webdav/issues/14
Closes: https://github.com/emersion/go-webdav/issues/16
2020-01-22 11:07:30 +01:00
Simon Ser
72c96af206 webdav: move recursive PROPFIND to backend
Closes: https://github.com/emersion/go-webdav/issues/22
2020-01-22 10:41:20 +01:00
Simon Ser
90fe8dedf7 internal: add PROPPATCH support to server 2020-01-21 23:18:27 +01:00
Simon Ser
23fa5c582c webdav: make FileInfo.ModTime optional 2020-01-21 22:44:10 +01:00
Simon Ser
02d1a7dbe8 webdav: add MIMEType to FileInfo 2020-01-21 22:43:39 +01:00
Simon Ser
c673e7c7e7 webdav: replace os.FileInfo with our own type 2020-01-21 22:36:42 +01:00
Simon Ser
6023eb58a0 webdav: replace File with io.ReadCloser
Closes: https://github.com/emersion/go-webdav/issues/17
2020-01-21 22:19:34 +01:00
Simon Ser
e9e1f102de webdav: add MKCOL support to server 2020-01-21 22:05:59 +01:00
Simon Ser
a2ad695145 webdav: move WebDAV semantics handling to LocalFileSystem 2020-01-21 21:49:54 +01:00
Simon Ser
41b68829e8 webdav: add DELETE support to server 2020-01-21 21:46:01 +01:00
Simon Ser
69f88b075a webdav: add PUT to allowed methods for regular files 2020-01-21 21:35:37 +01:00
Simon Ser
7d6de88179 webdav: add support for PUT to server 2020-01-21 21:19:44 +01:00
Simon Ser
45774fe572 carddav: simplify variable names 2020-01-21 21:04:19 +01:00
Simon Ser
ffc628aed9 webdav: fix URL encoding in PROPFIND handler 2020-01-21 21:02:41 +01:00
Simon Ser
0469c3d389 all: add basic docs 2020-01-21 21:01:18 +01:00
Simon Ser
f6d0a37ea4 webdav: properly URL-encode hrefs in PROPFIND response 2020-01-21 20:08:58 +01:00
Simon Ser
4e4a5abed2 webdav: remove File.Readdir, add FileSystem.Readdir
References: https://github.com/emersion/go-webdav/issues/15
2020-01-21 19:59:41 +01:00
Simon Ser
e851e6e3f1 webdav: remove File.Stat, add FileSystem.Stat
References: https://github.com/emersion/go-webdav/issues/15
2020-01-21 19:55:02 +01:00
Simon Ser
34b2ebf940 all: use variables for xml.Name values 2020-01-17 17:09:23 +01:00
Simon Ser
7cb302246b internal: add NewPropfindResponse helper 2020-01-17 14:40:29 +01:00
Simon Ser
e2da5769f5 Improve OPTIONS handling 2020-01-17 11:41:44 +01:00
Simon Ser
f4c21ca352 webdav: make HEAD/GET on a dir fail 2020-01-17 11:32:13 +01:00
Simon Ser
326c4b9b6f internal: add Handler 2020-01-17 11:30:42 +01:00
Simon Ser
dbdd296d38 webdav: advertise class 3 support in OPTIONS 2020-01-15 23:17:43 +01:00
Simon Ser
0687eb165e webdav: add missing PROPFIND to OPTIONS response 2020-01-15 23:10:51 +01:00
Simon Ser
4c4624e225 webdav: add support for allprop and propname in PROPFIND 2020-01-15 23:03:09 +01:00
Simon Ser
ae0541654a inetrnal: rename Date to Time, make it a Text{Marshaler,Unmarshaler} 2020-01-15 19:32:59 +01:00
Simon Ser
040c38f1b6 webdav: add support for more props 2020-01-15 19:08:38 +01:00
Simon Ser
d83efedfb5 webdav: list children in PROPFIND 2020-01-15 18:39:25 +01:00
Simon Ser
ae93da82c1 webdav: add minimal server implementation 2020-01-15 18:21:27 +01:00
Simon Ser
064cd80a24 Start from scratch 2020-01-14 17:51:33 +01:00
Simon Ser
cb215c7037 Rename webdav.go to server.go 2019-12-17 17:39:19 +01:00