Kantoor.Dav.ShareGuard (Kantoor v1.0.0)

The write check for shared collections, run before a DAV request reaches the protocol library.

The library only asks the store to refuse a PUT; for DELETE, PROPPATCH, COPY, MOVE and the rest it runs its side effects (cancellations, change notifications) whatever the store then does. So a request that would change something under /dav/<home>/<me>/shared-<id>/ is decided here:

  • reading (GET, HEAD, OPTIONS, PROPFIND, REPORT) always passes: the store answers 404 when there is no grant;
  • changing a member needs a write grant;
  • changing the shared collection itself (delete, move, properties, ACL, sharing documents) is the owner's, who addresses it by its real slug;
  • COPY and MOVE into or out of a shared collection are refused.

The same guard keeps every write away from the user's own subscribed calendars (Kantoor.Feeds), which only the feed fills: anything but reading a subscribed calendar or its members, and any COPY or MOVE into or out of one, is refused (subscribed_write?/4).

The store enforces the same rules again (defence in depth).

Summary

Functions

True when the request may go on to the DAV library.

True when the request would change a subscribed calendar of the user, or a member of one, or copy or move something into or out of one.

Functions

allowed?(method, request_path, destinations, user_id)

@spec allowed?(String.t(), String.t(), [String.t()], Ecto.UUID.t()) :: boolean()

True when the request may go on to the DAV library.

subscribed_write?(method, request_path, destinations, user_id)

@spec subscribed_write?(String.t(), String.t(), [String.t()], Ecto.UUID.t()) ::
  boolean()

True when the request would change a subscribed calendar of the user, or a member of one, or copy or move something into or out of one.