<?xml version="1.0" encoding="us-ascii"?>
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="std" docName="draft-campbell-oauth-resource-indicators-00"
     ipr="trust200902">
  <front>
    <title abbrev="OAuth Resource Indicators">Resource Indicators for OAuth 2.0</title>

    <author fullname="Brian Campbell" initials="B." surname="Campbell">
      <organization>Ping Identity</organization>
      <address><email>brian.d.campbell@gmail.com</email></address>
    </author>

    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization>Ping Identity</organization>
      <address><email>ve7jtb@ve7jtb.com</email></address>
    </author>

    <date />

    <area>Security</area>
    <workgroup>OAuth Working Group</workgroup>

    <keyword>OAuth</keyword>
    <keyword>Resource</keyword>

    <abstract>
      <t>
        This straw-man specification defines an extension to The OAuth 2.0
        Authorization Framework that enables the client and authorization
        server to more explicitly to communicate about the protected
        resource(s) to be accessed.
      </t>
    </abstract>

  </front>

  <middle>
    <section anchor="Introduction" title="Introduction">
<t>
  Several years of deployment and implementation experience with <xref target="RFC6749">OAuth 2.0</xref>
  has uncovered a need, in some circumstances, for the client to explicitly signal to the authorization sever where
  it intends to use the access token it is requesting.
</t>
<t>
  Knowing which resource server will process the access token enables the authorization server to construct the token
  as necessary for that entity. Properly encrypting the token (or content within the token) to a particular resource server, for example,
  requires knowing which resource server will receive and decrypt the token. Furthermore, various resource servers oftentimes have
  different requirements with respect to the data contained in, or referenced by, the token and knowing the resource server
  where the client intends to use the                                                 s
  token allows the the authorization server to mint the token accordingly.
</t>
<t>
  Specific knowledge of the intended recipient(s) of the access token also helps facilitate improved
  security characteristics of the token itself.
  Bearer tokens, currently the only defined type of OAuth access token,
  allow any party in possession of a token to get access to the associated resources.
  To prevent misuse, two important security assumptions must hold:
  bearer tokens must be protected from disclosure in storage and in
  transit and the access token must only be valid for use at a
  specific resource server and for a specific scope.  When the authorization server is informed of
  the resource server that will process the access token, it can restrict the intended audience of that token
  such that it cannot be used at other resource servers.
  <xref target="RFC6750">Section 5.2 of OAuth 2.0 Authorization Framework: Bearer Token Usage</xref>
  prescribes including the token's intended recipients within the token to prevent token redirect.
</t>
<t>
  Scope, from Section 3.3 of <xref target="RFC6749">OAuth 2.0</xref>, sometimes is overloaded to convey the
  location or identity of the resource server, however, doing so isn't always feasible or desirable. Scope is
  typically about what access is being requested rather than where that access will be redeemed
  (e.g. <spanx style="verb">email</spanx>, <spanx style="verb">user:follow</spanx>, <spanx style="verb">user_photos</spanx>,
  and <spanx style="verb">channels:read</spanx> are a small sample of scope values in use).
</t>
<t>
  A means for the client to signal to the authorization sever where it intends to use the access token it's requesting
  is important and useful. A number of implementations and deployments of OAuth 2.0 have already employed proprietary parameters
  toward that end.
  This specification aims to provide a standardized and interoperable alternative to the proprietary approaches going forward.
</t>
    <section anchor="RNC" title="Requirements Notation and Conventions">
<t>
  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL"
  in this document are to be interpreted as described in
  <xref target="RFC2119">RFC 2119</xref>.
</t>
    </section>

    <section anchor="Terminology" title="Terminology">
      <t>
        This specification uses the terms
        "access token",
        "refresh token",
        "authorization server",
        "resource server",
        "authorization endpoint",
        "authorization request",
        "authorization response",
        "token endpoint",
        "grant type",
        "access token request",
        "access token response",
        and "client"
        defined by <xref target="RFC6749">The OAuth 2.0 Authorization Framework</xref>.
      </t>
    </section>

    </section>

    <section anchor="ResourceParameter" title="Resource Parameter">
      <t>
        The client may indicate the resource server(s) for which it is requesting an access token by
        including the following parameter in the request.
      </t>
      <t>
      <list style="hanging">

      <t hangText="resource">
        <vspace/>
        OPTIONAL. The value of the
        <spanx style="verb">resource</spanx>
        parameter indicates a resource server where the requested access token will be used. It MUST be an
        absolute URI, as specified by Section 4.3 of<xref target="RFC3986"/>,
        and MUST NOT include a query or fragment component.  If the authorization server fails to parse the
        provided value or does not consider the resource server acceptable, it MUST reject the request and
        provide an error response with the error code <spanx style="verb">invalid_resource</spanx>. Multiple
        <spanx style="verb">resource</spanx>
        parameters may be used to indicate
        that the issued token is intended to be used at multiple resource servers.
      </t>
      </list>
      </t>
      <t>
        When an access token will be returned from the authorization endpoint, the <spanx style="verb">resource</spanx>
        parameter is used in the authorization request to the authorization endpoint as defined in Section 4.2.1 of <xref target="RFC6749">OAuth 2.0</xref>.
        An example of an authorization request where the client tells the authorization server that it wants a token for use at
        <spanx style="verb">https://rs.example.com/</spanx> is shown in <xref target="authz-endpoint"/> below.
      </t>
<figure title="Protected Resource Request" anchor="authz-endpoint">
<artwork><![CDATA[
  GET /as/authorization.oauth2?response_type=token
     &client_id=s6BhdRkqt3&state=laeb
     &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
     &resource=https%3A%2F%2Frs.example.com%2F HTTP/1.1
  Host: authorization-server.example.com
]]></artwork>
</figure>
      <t>
        When the access token is returned from the token endpoint, the request parameter is included in the token request to the token endpoint.
        Sections 4.1.1, 4.3.1, 4.4.2, 4.5 and 6 of <xref target="RFC6749">OAuth 2.0</xref> define requests to the token endpoint with different grant types.
        An example of a token request, using a refresh token, where the client tells the authorization server that it wants a token for use at
        <spanx style="verb">https://rs.example.com/</spanx> is shown in <xref target="token-endpoint"/> below.
      </t>
<figure title="Protected Resource Request" anchor="token-endpoint">
<artwork><![CDATA[
  POST /as/token.oauth2 HTTP/1.1
  Host: authorization-server.example.com
  Authorization: Basic czZCaGRSa3F0Mzpoc3FFelFsVW9IQUU5cHg0RlNyNHlJ
  Content-Type: application/x-www-form-urlencoded

  grant_type=refresh_token
  &refresh_token=4LTC8lb0acc6Oy4esc1Nk9BWC0imAwH
  &resource=https%3A%2F%2Frs.example.com%2F
]]></artwork>
</figure>
      <t>
        The <spanx style="verb">resource</spanx> parameter indicates the physical location of resource server, typically as an https URL,
        where the client intends to use
        the requested access token. This enables the authorization server to apply policy as appropriate
        for the resource, such as determining the type and content of the token to be issued, if and how
        the token is to be encrypted, and applying appropriate audience restrictions to the token.
      </t>
      <t>
        The client SHOULD provide the most specific URI that it can for the set of resources or API it intends to access.
        In practice a client will know a base URI for the resource server application that it interacts with, which
        is appropriate to use as the value of the <spanx style="verb">resource</spanx> parameter.
        The client SHOULD use the base URI for the API unless specific knowledge of resource server
        dictates the client use a shorter path.
        For example, the value <spanx style="verb">https://rs.example.com/</spanx> would be used
        for a resource server that is the exclusive application on that host, however,
        if the resource server is one of many applications on that host, something like
        <spanx style="verb">https://rs.example.com/application/</spanx> would be used.
        Another example, for an API like <xref target="RFC7644">SCIM</xref> that has multiple endpoints such as
        <spanx style="verb">https://rs.example.com/scim/Users</spanx>,
        <spanx style="verb">https://rs.example.com/scim/Groups</spanx>, and
        <spanx style="verb">https://rs.example.com/scim/Schemas</spanx>
        The client should use <spanx style="verb">https://rs.example.com/scim/</spanx> as the resource
        so that the issued access token is valid for all the endpoints of the SCIM API.
      </t>
      <t>
        The authorization server SHOULD audience restrict the access token to the
        resource server(s) indicated by the <spanx style="verb">resource</spanx> parameter.
        Audience restrictions can be communicated in <xref target="RFC7519">JSON Web Tokens</xref> with the <spanx style="verb">aud</spanx> claim
        and the top-level member of the same name provides the audience restriction information in a <xref target="RFC7662">Token Introspection</xref> response.
        The authorization server may use the exact <spanx style="verb">resource</spanx> value as the audience or it may map from that value to a more
        general URI or abstract identifier for the resource server.
      </t>
      <t>
        The requested resource pertains to the access token that is the expected result of the request and
        not to the underlying access granted by the resource owner.
      </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
<t>
  [[TODO:
  "invalid_resource" for authorization response and token response and
  "resource" for authorization request and token request. ]]
</t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>
        An access token that is audience restricted to a resource server, which obtains the
        token legitimately, cannot be used to access resources on behalf of the
        resource owner at other resource servers. The <spanx style="verb">resource</spanx>
        parameter enables a client to indicate the resource server where the requested access
        token will be used, which in turn enables the authorization server to apply the
        appropriate audience restrictions to the token.
      </t>
      <t>
        Some Resource servers may host user content or be multi-tenant. In order to avoid attacks that might
        confuse a client into sending a AT to a user controlled resource it is important to use the a specific
        resource URI including path and not use just a host with no path. This will cause any AT issued for
        accessing the user controlled resource to have a invalid audience if replayed against the legitimate
        resource API.
      </t>
      <t>
        Although multiple occurrences of the <spanx style="verb">resource</spanx> parameter
        may be included in a request, using only a single <spanx style="verb">resource</spanx> parameter
        is encouraged. A bearer token that has multiple intended recipients (audiences) can be used by
        any one of those recipients at any other. Thus, a high degree of trust between the involved parties
        is needed when using access tokens with multiple audiences. Furthermore an authorization server may
        be unwilling or unable to fulfill a token request with multiple resources.
      </t>
      <t>
        [[TODO: I continue to question the value of allowing multiple resources vs the functional and security
        complexity that comes with doing so. Writing the preceding paragraph just underscores that concern. So
        just noting it here.]]
      </t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6749.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml' ?>
    </references>

    <references title="Informative References">
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7662.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7519.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6750.xml' ?>
      <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7644.xml' ?>

      <reference anchor="I-D.draft-tschofenig-oauth-audience">
        <front>
          <title>OAuth 2.0: Audience Information</title>
          <author fullname="Hannes Tschofenig" initials="H" surname="Tschofenig"/>
          <date month="February" year="2013"/>
        </front>
        <seriesInfo value="draft-tschofenig-oauth-audience" name="Internet-Draft"/>
        <format target="https://tools.ietf.org/html/draft-tschofenig-oauth-audience-00" type="HTML" />
      </reference>
    </references>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The following individuals contributed to discussions relating to and giving rise to this draft specification:</t>
      <t>
        George Fletcher,
        Hannes Tschofenig (for authoring <xref target="I-D.draft-tschofenig-oauth-audience"/>),
        Hans Zandbelt,
        Justin Richer,
        Michael Jones,
        Nat Sakimura,
        Phil Hunt,
        Sergey Beryozkin,
        and
        Anthony "no go" Nadalin.
      </t>

    </section>


    <section anchor="History" title="Document History">
      <?rfc subcompact="yes"?>
      <t>
	[[ to be removed by the RFC Editor before publication as an RFC ]]
      </t>

      <t>
        -00
        <list style='symbols'>
          <t>
            Initial draft to define a resource parameter for OAuth 2.0.
	        </t>
        </list>
      </t>
      <?rfc subcompact="no"?>
    </section>     

  </back>
</rfc>