<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' [
<!ENTITY rfc2119 PUBLIC '' 'bibxml/reference.RFC.2119.xml'>
<!ENTITY rfc3744 PUBLIC '' 'bibxml/reference.RFC.3744.xml'>
<!ENTITY rfc4791 PUBLIC '' 'bibxml/reference.RFC.4791.xml'>
<!ENTITY rfc4918 PUBLIC '' 'bibxml/reference.RFC.4918.xml'>
<!ENTITY rfc6352 PUBLIC '' 'bibxml/reference.RFC.6352.xml'>
<!ENTITY rfc7303 PUBLIC '' 'bibxml/reference.RFC.7303.xml'>
]>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc strict="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc ipr="trust200902" docName='draft-pot-webdav-resource-sharing-04'>
    <front>
        <title abbrev="WebDAV Resource Sharing">WebDAV Resource Sharing</title>
        <author initials="E." surname="Pot" fullname="Evert Pot">
            <organization abbrev="fruux GmbH">
                fruux GmbH
            </organization>
            <address>
                <postal>
                    <street>Koenigsstrasse 32</street>
                    <city>Muenster</city>
                    <region>NRW</region>
                    <code>48143</code>
                    <country>Germany</country>
                </postal>
                <email>me@evertpot.com</email>
                <uri>https://fruux.com/</uri>
            </address>
        </author>
        <author initials="C." surname="Daboo" fullname="Cyrus Daboo">
            <organization abbrev="Apple Inc.">
                Apple Inc.
            </organization>
            <address>
                <postal>
                    <street>1 Infinite Loop</street>
                    <city>Cupertino</city>
                    <region>CA</region>
                    <code>95014</code>
                    <country>USA</country>
                </postal>
                <email>cyrus@daboo.name</email>
                <uri>http://www.apple.com/</uri>
            </address>
        </author>
        <author initials="E." surname="York" fullname="Eric York">
            <organization abbrev="Apple Inc.">
                Apple Inc.
            </organization>
            <address>
                <postal>
                    <street>1 Infinite Loop</street>
                    <city>Cupertino</city>
                    <region>CA</region>
                    <code>95014</code>
                    <country>USA</country>
                </postal>
                <email></email>
                <uri>http://www.apple.com/</uri>
            </address>
        </author>
        <date/>
        <abstract>
            <t>
                This specification defines an extension to WebDAV that enables the sharing of
                resources between users on a WebDAV server.
            </t>
        </abstract>
    </front>
    <middle>
        <section title='Introduction'>

            <t>
                Users of <xref target="RFC4791">CalDAV</xref> and
                <xref target="RFC6352">CardDAV</xref> often require a
                mechanism to share a calendar or address book collection
                with other users.
            </t>
            <t>
                This specification introduces a mechanism that allows
                users of WebDAV servers to invite another user to share a
                resource or WebDAV collection. The invited user can either
                accept or reject the invite, which is communicated back to the
                sharer. If the user chooses to accept the invite, the shared
                resource will then appear in a location on the server that's
                accessible by the invitee.
            </t>
            <t>
                There are existing mechanism that address similar use-cases,
                such as using <xref target='RFC3744'>WebDAV ACL</xref> for
                fine-grained access control. Experience has shown that client
                developers are averse to using it due its complexity. Many
                implementations have chosen to only use WebDAV ACL for
                communicating access control information to clients, but not
                for modification. WebDAV ACL alone also does not provide the
                means for a user to invite another user.
            </t>
            <t>
              In this specification, HTTP POST operations are used to manage
              the sharing invitations and replies, and WebDAV properties are
              used to expose the state of shared resources.
            </t>
            <t>
                This specification uses WebDAV notifications to communicate to
                users there are outstanding invitations, or responses to
                invitations.
            </t>
        </section>
        <!--<section title="Open Issues">
            <t>
                 <list style="numbers">
                    <t>...</t>
                 </list>
            </t>
        </section>-->

        <section title='Conventions Used in This Document'>
            <t>
                The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target='RFC2119' />.
            </t>
            <t>
                When XML element types in the namespace "DAV:" are referenced in this document outside of the context of an XML fragment, the string "DAV:" will be prefixed to the element type names.
            </t>
            <t>Terms Used:
                <list style='hanging'>
                    <t hangText='Sharer'>A user who is sharing a resource with other users.</t>
                    <t hangText='Sharee'>A user to whom a resource has been shared.</t>
                    <t hangText='Sharing Invite'>A message sent by a sharer to a sharee to notify a sharee of an invitation or update.</t>
                    <t hangText='Sharing Reply'>A message sent by a sharee to a sharer to indicate the answer to an invite.</t>
                </list>
            </t>
            <t>
              The DTD samples used in this document are for illustrative
              purposes only. All XML documents in this document follow
              the conventions and restrictions described in
              <xref target="RFC4918" /> section 17.
            </t>
        </section>

        <section title='High-level overview' anchor='overview'>
            <t>
                This section provides a basic overview of this protocol by way
                of a simple use case of a sharer sharing a collection with a
                single sharee.
            </t>
            <t>
                To share a resource with another user, the sharer's client
                executes an HTTP POST request against the resource that's to
                be shared. The POST request body will contain details of the
                user to whom the resource is to be shared as well as the
                access right to be granted to them. If the request succeeds, a
                notification is sent to the sharee with details of the
                resource being shared to them.
            </t>
            <t>
                The sharee's client will show the notification to the sharee
                and present them with the choice to accept or decline the
                invitation to the shared collection. If the sharee chooses to
                decline, then nothing changes for that sharee. If the sharee
                chooses to accept, then a new resource is created at a
                location that's accessible to the sharee.
                The server enforces the appropriate access privileges for the
                sharee.
            </t>
            <t>
                At any time, the sharer can inspect properties on the
                resource being shared, and determine the accept/decline
                status of each sharee. Additional sharees can be added and
                existing ones removed. The access privileges for existing
                sharees can also be changed.
            </t>
            <t>
                Once a sharee has access to the shared resource, they can
                remove it and decline the sharing invite by simply having
                their client issue an HTTP DELETE request on the shared
                collection. That does not delete any data, but rather simply
                removes the "link" to the sharer's resource and sets the
                sharee's invite status to declined.
            </t>
        </section>

        <section title="Sharing a resource">
          <section title="Advertising resource sharing support">
            <t>
                A server that supports the features described in this
                document MUST include "resource-sharing" as a field in the
                DAV response header from an OPTIONS request on any resource
                that supports these features.
            </t>
            <t>
                A response to this OPTIONS request might look as follows:
            </t>
            <t>
                <figure>
                   <artwork><![CDATA[
HTTP/1.1 200 OK

Dav: 1,3,extended-mkcol,resource-sharing
Allow: GET,HEAD,POST,OPTIONS,PROPFIND,PROPPATCH
]]></artwork>
                </figure>
            </t>
          </section>
          <section title="Required privileges" anchor="share-privilege">
            <t>
              A server that supports sharing on a specific resource, MUST
              enforce this using the "DAV:share" privilege. Privileges are
              defined in <xref target="RFC3744" />.
            </t>
            <t>
              The privilege MAY be abstract and MAY be protected. This
              privilege MUST appear in the DAV:supported-privilege-set
              property for resources that may be shared. In addition, it MUST
              appear in the DAV:current-user-privilege-set property, if the
              user is in fact allowed to share the resource. This mechanism
              is also used by a client to discover sharing capabilities on
              specific resources.
            </t>
          </section>
          <section title="Sharing POST request" anchor="share-post-request">
            <t>
              To share a resource or revoke access to a shared resource, the
              client must issue a POST request to the resource that the user
              wants to share. The POST request MUST contain an XML document as
              its body, with the root element being
              <xref target="DAV:share-resource">DAV:share-resource</xref>.
            </t>
            <t>
              The POST request MUST contain a Content-Type HTTP header, which
              MUST contain "application/davsharing+xml" as its value. Servers
              SHOULD reject the request if this is not the case.
            </t>
            <t>
              The DAV:share-resource element can contain one or more DAV:sharee
              elements. Each DAV:sharee element MUST at least have a
              DAV:href element containing a URI identifying the sharee.
            </t>
            <t>
              The URI in DAV:href may be a principal-URL referring to a
              sharee hosted on the same server, an email address or any other URI
              identifying a user. In the case of the latter two, the sharee might not
              be a user on the same server - though in that case how invitations are
              sent or access is enabled is out of scope for this specification.
            </t>
            <t>
              The DAV:prop element is optional, and can be used to provide more
              information about the sharee. The server MAY use this information and
              later return it when information is requested about the list of sharees.
              Any valid WebDAV property might be provided here, but it's up to the
              discretion of the server what to support.
              A client SHOULD provide at least a DAV:displayname property as a human-
              readable string identifying the user.
            </t>
            <t>
              The DAV:share-access element is required. It MUST contain one of the
              following elements:
            </t>
            <t>
            <list style="hanging">
              <t hangText="DAV:read">
                  When present this indicates that sharees can read information from the resource, but cannot change it. This applies to the resource, but if the shared resource is a collection, it also applies to the collection's children.
              </t>
              <t hangText="DAV:read-write">
                  When present this indicates that sharees can read and write information from the resource.
              </t>
              <t hangText="DAV:no-access">
                  When present this indicates that access to the resource is revoked for the sharee.
              </t>
            </list>
          </t>
          <t>
            Lastly, you may add the optional DAV:comment element. This element may contain
            some information about the intent of the share, for the sharee, this allows the
            sharee to send a short message.
          </t>
          <section title="Example: Sharing a resource">
              <t>
                The following example grants read-write access to a resource
                identified by "/calendars/users/cyrus/shared" to a sharee
                with email address "mailto:eric@example.com".
              </t>
              <t>
                  <figure>
                     <artwork><![CDATA[
POST /calendars/users/cyrus/shared/ HTTP/1.1
Host: calendar.example.com
Content-Type: application/davsharing+xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:share-resource xmlns:D="DAV:">
  <D:sharee>
    <D:href>mailto:eric@example.com</D:href>
    <D:prop>
      <D:displayname>Eric York</D:displayname>
    </D:prop>
    <D:comment>Shared workspace</D:comment>
    <D:share-access>
      <D:read-write />
    </D:share-access>
  </D:sharee>
</D:share-resource>]]></artwork>
                  </figure>
               </t>
               <t>
                 If the operation was successful, the server MUST respond with a
                 204 No Content HTTP status.
               </t>
               <t>
                 <figure>
                   <artwork><![CDATA[
HTTP/1.1 200 OK
Cache-Control: no-cache
Date: Sat, 11 Nov 2006 09:32:12 GMT]]></artwork>
                 </figure>
               </t>
          </section>
          <section title="Example: Multiple sharee changes">
              <t>
                This example shows how multiple sharee's can be
                manipulated in a single request. The sharee with email
                address "mailto:eric@example.com" has their access
                downgraded to DAV:read, whilst another sharee is
                removed from the access list entirely.
              </t>
              <t>
                  <figure>
                     <artwork><![CDATA[
POST /calendars/users/cyrus/shared/ HTTP/1.1
Host: calendar.example.com
Content-Type: application/davsharing+xml; charset="utf-8"
Content-Length: xxxx

<?xml version="1.0" encoding="utf-8" ?>
<D:share-resource xmlns:D="DAV:">
  <D:sharee>
    <D:href>mailto:eric@example.com</D:href>
    <D:share-access>
      <D:read />
    </D:share-access>
  </D:sharee>
  <D:sharee>
    <D:href>mailto:wilfredo@example.com</D:href>
    <D:share-access>
      <D:no-access />
    </D:share-access>
  </D:sharee>
</D:share-resource>]]></artwork>
                  </figure>
               </t>
          </section>
        </section>

        <section title="New WebDAV properties on shared resources">
            <t>
                The following new or modified WebDAV properties are defined for resources and used to view or manipulate shared resources features.
            </t>
            <section title="DAV:share-access Property" anchor="share-access-property">
              <t>
                <list style="hanging">
                  <t hangText="Name:">share-access</t>
                  <t hangText="Namespace:">DAV:</t>
                  <t hangText="Purpose:">Allows a client to see if a resource is a shared resource and the access level.</t>
                  <t hangText="Protected:">This property MUST be protected.</t>
                  <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
                  <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in MOVE operations, but MUST NOT be preserved in COPY operations.</t>

                  <t hangText="Description:">
                    Resources that are shared must have a DAV:share-access property. It's value
                    should be one of four elements:
                      <list style="symbols">
                          <t>DAV:not-shared: Used to indicate that the resource is not shared. This is the default, which means that if the DAV:share-access is omitted, this value is implied.</t>
                          <t>DAV:shared-owner: used to indicate that the resource is owned by the current user and is being shared by them.</t>
                          <t>DAV:read-write: used to indicate that the resource is shared, and the current instance is the 'shared instance' which has read-write access.</t>
                          <t>DAV:read: used to indicate that the resource is shared, and the current instance is the 'shared instance', and only read access is provided.</t>
                      </list>
                  </t>
                </list>
              </t>
            </section>
            <section title="DAV:invite Property" anchor="invite-property">
                <t>
                  <list style="hanging">
                    <t hangText="Name:">invite</t>
                    <t hangText="Namespace:">DAV:</t>
                    <t hangText="Purpose:">Used to show to whom a resource has been shared.</t>
                    <t hangText="Protected:">This property MUST be protected.</t>
                    <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
                    <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in MOVE operations, but MUST NOT be preserved in COPY operations.</t>

                    <t hangText="Description:">
                        This WebDAV property is present on a resource that
                        has been shared by the owner, or on the resources for
                        the sharees. It provides a list of users to whom the
                        resource has been shared, along with the "status" of
                        the sharing invites sent to each user. In addition,
                        servers SHOULD include a DAV:principal XML element on
                        resources of the sharees to provide clients with a
                        fast way to determine who the sharer is. A server's
                        local privacy policy may prevent sharees from
                        knowing about other sharees on a shared calendar.
                        In those cases a server may hide information about
                        other sharees.
                    </t>
                  </list>
                </t>
            </section>
            <section title="DAV:share-resource-uri Property" anchor="share-resource-uri-property">
              <t>
                <list style="hanging">
                  <t hangText="Name:">share-resource-uri</t>
                  <t hangText="Namespace:">DAV:</t>
                  <t hangText="Purpose:">A unique URI that identifies the shared resource.</t>
                  <t hangText="Protected:">This property MUST be protected.</t>
                  <t hangText="PROPFIND behavior:">This property SHOULD NOT be returned by a PROPFIND allprop request (as defined in Section 14.2 of <xref target="RFC4918"/>).</t>
                  <t hangText="COPY/MOVE behavior:">This property value MUST be preserved in COPY and MOVE operations.</t>

                  <t hangText="Description:">
                      This WebDAV property SHOULD be present on a shared
                      resource. Its content is a single DAV:href element
                      whose value is the URL of the sharer's resource being
                      shared. The property MUST contain a URI that uniquely identifies
                      the original shared resource. The URI MAY refer to a resource
                      hosted on the same server, but MAY also refer to a URN.
                      A key requirement is that this URI remains stable during the
                      life-time of a share.
                  </t>
                </list>
              </t>
            </section>

        </section>

        <section title="Handling the share process" anchor="handling-share-process">

          <t>
            This specification supports two major processes for sharing a resource.
            The server can either immediately set up the newly shared resource, or
            the server can provide an invitation process. The former might be useful
            in  small trusted team settings, whereas the invitation process might be
            used in public servers, where it's desirable for users to explicitly
            opt-in to getting access to newly shared resources.
          </t>
          <t>
            This specification provides a invitation and notification mechanism.
            It might also be possible that servers provide their own out-of-band
            mechanism for this, but this should not affect clients.
          </t>

          <section title="The invitation process" anchor="invitation-process">
            <t>
              If the server opts to support the standard invitation process, the
              server MUST support <!-- <xref target="dav-notifcations"-->WebDAV
              notifications<!-- </xref> -->.
            </t>
            <t>
              Sharees for a resource MUST appear up in the
              <xref target="invite-property">DAV:invite</xref> property.
              Each sharee will have one of the following elements:

              <list style="hanging">
                <t hangText="DAV:invite-noresponse">The sharee was invited, but has not yet responded to the invite.</t>
                <t hangText="DAV:invite-accepted">The sharee has accepted the invite.</t>
                <t hangText="DAV:invite-declined">The sharee has declined the invite.</t>
                <t hangText="DAV:invite-invalid">The invitation was invalid or could not be delivered.</t>
              </list>
            </t>
            <t>
              When sharees are initially invited, they will get the DAV:invite-noresponse status.
              When a sharee's access has been changed, they will retain their existing status.
              When a sharee's access has been revoked, they will no longer appear in the DAV:invite property.
            </t>
            <t>
              After any of these mutations, sharees receive an
              <xref target="share-invite-notification">share-invite-notification</xref> in their
              notification collection. After the sharee has accepted or declined the invite, their status
              will reflect this response.
            </t>
          </section>

          <section title="Instant sharing" anchor="instant-sharing">

            <t>
              Implementing the invitation process is optional. It's also possible for servers
              to immediately apply changes. The effect is that no notifications may be needed,
              and the server behaves as if sharees immediately accept invitations.
              Sharees listed in DAV:invite might immediately receive a DAV:invite-accepted status.
            </t>

          </section>

        </section>

        <section title="Notification Definitions">
            <t>
                In order to facilitate the process of sharing invitations, this
                specification uses <!-- <xref target="dav-notifications">-->WebDAV
                notifications<!-- </xref> -->, and defines several new notification
                types.
            </t>
            <section title="Invite Notification" anchor='share-invite-notification'>
                <t>
                    When a sharer adds a new sharee to a resource, or updates
                    a sharee, an invite notification is added to the sharee's
                    notification collection.
                </t>
                <t>
                    The notification contains information about the shared
                    resource, the owner and how to respond to the invitation.
                </t>
                <section title="Example: An invite notification">
                    <t>
                        This is an example of a response to a GET request on a
                        correct reply invite notification. Note that several HTTP
                        response headers have been removed for brevity.
                    </t>
                    <t>
                    <figure>
                        <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/davnotification+xml
Content-Length: xxxx

<D:notification xmlns:D="DAV:">
    <D:dtstamp>2014-08-05T13:38:02Z</D:dtstamp>
    <D:share-invite-notification>
        <D:principal>
            <D:href>/principals/users/evert/</D:href>
        </D:principal>
        <D:invite-accepted />
        <D:sharer-resource-uri>
          <D:href>/calendars/users/evert/offdays/</D:href>
        </D:sharer-resource-uri>
        <D:share-access><D:read-write /></D:share-access>
        <D:prop>
            <D:displayname>Vacation days!!</D:displayname>
            <D:resourcetype><D:collection /></D:resourcetype>
        </D:prop>
        <D:reply-url>
          <D:href>?invite-reply</D:href>
        </D:reply-url>
    </D:share-invite-notification>
</D:notification>
]]></artwork>
                    </figure>
                  </t>
                  <t>
                    In this notification, DAV:principal indicates which principal
                    is the sharer for the resource.
                  </t>
                  <t>The notification MUST contain
                    DAV:invite-accepted or DAV:invite-noresponse
                    to indicate the current invitation status of the sharee in the
                    shared resource.
                    New invites to shares would carry the DAV:invite-noresponse status.
                    In case the sharee had accepted an earlier invite, but it's access
                    was changed or revoked, the invitation will have a DAV:invite-accepted
                    status.
                  </t>
                  <t>
                    DAV:sharer-resource-uri refers to the DAV:sharer-resource-uri that
                    the shared resource will have, and can be used to identify which
                    invitation refers to which existing shared resource. The element
                    MAY refer to the URI of the original shared resource, but may also
                    be a urn, or any other unique URI.
                  </t>
                  <t>
                    DAV:share-access MUST be one of DAV:read-write, DAV:read or DAV:no-access.
                    This indicates that the invitee either has read-write access, read-only
                    access or no access at all respectively.
                  </t>
                  <t>
                    DAV:reply-url appears for invitations to new shared resources. The url
                    in this property can be used for a sharee to accept or decline the
                    invite. DAV:reply-url only appears for sharees with the
                    DAV:invite-noresponse status, and does not appear when DAV:share-access
                    is DAV:no-access.
                  </t>
                  <t>
                    The DAV:prop element is optional, and may contain a list of WebDAV
                    properties associated with the shared resource. Servers SHOULD at least
                    set the DAV:resourcetype, if available. This will allow a client to
                    know what kind of resource is being shared. Some clients may only
                    support responding to invites of certain kinds of resources. For example,
                    a calendaring user agent may only support CalDAV calendars.
                  </t>
                  <t>
                    The DAV:comment element is also optional, and may return a brief message
                    from the sharer to the sharee. The sharer is able to specify this in the
                    original DAV:share-resource POST request.
                  </t>
                </section>
            </section>
            <section title="Invite Reply" anchor='share-reply-notification'>
                <t>
                    After a sharee has accepted or declined an invitation,
                    the sharer receives a share-reply-notification in their notification
                    collection.
                </t>
                <t>
                    This notification contains information about which
                    collection this relates to, and who responded to the
                    invite.
                </t>
                <section title="Example: An invite reply">
                    <t>
                        This is an example of a response to a GET request on a
                        correct invite notification. Note that several HTTP
                        response headers have been removed for brevity.
                    </t>
                    <t>
                    <figure>
                        <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/davnotification+xml
Content-Length: xxxx

<D:notification xmlns:D="DAV:">
    <D:dtstamp>2014-09-03T02:30:00Z</D:dtstamp>
    <D:share-reply-notification>
        <D:sharee>
          <D:href>mailto:john@example.org</D:href>
          <D:invite-declined />
        </D:sharee>
        <D:href>/calendars/users/evert/offdays/</D:href>
        <D:comment>Sorry, I'm not interested</D:comment>
    </D:share-reply-notification>
</D:notification>
]]></artwork>
                    </figure>
                    </t>
                    <t>
                      In this notification, the DAV:sharee element MUST appear
                      and contains information about the updated status of the
                      sharee in the shared resource.
                    </t>
                    <t>
                      The DAV:href element MUST appear and refers to the resource
                      the sharer originally shared.
                    </t>
                    <t>
                      The DAV:comment element is optional, and may contain a message
                      that the sharee specified when responding to the invite.
                    </t>
                </section>
            </section>
        </section>

        <section title="Sharee Actions on Shared Resources">
                <section title="Replying to a Sharing Invite" anchor="reply-post-request">
                    <t>
                        When a sharee is invited to a shared resource they
                        can accept or decline the invite by issuing a POST
                        request to the url specified in the DAV:reply-url element,
                        in the invitation notification. The POST request MUST contain
                        an XML document as its body with the root element being
                        <xref target="DAV:invite-reply">DAV:invite-reply</xref>.
                    </t>
                    <t>
                        The POST request MUST contain a Content-Type HTTP
                        header, which MUST contain "application/davsharing+xml"
                        as its value. Servers SHOULD reject the request if
                        this is not the case.
                    </t>
                    <t>
                        The <xref target="DAV:invite-reply">DAV:invite-reply</xref>
                        element in the POST request specifies the accept or
                        decline action via the DAV:invite-accepted or
                        DAV:invite-declined elements, and an optional
                        DAV:comment element. IF the invite was accepted, the
                        body MUST also contain a DAV:create-in element. This element
                        contains a single DAV:href element, which content is a URI
                        that will be used as the parent for the new shared resource.
                    </t>
                    <t>
                        The client MAY also provide a <!--<xref target="DAV:slug">-->
                            DAV:slug<!--</xref>--> property. The server MAY use the
                        contents of this property to determine the name of
                        the new resource.
                    </t>
                    <t>
                        All usual preconditions for creating a resource at the
                        DAV:create-in target collection need to be taken into
                        consideration.
                    </t>
                    <t>
                        Note that some servers may restrict where certain types
                        of resources may be created. A CalDAV server for
                        instance, may only allow calendars to be created in
                        collections identified by the CALDAV:calendar-home-set
                        WebDAV property.
                    </t>
                    <t>
                        The client MAY also provide a small comment in the
                        DAV:comment element. This comment will be sent back to the
                        sharer. Support for DAV:comment is optional.
                    </t>
                    <t>
                        A successful response to an accepted invitation, SHOULD
                        have a HTTP 201 status code, and MUST have a HTTP
                        Location header, containing the full url to the newly
                        created resource.
                    </t>
                    <t>
                        A successful response to a declined invitation, SHOULD
                        contain a 200 or 204 HTTP status code.
                    </t>
                    <t>
                        When the sharee replies to an invite, the server
                        SHOULD send a notification to the sharer to update
                        them on the change in the sharee state. This is
                        accomplished by sending a
                        <xref target="DAV:share-reply-notification">DAV:share-reply-notification</xref>
                        notification to the sharer.
                    </t>
                    <t>
                        After the sharee has issued a reply, the server SHOULD
                        also remove the notification that contained the
                        initial invite.
                    </t>
                    <section title="Example: Accepting an invite">
                    <t>
                        This is an example of a request that the sharee would
                        send to accept an invitation.
                    </t>
                    <t>
                    <figure>
                        <artwork><![CDATA[
POST /principals/users/evert/notifications/1000455.xml HTTP/1.1
Host: calendar.example.com
Content-Type: application/davsharing+xml; charset="utf-8"

<?xml version="1.0" encoding="utf-8" ?>
<D:invite-reply xmlns:D="DAV:">
    <D:invite-accepted />
    <D:create-in>
        <D:href>/calendars/users/evert/</D:href>
    </D:create-in>
    <D:slug>Tech meetups</D:slug>
    <D:comment>Thanks for the share!</D:comment>
</D:invite-reply>
]]></artwork>
                    </figure>
                    </t>
                    </section>
                </section>
                <section title="Ignoring an invitation">
                    <t>
                        For privacy reasons, sharees need to be able to
                        remove invitations without notifiying the sharer.
                    </t>
                    <t>
                        When the sharee issues a DELETE on an
                        share-invite-notification, the server MUST remove the
                        notification, and MUST NOT let the sharer know about
                        this.
                    </t>
                    <t>
                        As a result, from the sharers perspective, the
                        invitation status for that principal will always
                        remain as DAV:invite-noreply.
                    </t>
                </section>
                <section title="Making modifications to a shared resource">
                    <t>
                        Any changes that a sharee makes to a shared resource
                        should also be reflected in the sharers instance of
                        the resource.
                    </t>
                    <t>
                        If the shared resource is a collection, any resources
                        in the collection, or in the collection's
                        child-collections MUST also appear in the sharers
                        instance.
                    </t>
                </section>
                <section title="Removing a shared resource">
                    <t> To remove a shared resource a DELETE request is
                        targeted at the shared resource URI. When such a
                        request is received the server MUST remove the shared
                        collection and automatically update the sharee's
                        status in the sharer's
                        <xref target="invite-property">DAV:invite</xref> property.
                    </t>
                </section>
            </section>
            <section title="General Considerations">

                <section title="Per-instance WebDAV Properties" anchor="per-instance-data">
                    <t>
                        Servers MUST support "per-instance" WebDAV properties
                        on shared resource and MAY support them on resources
                        within shared collections. A "per-instance" WebDAV
                        property is one whose value can be set and retrieved
                        on an instance of a resource, but is not
                        automatically propagated to other instances of the
                        same shared resource. For example, a sharee may
                        change a property on their instance of a shared
                        resource, but the instance of the owner of the
                        resource will not see this updated value.
                    </t>
                    <t>
                        For shared resources, the server MUST allow all
                        users to write "per-instance" WebDAV properties on the
                        shared resources and MAY allow property writes on
                        resources within the shared resources. This is
                        required even in the case where the sharee has been
                        granted read access only (i.e., the ability to
                        change the resource is disallowed). This requirement
                        ensures that sharees can always change "personal"
                        properties such as display names.
                    </t>
                    <t>
                        Servers MAY treat any dead property as per-instance.
                    </t>
                    <t>
                        Servers MUST NOT treat live properties as per-instance.
                    </t>
                </section>
                <section title="Sharees and instances">
                  <t>
                    A point that may not be immediately obvious, is that there
                    is a separation between sharees and shared instances.
                  </t>
                  <t>
                    Sharees (and sharers) are effectively only 'actors' in the
                    sharing process and allow shared instances to be created and
                    modified. The sharing "role" or access level that a user has
                    when performing an opteration on a shared resource, is
                    dependent on which intance they are accessing, not who the
                    currently logged in principal is.
                  </t>
                  <t>
                    To illustrate, take the DAV:share-access WebDAV property. This
                    property should always describe the access-level of the
                    instance, not the current user accessing the property.
                  </t>
                  <t>
                    An implication is that if an owner of a shared resource also
                    has direct access to a shared instance of a sharee (via normal
                    WebDAV ACL controls for example), requesting the share-access
                    property on that shared resource should always indicate
                    DAV:read or DAV:read-write, but never DAV:shared-owner.
                  </t>
                  <t>
                    Likewise, if a sharee also has direct access to the original
                    shared (owner) instance on the same server, the DAV:share-access
                    property should always return DAV:shared-owner.
                  </t>
                  <t>
                    This philosophy must be considered when designing the
                    underlying data-model of the server, and every feature in this
                    specification. That is: the sharing-role a user has
                    when accessing a shared-resource, is generally dependent on the
                    resource being accessed, not the current principal.
                  </t>
                </section>

                <section title="Relationship between sharing access levels and WebDAV ACL">
                   <t>
                    This document describes a way for a user to grant access to
                    other resources, sidestepping <xref target="RFC3744">WebDAV ACL</xref>.
                  </t>
                  <t>
                    WebDAV ACL is still relevant though. The DAV:share ACL privilege
                    is used to indicate that a user is allowed to share a resource.
                  </t>
                  <t>
                    This specification uses the DAV:read and DAV:read-write
                    access levels to indicate the access level of the shared resource.
                  </t>
                  <t>
                    These privileges don't directly correlate to ACL privileges. It's
                    left up to the implementor to decide which ACL privileges are the
                    most appropriate for both DAV:read and DAV:read-write.
                  </t>
                  <t>
                    The following is a suggestion: Sharees with a DAV:read share-access
                    level, may typically at least expect DAV:read, DAV:write-properties,
                    DAV:read-current-user-privilege set.
                  </t>
                  <t>
                    For DAV:read-write, this also includes DAV:write, DAV:write-content,
                    and if the shared resource is a collection, DAV:bind and DAV:unbind.
                  </t>
                  <t>
                    These privileges are typically applied to the shared resource and
                    all its child resources (if any).
                  </t>
                  <t>
                    There is no requirement for the shared instance to have a
                    DAV:owner element that refers to the original sharer. In fact,
                    it SHOULD probably be the sharee. Likewise, there is also no
                    requirement for the original sharer to have any privileges
                    to any of the sharee instances.
                  </t>
                </section>
            </section>
        </section>

        <section title='XML Element Definitions'>

            <t>
              The following section contains a definition of all the XML elements
              used in this document  The definitions are written in the form of a
              DTD. The DTD itself non-normative and for reference only.
            </t>
            <t>
              It should be noted that several elements in the following sections
              are repeated, sometimes with varying definitions. This is
              because some of these elements have slightly different definitions
              depending on the context in which they appear in.
            </t>

            <section title="DAV:share-resource" anchor="DAV:share-resource">

              <t>
                The following section describes the DAV:share-resource element, which
                is defined in <xref target="share-post-request" />
              </t>

              <t>
                <figure>
                  <artwork><![CDATA[<!ELEMENT share-resource (sharee+)>

<!-- Each sharee represents a sharee -->
<!ELEMENT sharee (href, share-access, prop?, comment?)>

<!-- The sharee href, can be a mailto:, http: or any supported scheme -->
<!ELEMENT href (#PCDATA)>

<!-- Describes the access-level the user will get -->
<!ELEMENT share-access (read, read-write, no-access)>

<!-- Read-only access -->
<!ELEMENT read EMPTY>

<!-- Read-write access -->
<!ELEMENT read-write EMPTY>

<!-- Access is revoked -->
<!ELEMENT no-access EMPTY>

<!-- A list of properties describing the sharee, such as a displayname ->
<!ELEMENT prop ANY>

<!-- An optional message to the sharee by the sharer -->
<!ELEMENT comment (#PCDATA)>
]]></artwork>
                </figure>
              </t>
            </section>

            <section title="DAV:share" anchor="DAV:share">
              <t>
                The share element is a <xref target="RFC3744">WebDAV ACL</xref>
                privilege that allows a client to inspect whether a user may be
                allowed to share a resource. The element is defined in
                <xref target="share-privilege" />.
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!ELEMENT share EMPTY>]]></artwork>
                </figure>
              </t>
            </section>
            <section title="DAV:share-invite-notification" anchor="DAV:share-invite-notification">
              <t>
                DAV:share-invite-notification is used within a WebDAV notification
                to communicate to a sharee that a sharer is sharing a resource, or
                changing the access level to a resource. DAV-share-invite-notification
                is defined in <xref target="share-invite-notification" />
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!-- Every notification has a DAV:notification root element -->
<!ELEMENT notification (dtstamp, share-invite-notification)>

<!-- This element has all the information about the notification -->
<!ELEMENT share-invite-notification (principal, (invite-accepted|invite-noresponse),
    sharer-resource-uri, share-access, prop?, reply-url?, comment?)>

<!-- Indicates that this was a new invitation -->
<!ELEMENT invite-noresponse EMPTY>

<!-- Indicates that this was an update to an existing invitation -->
<!ELEMENT invite-accepted EMPTY>

<!-- A uri that indentifies the original shared resource. -->
<!ELEMENT sharer-resource-uri (href)>

<!-- Information about the sharer -->
<!ELEMENT principal (href, prop?)>

<!-- Describes the access-level the user will get -->
<!ELEMENT share-access (read, read-write, no-access)>

<!-- Read-only access -->
<!ELEMENT read EMPTY>

<!-- Read-write access -->
<!ELEMENT read-write EMPTY>

<!-- Access is revoked -->
<!ELEMENT no-access EMPTY>

<!-- If it was a new share, where to respond to the invitation -->
<!ELEMENT reply-url (href)>

<!-- An optional comment from the sharer to the sharee -->
<!ELEMENT comment (#PCDATA)>

<!-- Common elements -->
<!ELEMENT href (#PCDATA)>
<!ELEMENT prop ANY>]]></artwork>
                </figure>
              </t>
            </section>
            <section title="DAV:share-reply-notification" anchor="DAV:share-reply-notification">
              <t>
                DAV:share-reply-notification is a notification that appears in a sharers notification
                collection when a sharee responded to an invitation. It is defined in
                <xref target="share-reply-notification" />
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!-- Every notification has a DAV:notification root element -->
<!ELEMENT notification (dtstamp, share-invite-notification)>

<!-- This element has all the information about the notification -->
<!ELEMENT share-reply-notification (sharee, href, comment?)

<!ELEMENT sharee (href, (invite-accepted|invite-declined), comment?)>

<!-- A reference to the owner's shared resource -->
<!ELEMENT href (#PCDATA)>

<!-- Indicates that the sharee accepted the invitation -->
<!ELEMENT invite-accepted EMPTY>

<!-- Indicates that the sharee declined the invitation -->
<!ELEMENT invite-declined EMPTY>

<!-- An optional comment from the sharer to the sharee -->
<!ELEMENT comment (#PCDATA)>]]></artwork>
                </figure>
              </t>
            </section>
            <section title="DAV:invite" anchor="DAV:invite">
              <t>
                DAV:invite is a live WebDAV property, defined in <xref target="invite-property" />.
                This property allows a sharer or sharee to inspect who has access to a particular
                resource, their invitation status and access level.
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!-- The invite WebDAV property -->
<!ELEMENT invite (sharee*)>

<!-- A person with access to the shared resource -->
<!ELEMENT sharee (href,
    (invite-accepted|invite-declined|invite-invalid|invite-noresponse),
    share-access, prop
)>

<!-- A reference to the user who access access to the share -->
<!ELEMENT href (#PCDATA)>

<!-- Indicates that the sharee accepted the invitation -->
<!ELEMENT invite-accepted EMPTY>

<!-- Indicates that the sharee declined the invitation -->
<!ELEMENT invite-declined EMPTY>

<!-- Indicates that the sharee has not responsed yet -->
<!ELEMENT invite-noresponse EMPTY>

<!-- Indicates that the server could not deliver the invitation -->
<!ELEMENT invite-invalid EMPTY>

<!-- The level of access the user has -->
<!ELEMENT share-access (read|read-write|shared-owner)>

<!-- The user has read access -->
<!ELEMENT read EMPTY>

<!-- The user has read-write access -->
<!ELEMENT read-write EMPTY>

<!-- The user is actually the owner of the share -->
<!ELEMENT shared-owner EMPTY>

<!-- A list of WebDAV properties describing the user. -->
<!ELEMENT prop ANY>]]></artwork>
                </figure>
              </t>
            </section>
            <section title="DAV:share-access" anchor="DAV:share-access">
              <t>
                DAV:invite is a live WebDAV property, defined in <xref target="share-access-property" />.
                This property allows sharer or sharee to inspect the sharing
                status of the resource.
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!-- The share-access WebDAV property -->
<!ELEMENT share-access (read|read-write|shared-owner|not-shared)>

<!-- The current instance is a read-only instance of the share -->
<!ELEMENT read EMPTY>

<!-- The current instance if a read-write instance of the share -->
<!ELEMENT read-write EMPTY>

<!-- The current instance if the original instance, owned by the sharee -->
<!ELEMENT shared-owner EMPTY>

<!-- The current instance is not shared at all -->
<!ELEMENT not-shared EMPTY>
]]></artwork>
                </figure>
              </t>
            </section>
            <section title="DAV:invite-reply" anchor="DAV:invite-reply">
              <t>
                DAV:invite-reply is the root element of a POST request that a
                sharee would issue to respond to an invitation. It is defined
                in <xref target="reply-post-request" />.
              </t>
              <t>
                <figure>
                  <artwork><![CDATA[<!ELEMENT invite-reply ((invite-accepted|invite-declined),
    create-in?, slug?, comment?)>

<!-- The user is accepting the invite -->
<!ELEMENT invite-accepted EMPTY>

<!-- The user is declining the invite -->
<!ELEMENT invite-declined EMPTY>

<!-- When accepting the invite, the collection in which to create the new
  instance in -->
<!ELEMENT create-in (href)>
<!ELEMENT href (#PCDATA)>

<!-- A hint for the server for a new resource name. -->
<!ELEMENT slug (#PCDATA)>

<!-- A comment by the sharee to the sharer -->
<!ELEMENT comment (#PCDATA)>]]></artwork>
                </figure>
              </t>
            </section>
        </section>

        <section title='Security Considerations'>
          <section title='Forced shares'>
            <t>
              When this specification is implemented without the use of the notification
              flow, as described in <xref target="instant-sharing" />, it may be possible
              that a malicious user can create unwanted resources for a target user.
            </t>
            <t>
              If this is a concern, taking advantage of the notification process is
              highly recommended.
            </t>
          </section>
          <section title='Notification spamming'>
            <t>
              If a server does deploy the entire notification process, a user
              with malicious intent may still generate a large amount of notifications
              targetting other users.
            </t>
            <t>
              Servers SHOULD at the very least ensure that multiple share invitations for
              the same resource are coalesced into a single invitation.
            </t>
          </section>
        </section>

        <section title='IANA Considerations'>
            <t>
                This document defines a MIME media type for XML documents
                used in for sharing. This media type SHOULD be used for all
                POST requests in this specification.
            </t>
            <t>
            <list style="hanging">
              <t hangText="Type name:">application</t>
              <t hangText="Subtype name:">davsharing+xml</t>
              <t hangText="Required parameters:">none</t>
              <t hangText="Optional parameters:">none</t>
              <t hangText="Encoding considerations:">Identical to those of "application/xml" as described in <xref target="RFC7303">RFC7303</xref>.</t>
              <t hangText="Security considerations:">N/A.</t>
              <t hangText="Interoperability considerations:">There are no known interoperability issues.</t>
              <t hangText="Published specification:">This specification.</t>
              <t hangText="Applications that use this media type:">No known applications currently use this media type.</t>
              <t hangText="Fragment identifier considerations:">N/A.</t>
            </list>
          </t>
          <t>Additional information</t>
          <t>
          <list style="hanging">
              <t hangText="Deprecated alias names for this type">N/A.</t>
              <t hangText="Magic number(s)">N/A.</t>
              <t hangText="File extension(s)">xml</t>
              <t hangText="Macintosh file type code(s)">TEXT</t>
              <t hangText="Person &amp; email address to contact for further information:">me@evertpot.com</t>
              <t hangText="Intended usage">COMMON</t>
              <t hangText="Restrictions on usage">There are no restrictions on where this media</t>
              <t hangText="Author">See the "Authors' Addresses" section of this document.</t>
              <t hangText="Change Controller">IETF</t>
          </list>
          </t>
        </section>
        <section title='Acknowledgments'>
          <t>
             The authors would like to thank the members of the Calendaring and
             Scheduling Consortium's SharingTechnical Committee. In particular,
             the following individuals have made important contributions to
             this work: Richard Brigham, John Chaffee, Michael Douglass and
             Ken Murchison and Dave Thewlis.
          </t>
           <t>
             This specification originated from work at the Calendaring and
             Scheduling Consortium, which has supported the development and
             testing of implementations of the specification.
           </t>
        </section>
    </middle>
    <back>
        <references title='Normative References'>
            &rfc2119;
            &rfc3744;
            &rfc4791;
            &rfc4918;
            &rfc6352;
            &rfc7303;
        </references>
<!--
<references title='Informative References'>
</references>
-->
        <section title='Backwards compatibility'>
            <t>
                This specification is based on an earlier effort, often referred
                to as 'caldav-sharing'. It is possible to remain compatibile with
                this specification, but it's important to be aware of a number of
                changes.
            </t>
            <t>
                The earlier draft uses the http://calendarserver.org/ns/
                namespace for all its xml elements. This means that any
                WebDAV property introduced in this specification, may need
                to have a similar property in the old namespace.
            </t>
            <t>
                XML documents as sent by POST requests and responses, and
                resources returned from notifications can be distinguished by
                the use of the Content-Type and Accept HTTP headers. The earlier
                draft does not define new mime-types for these, but this
                specification does.
            </t>
        </section>
        <section title='Change History (to be removed prior to publication as an RFC'>
            <t>Changes in -04:
                <list style='numbers'>
                  <t>Corrected the application/davsharing+xml mimetype where it was misspelled.</t>
                  <t>Lots of small spelling/english fixes.</t>
                  <t>Changed sharer-resource-uri into share-resource-uri. This new uri makes a bit more sense.</t>
                </list>
            </t>
            <t>Changes in -03:
                <list style='numbers'>
                  <t>A major rewrite, making many xml elements self-consistent and with other WebDAV specifications.</t>
                  <t>While all of the same data is still there, many xml elements have changed.</t>
                  <t>Added 'Instant sharing' concept, making notifications integration optional.</t>
                  <t>Removed DAV:share-mode</t>
                  <t>Added DAV:share-access</t>
                  <t>Added a DAV:sharee element with a consistent set of information about sharees.</t>
                  <t>Clarified the nature of DAV:invite-accepted element in DAV:invite-notifaction documents.</t>
                  <t>Introduced the DAV:reply-url element.</t>
                  <t>DAV:sharer-instance-url is now DAV:sharer-instance-uri and may contain other uris.</t>
                  <t>Added security concerns.</t>
                  <t>Complete rewrite of the XML Elements section, using DTDs.</t>
                  <t>DAV:invite-notification is now DAV:share-invite-notification.</t>
                  <t>DAV:reply-notification is now DAV:share-reply-notification.</t>
                  <t>Added design philosophy section.</t>
                  <t>Added information about relationship with WebDAV ACL.</t>
                </list>
            </t>
            <t>Changes in -02:
                <list style='numbers'>
                  <t>Renamed DAV:shared-url to DAV:sharer-instance-url.</t>
                  <t>Introduced DAV:share-mode WebDAV property.</t>
                  <t>Removed additions to DAV:resource-type to indicate that a resource is shared.</t>
                </list>
            </t>
            <t>Changes in -01:
                <list style='numbers'>
                    <t>Fixed some issues in the DTD declatations of set-invitee and remove-invitee.</t>
                    <t>Removed an unused normative reference.</t>
                    <t>Removed 'open issues' section.</t>
                    <t>Added a paragraph about xml/dtd handling with a reference to RFC4917</t>
                    <t>Renamed DAV:share to DAV:share-resource for the POST request</t>
                </list>
            </t>
        </section>
    </back>
</rfc>
