<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" ipr="trust200902" docName="draft-authors-datarightplus-sharing-arrangement-v1-00" submissionType="independent" category="exp" xml:lang="en" indexInclude="true">

<front>
<title>DataRight+: Sharing Arrangement V1</title><seriesInfo value="draft-authors-datarightplus-sharing-arrangement-v1-00" stream="independent" status="experimental" name="Internet-Draft"/>
<author initials="S." surname="Low" fullname="Stuart Low"><organization>Biza.io</organization><address><postal><street/>
</postal><email>stuart@biza.io</email>
</address></author><author initials="B." surname="Kolera" fullname="Ben Kolera"><organization>Biza.io</organization><address><postal><street/>
</postal><email>bkolera@biza.io</email>
</address></author><date/>
<area>Internet</area>
<workgroup>datarightplus</workgroup>

<abstract>
<t>This specification outlines the technical requirements related to the delivery of Sharing Arrangement V1.</t>
</abstract>

<note><name>Notational Conventions</name>
<t>The keywords  "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>",  "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in <xref target="RFC2119"/>.</t>
</note>

</front>

<middle>

<section anchor="scope"><name>Scope</name>
<t>The scope of this specification is focused on describing the authorisation related components of establishing a CDR Sharing Arrangement. This specification unavoidably references ecosystem specific concepts (Australian CDR) due to the very nature of localised claim names. Sharing Arrangement V1 therefore is aligned with the definition of a CDR Arrangement as originally outlined within <xref target="CDS"/>.</t>
</section>

<section anchor="terms-definitions"><name>Terms &amp; Definitions</name>
<t>This specification uses the terms "Consumer", "Provider", "Initiator", "Personally Identifiable Information (PII)",
"Pairwise Pseudonymous Identifier (PPID)", "Initiator", "CDR Sharing Arrangement" and "CDR Sharing Arrangement Identifier"  as defined by <xref target="DATARIGHTPLUS-ROSETTA"/>.</t>
</section>

<section anchor="provider"><name>Provider</name>
<t>The following provisions apply to services delivered by Providers.</t>

<section anchor="authorisation-server"><name>Authorisation Server</name>
<t>In addition to the provisions outlined in <xref target="DATARIGHTPLUS-INFOSEC-BASELINE"/> the authorisation server:</t>

<ol spacing="compact">
<li><bcp14>SHALL NOT</bcp14> issue a refresh token unless the duration of the CDR Arrangement is greater than <tt>0</tt> (see [Request Object])</li>
<li><bcp14>SHALL</bcp14>, where the supplied <tt>cdr_arrangement_id</tt>, if provided, does not match the authenticated Consumer and as soon as practicable, return an OAuth2 Error</li>
<li><bcp14>SHALL</bcp14> modify the existing authorisation grant referenced by the <tt>cdr_arrangement_id</tt>, if provided, while maintaining the <tt>cdr_arrangement_id</tt> between such authorisations</li>
<li><bcp14>SHALL</bcp14> revoke previously issued Access and refresh tokens when modifying existing authorisation grants;</li>
<li><bcp14>SHALL</bcp14> support the Provider CDR Arrangement Revocation Endpoint (PCARE);</li>
<li><bcp14>SHALL</bcp14> publish the url for the [Provider CDR Arrangement Revocation Endpoint (PCARE)] as an attribute named <tt>cdr_arrangement_revocation_endpoint</tt> within the OpenID Connect Discovery 1.0 <xref target="OIDC-Discovery"/> endpoint response;</li>
</ol>

<section anchor="request-object"><name>Request Object</name>
<t>The request object submitted to the authorisation server:</t>

<ol spacing="compact">
<li><bcp14>SHALL</bcp14> support an optional integer parameter of <tt>sharing_duration</tt> representing the number of seconds requested for data sharing. The default value of this parameter <bcp14>SHALL</bcp14> be <tt>0</tt> and the maximum value <bcp14>SHALL NOT</bcp14> exceed <tt>31536000</tt>.</li>
<li><bcp14>SHALL</bcp14> support an optional string parameter <tt>cdr_arrangement_id</tt> referencing an existing CDR Arrangement (see CDR Sharing Arrangement Identifier);</li>
<li><bcp14>SHALL</bcp14> reject requests containing a <tt>cdr_arrangement_id</tt> parameter that is unknown, expired or not associated with the requesting Initiator</li>
</ol>
</section>

<section anchor="claims"><name>Claims</name>
<t>The authorisation server:</t>

<ol spacing="compact">
<li><t><bcp14>SHALL</bcp14> include within the Introspection Endpoint response:</t>

<ol spacing="compact">
<li>the <tt>exp</tt> claim, with a value equal to the expiry time of the underlying CDR Arrangement and;</li>
<li>the <tt>cdr_arrangement_id</tt> claim, containing the assigned [CDR Sharing Arrangement Identifier]</li>
</ol></li>
<li><bcp14>SHALL</bcp14> ensure the <tt>cdr_arrangement_id</tt> claim is persistent and does not change between token interactions;</li>
</ol>
</section>
</section>

<section anchor="provider-cdr-arrangement-revocation-endpoint-pcare"><name>Provider CDR Arrangement Revocation Endpoint (PCARE)</name>
<t>The Provider CDR Arrangement (PCARE) Revocation endpoint accepts a CDR Sharing Arrangement Identifier and immediately revokes the CDR Sharing Arrangement.</t>

<section anchor="pcare-discovery"><name>PCARE Discovery</name>
<t>The PCARE endpoint <bcp14>SHALL</bcp14> be advertised using the <tt>cdr_arrangement_revocation_endpoint</tt> attribute at the OpenID Connect Discovery 1.0 <xref target="OIDC-Discovery"/> endpoint.</t>
</section>

<section anchor="pcare-request"><name>PCARE Request</name>
<t>The PCARE endpoint receives requests using the HTTP POST <xref target="RFC7231"/> method with parameters sent as <tt>application/x-www-form-urlencoded</tt> data as defined in <xref target="W3C.REC-html5-20141028"/>.</t>
<t>In addition to authentication credentials described in Section 2.2 of <xref target="RFC7523"/> the endpoint includes the CDR Sharing Arrangement Identifier as an additional parameter, specified as follows:</t>

<ul spacing="compact">
<li><tt>cdr_arrangement_id</tt>: <bcp14>REQUIRED</bcp14>  The CDR Sharing Arrangement Identifier previously provided in the token and introspection endpoint responses.</li>
</ul>
<t>An example request to the Provider CDR Arrangement Revocation Endpoint is as follows:</t>

<artwork><![CDATA[POST https://data.provider.com.au/arrangements/revoke
HTTP/1.1
Host: data.Provider.com.au
Content-Type: application/x-www-form-urlencoded

client_id=s6BhdRkqt3&
client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&
client_assertion=eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEyNDU2In0.ey ...&
cdr_arrangement_id=5a1bf696-ee03-408b-b315-97955415d1f0
]]>
</artwork>
<t>On receipt of a valid request the Provider authorisation server:</t>

<ol spacing="compact">
<li><bcp14>SHALL</bcp14> validate the client credentials as per Section 2.2 of <xref target="RFC7523"/> and;</li>
<li><bcp14>SHALL</bcp14> validate the <tt>cdr_arrangement_id</tt> relates to a valid CDR Sharing Arrangement and;</li>
<li><bcp14>SHALL</bcp14> verify the CDR Sharing Arrangement referenced by specified <tt>cdr_arrangement_id</tt> belongs to validated client</li>
<li><t>If all of the above conditions are met the authorisation server:</t>

<ul spacing="compact">
<li><bcp14>SHALL</bcp14> immediately invalidate the CDR Arrangement</li>
<li><bcp14>SHALL</bcp14> immediately invalidate all refresh tokens associated with the CDR Arrangement</li>
<li><bcp14>SHALL</bcp14> immediately invalid all access tokens associated with the CDR Arrangement</li>
</ul></li>
</ol>
</section>

<section anchor="pcare-response"><name>PCARE Response</name>

<section anchor="successful-response"><name>Successful Response</name>
<t>In the event of a successful revocation, the authorisation server:</t>

<ol spacing="compact">
<li>If the CDR Sharing Arrangement is revoked, <bcp14>SHALL</bcp14> respond with a 204 HTTP status code containing no content</li>
<li>If the CDR Sharing Arrangement was already revoked prior to the request being received, <bcp14>SHOULD</bcp14> respond with a 204 HTTP status code containing no content</li>
</ol>
</section>

<section anchor="failure-response"><name>Failure Response</name>
<t>In the event of a failure to validate the CDR Arrangement conditions the authorisation server:</t>

<ol spacing="compact">
<li><bcp14>SHALL</bcp14> respond with a  422 Unprocessable Entity response containing a JSON payload structured as as described below and;</li>
<li><bcp14>SHOULD</bcp14> respond with a 503 Service Unavailable if currently unavailable and <bcp14>MAY</bcp14> supply a <tt>Retry-After</tt> indicating the earliest retry time</li>
</ol>

<section anchor="failure-response-body"><name>Failure Response Body</name>
<t>The failure response body is an object with a single attribute of <tt>errors</tt> containing an array of one object with the following fields:</t>

<ul spacing="compact">
<li><tt>code</tt> with the value of <tt>urn:au-cds:error:cds-all:Authorisation/InvalidArrangement</tt></li>
<li><tt>title</tt> with the value of <tt>The arrangement could not be found.</tt></li>
<li><tt>detail</tt> with a value containing the provided <tt>cdr_arrangement_id</tt></li>
</ul>
<t>A non-normative example of the payload is provided below:</t>

<artwork><![CDATA[{
    "errors": [
        {
            "code": "urn:au-cds:error:cds-all:Authorisation/InvalidArrangement",
            "title": "The arrangement could not be found.",
            "detail": "b3f0c9d0-457d-4578-b0cd-52e443ae13c5"
        }
    ]
}
]]>
</artwork>
</section>
</section>
</section>
</section>
</section>

<section anchor="initiator"><name>Initiator</name>
<t>The following provisions apply to participants operating individual Initiators.</t>

<section anchor="authorisation-client"><name>Authorisation Client</name>
<t>An Initiators authorisation client:</t>

<ol spacing="compact">
<li><bcp14>SHALL</bcp14> support the provisions specified in Section 4 of <xref target="DATARIGHTPLUS-INFOSEC-BASELINE"/></li>
<li><bcp14>SHALL</bcp14> support the submission of Request Object parameters outlined in [Request Object]</li>
<li><t><bcp14>SHALL</bcp14> call the [Provider CDR Arrangement Revocation Endpoint (PCARE)] following;</t>

<ol spacing="compact">
<li>revocation request is requested by the Consumer using the Initiator Consumer Dashboard or;</li>
<li>where a refresh token has not been issued, as soon as practicable following the completion of data collection</li>
</ol></li>
<li><bcp14>SHALL</bcp14> support the [Initiator CDR Arrangement Revocation Endpoint (ICARE)]</li>
<li><bcp14>SHALL</bcp14> retry requests to the [Provider CDR Arrangement Revocation Endpoint (PCARE)] where the response received was a HTTP Status 503. The retry time <bcp14>SHOULD</bcp14> be informed by the presence of the <tt>Retry-After</tt> header.</li>
</ol>
</section>

<section anchor="initiator-cdr-arrangement-revocation-endpoint-icare"><name>Initiator CDR Arrangement Revocation Endpoint (ICARE)</name>
<t>The Initiator CDR Arrangement (ICARE) Revocation endpoint accepts a CDR Sharing Arrangement Identifier and immediately revokes the CDR Sharing Arrangement.</t>

<section anchor="icare-request"><name>ICARE Request</name>
<t>The protected resource calls the ICARE endpoint using an HTTP POST <xref target="RFC7231"/> request with parameters sent as <tt>application/x-www-form-urlencoded</tt> data as defined in <xref target="W3C.REC-html5-20141028"/>.</t>
<t><tt>cdr_arrangement_jwt</tt>
<bcp14>REQUIRED</bcp14>. A single signed <xref target="JWT"/> containing the following parameters:</t>

<ol spacing="compact">
<li><tt>cdr_arrangement_id</tt> representing the CDR Sharing Arrangement Identifier previously provided in the introspection endpoint responses;</li>
<li><tt>iss</tt>: Provider ID issued by the Ecosystem Authority</li>
<li><tt>sub</tt>: Provider ID issued by the Ecosystem Authority</li>
<li><tt>aud</tt>: URI to the ICARE endpoint</li>
<li><tt>jti</tt>: A unique identifier for the token</li>
<li><tt>exp</tt>: Expiration time on or after the JWT must not be accepted</li>
</ol>
<t>In addition, the client includes an <tt>Authorization</tt> header parameter with a Bearer token containing a single signed <xref target="JWT"/> with the following parameters:</t>

<ol spacing="compact">
<li><tt>iss</tt>: Provider ID issued by the Ecosystem Authority</li>
<li><tt>sub</tt>: Provider ID issued by the Ecosystem Authority</li>
<li><tt>aud</tt>: URI to the ICARE endpoint</li>
<li><tt>jti</tt>: A unique identifier for the token</li>
<li><tt>exp</tt>: Expiration time on or after the JWT must not be accepted</li>
</ol>
<t>For example, a Provider may request CDR Arrangement revocation with the following request:</t>

<artwork><![CDATA[POST https://data.Initiator.com.au/arrangements/revoke HTTP/1.1
Host: data.Initiator.com.au
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEyNDU2In0.ey …

cdr_arrangement_jwt=eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEyNDU2In0.ey ...&
]]>
</artwork>
<t>The Initiator first validates the Provider credentials and then verifies whether the CDR Sharing Arrangement Identifier exists and was issued by the Provider making the CDR Arrangement Revocation request. If this validation fails, the request is refused and the Provider is informed of the error by the ICARE endpoint as described below.</t>
<t>In the next step, the Initiator invalidates the CDR Arrangement and <bcp14>SHOULD</bcp14> discard associated tokens. Data Minimisation events <bcp14>SHOULD</bcp14> also be triggered on receipt of this event.</t>
</section>

<section anchor="icare-response"><name>ICARE Response</name>

<section anchor="successful-response-1"><name>Successful Response</name>
<t>In the event of a successful revocation, the Initiator:</t>

<ol spacing="compact">
<li>if the CDR Sharing Arrangement is revoked, <bcp14>SHALL</bcp14> respond with a 204 HTTP status code containing no content</li>
<li>if the CDR Sharing Arrangement was already revoked prior to the request being received, <bcp14>SHOULD</bcp14> respond with a 204 HTTP status code containing no content</li>
</ol>
</section>

<section anchor="failure-response-1"><name>Failure Response</name>
<t>In the event of a failure to validate the CDR Arrangement conditions the Initiator:</t>

<ol spacing="compact">
<li><bcp14>SHALL</bcp14> respond with a  422 Unprocessable Entity response containing a JSON payload structured as as described below and;</li>
<li><bcp14>SHOULD</bcp14> respond with a 503 Service Unavailable if currently unavailable and <bcp14>MAY</bcp14> supply a <tt>Retry-After</tt> indicating the earliest retry time</li>
</ol>

<section anchor="failure-response-body-1"><name>Failure Response Body</name>
<t>The failure response body is an object with a single attribute of <tt>errors</tt> containing an array of one object with the following fields:</t>

<ul spacing="compact">
<li><tt>code</tt> with the value of <tt>urn:au-cds:error:cds-all:Authorisation/InvalidArrangement</tt></li>
<li><tt>title</tt> with the value of <tt>The arrangement could not be found.</tt></li>
<li><tt>detail</tt> with a value containing the provided <tt>cdr_arrangement_id</tt></li>
</ul>
<t>A non-normative example of the payload is provided below:</t>

<artwork><![CDATA[{
    "errors": [
        {
            "code": "urn:au-cds:error:cds-all:Authorisation/InvalidArrangement",
            "title": "The arrangement could not be found.",
            "detail": "b3f0c9d0-457d-4578-b0cd-52e443ae13c5"
        }
    ]
}
]]>
</artwork>
</section>
</section>
</section>
</section>
</section>

<section anchor="implementation-considerations"><name>Implementation Considerations</name>
<t>Where a Initiator, by way of the [Request Object], requests to update an existing authorisation grant through the supply of the <tt>cdr_arrangement_id</tt> some ecosystems may apply additional expectations with respect to the authorisation flow. Within the Australian Consumer Data Right this is summarised within the <em>CX Standards: Amending Authorisation</em> section of the <xref target="CDS"/>.</t>
</section>

<section anchor="security-considerations"><name>Security Considerations</name>
<t>The CDR Sharing Arrangement Identifier <bcp14>SHALL NOT</bcp14> be guessable, derivable nor identify the Consumer.</t>
</section>

</middle>

<back>
<references><name>Normative References</name>
<reference anchor="CDS" target="https://consumerdatastandardsaustralia.github.io/standards">
  <front>
    <title>Consumer Data Standards (CDS)</title>
    <author>
      <organization>Data Standards Body (Treasury)</organization>
    </author>
  </front>
</reference>
<reference anchor="DATARIGHTPLUS-INFOSEC-BASELINE" target="https://datarightplus.github.io/datarightplus-infosec-baseline/draft-authors-datarightplus-infosec-baseline.html">
  <front>
    <title>DataRight+ Security Profile: Baseline</title>
    <author fullname="Stuart Low" initials="S." surname="Low">
      <organization>Biza.io</organization>
    </author>
  </front>
</reference>
<reference anchor="DATARIGHTPLUS-ROSETTA" target="https://datarightplus.github.io/datarightplus-rosetta/draft-authors-datarightplus-rosetta.html">
  <front>
    <title>DataRight+ Rosetta Stone</title>
    <author fullname="Stuart Low" initials="S." surname="Low">
      <organization>Biza.io</organization>
    </author>
  </front>
</reference>
<reference anchor="JWT" target="https://datatracker.ietf.org/doc/html/rfc7519">
  <front>
    <title>JSON Web Token (JWT)</title>
    <author fullname="M. Jones">
      <organization>Microsoft</organization>
    </author>
    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization>Ping Identity</organization>
    </author>
    <author fullname="N. Sakimura">
      <organization>Nomura Research Institute</organization>
    </author>
    <date year="2015" month="May"/>
  </front>
</reference>
<reference anchor="OIDC-Discovery" target="https://openid.net/specs/openid-connect-discovery-1_0.html">
  <front>
    <title>OpenID Connect Discovery 1.0 incorporating errata set 1</title>
    <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
      <organization>NRI</organization>
    </author>
    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization>Ping Identity</organization>
    </author>
    <author fullname="Mike Jones" initials="M." surname="Jones">
      <organization>Microsoft</organization>
    </author>
    <author initials="E." surname="Jay">
      <organization>Illumila</organization>
    </author>
    <date year="2014" month="Nov" day="8"/>
  </front>
</reference>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7231.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7523.xml"/>
<xi:include href="https://bib.ietf.org/public/rfc/bibxml4/reference.W3C.REC-html5-20141028.xml"/>
</references>

</back>

</rfc>
