<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "http://xml.resource.org/authoring/rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<rfc category="std" docName="draft-sakimura-oauth-requrl-03" ipr="trust200902">
  <?rfc toc="yes"?>
  <?rfc tocompact="yes"?>
  <?rfc tocdepth="3"?>
  <?rfc tocindent="yes"?>
  <?rfc symrefs="yes"?>
  <?rfc sortrefs="yes"?>
  <?rfc comments="yes"?>
  <?rfc inline="yes"?>
  <?rfc compact="yes"?>
  <?rfc subcompact="no"?>
  <?rfc strict="no"?>

  <front>
    <title abbrev="oauth-json-request">Request by JWS ver.1.0 for OAuth
    2.0</title>

    <author fullname="Nat Sakimura" initials="N." role="editor"
            surname="Sakimura">
      <organization>Nomura Research Institute</organization>

      <address>
        <postal>
          <street>1-6-5 Marunouchi, Marunouchi Kitaguchi Bldg.</street>
          <city>Chiyoda-ku</city>
          <code>100-0005</code>
          <region>Tokyo</region>
          <country>Japan</country>
        </postal>
        <phone>+81-3-5533-2111</phone>
        <email>n-sakimura@nri.co.jp</email>
      </address>
    </author>

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

    <date day="6" month="November" year="2012" />
    <area>Applications</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <keyword>RFC</keyword>
    <keyword>Request for Comments</keyword>
    <keyword>I-D</keyword>
    <keyword>Internet-Draft</keyword>
    <keyword>Assertion</keyword>
    <keyword>Claim</keyword>
    <keyword>Security Token</keyword>
    <keyword>OAuth</keyword>
    <keyword>JavaScript Object Notation</keyword>
    <keyword>JSON</keyword>
    <keyword>JSON Web Token</keyword>
    <keyword>JWT</keyword>
    <keyword>JSON Web Signature</keyword>
    <keyword>JWS</keyword>
    <keyword>JSON Web Encryption</keyword>
    <keyword>JWE</keyword>

    <abstract>
      <t>The authorization request in OAuth 2.0 utilizes query parameter
      serizalization. This specification defines the authorization request
      using JWT serialization. The request is sent thorugh 'request' parameter
      or by reference through 'request_url' that points to the JWT, 
      allowing the request to be optionally signed and encrypted. </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The parameters 'request' and 'request_url' are introduced as
      additional authorization request parameters for the <xref
      target="RFC6749">OAuth 2.0</xref> flows. The 'request' parameter is a JSON Web
      Token (JWT) <xref target="JWT"></xref> whose body holds the JSON encoded
      OAuth 2.0 authorization request parameters. The <xref
      target="JWT"></xref> can be passed to the authorization endpoint by
      reference, in which case the parameter 'request_uri' is used instead of
      the 'request'.</t>

      <t>Using <xref target="JWT"></xref> as the request encoding instead of
      query parameters has several advantages:</t>

      <t><list style="numbers">
          <t>The request may be signed so that integrity check may be
          implemented. If a suitable algorithm is used for the signing, then
          non-repudiation property may be obtained in addition.</t>

          <t>The request may be encrypted so that end-to-end confidentiality
          may be obtained even if in the case TLS connection is terminated at
          a gateway or a similar device.</t>
        </list></t>

      <t>There are a few cases that request by reference is useful such
      as:</t>

      <t><list style="numbers">
          <t>When it is detected that the User Agent dose't suport long URLs - It
          is entirely possible that some extensions may extend the URL. For
          example, the client might want to send a public key with the
          request.</t>

          <t>Static signature: The client may make a signed request file and
          put it on the client. This may just be done by a client utility or
          other process, so that the private key does not have to reside on
          the client,  simplifying programming.</t>

          <t>When the server wants the requests to be cacheable - The
          request_uri may include a sha256 hash of the file, as defined in <xref
          target="FIPS180-2">FIPS180-2</xref>, the server knows if
          the file has changed without fetching it, so it does not have to
          re-fetch a same file, which is a win as well.</t>

          <t>When the client wants to simplify the implementation without
          compromising the security. If the request parameters go through the
          Browser, they may be tampered in the browser even if TLS was used.
          This implies we need to have signature on the request as well.
          However, if HTTPS request_url was used, it is not going to be
          tampered, thus we now do not have to sign the request. This
          simplifies the implementation.</t>
        </list></t>

      <t>
        This capability is in use by OpenID Connect. 
      </t>

      <section title="Requirements Language">
        <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">RFC 2119</xref>.</t>
      </section>
    </section>

    <section title="Terminology">
      <t>Following parameters are defined as a request and response parameter.
      <list style="hanging">
          <t hangText="request object">A <xref target="JWT"></xref> that holds
          OAuth 2.0 authorization requests as JSON object in its body. It MAY
          include all the potential variables including extension and
          non-oauth variables. Request object can optionally be digitally
          signed or signed and encrypted. To sign, <xref target="JWS"></xref>
          is used. To encrypt, <xref target="JWE"></xref> is used.</t>

          <t hangText="request_uri">The absolute URL from which the request
          object is obtained.</t>

          <t hangText="Request File">This is a physical or logical file that
          the 'request_url' points to.</t>
        </list></t>
    </section>

    <section anchor="aro" title="Authorization Request Object">
      <t>
        The Authorization Request object is used to provide authorization
        request parameters. It contains OAuth 2.0 authorization
        request parameters including extension parameters. It
        is a <xref target="JWS">JSON Web Signature (JWS)</xref> signed 
        <xref target="JWT">JWT</xref> that has the JSON
        object that holds the OAuth 2.0 authorization request parameters. The
        parameters are included as the top level members of <xref
        target="RFC4627">JSON</xref>. Parameter names and string values are
        included as JSON strings. Numerical values are included as JSON numbers.
        It MAY include any extension parameters. This <xref
        target="RFC4627">JSON</xref> constitues the body of the <xref
        target="JWT"></xref>.
      </t>
      <t>
        The Authorization Request Object MAY be signed or unsigned (plaintext).
        When it is plaintext, this is indicated by use of the
        <spanx style="verb">none</spanx> algorithm <xref target="JWA" />
        in the JWS header.  If signed, the Authorization Request Object
        SHOULD contain the Claims
        <spanx style="verb">iss</spanx> (issuer)
        and <spanx style="verb">aud</spanx> (audience) as members,
        with their semantics being the same as defined in the
        <xref target="JWT">JWT</xref> specification.
      </t>

      <t>
        The Authorization Request Object MAY also be encrypted using
        <xref target="JWE">JWE</xref>
        after signing, with nesting performed in the same manner as
        specified for JWTs <xref target="JWT"/>.
        The Authorization Request Object MAY alternatively be sent by reference using 
        <spanx style="verb">request_uri</spanx> parameter. 
      </t>

      <t>
        OAuth 2.0 Authorization Request parameters that are not included in
        the Authorization Request Object MAY be sent as a query parameter. 
        If the parameter exists both in the query string and the 
        Authorization Request Object, they MUST exactly match. 
      </t>

      <t>
        If a required parameter is not present in neither the query parameter or 
        the Authorization Request Object, it forms a malformed request. 
      </t>

      <t>Following is the example of the JSON which consitutes the body of the
      <xref target="JWT"></xref>.</t>

      <figure>
        <artwork><![CDATA[{
    "redirect_url":"https://example.com/rp/endpoint_url",
    "cliend_id":"http://example.com/rp/"
}]]></artwork>
      </figure>

      <t></t>

      <t>The following is a non-normative example of a <xref
      target="JWT"></xref> encoded authorization request object. It includes
      extension variables such as "nonce", "userinfo", and "id_token". Note
      that the line wraps within the values are for display purpose only:</t>

      <figure>
        <artwork><![CDATA[
JWT algorithm = HS256
HMAC HASH Key = 'aaa'

JSON Encoded Header = "{"alg":"HS256","typ":"JWT"}"
JSON Encoded Payload = "{"response_type":"code id_token",
    "client_id":"s6BhdRkqt3",
    "redirect_uri":"https://client.example.com/cb",
    "scope":"openid profile",
    "state":"af0ifjsldkj",
    "nonce":"n-0S6_WzA2Mj",
    "userinfo":{"claims":{"name":null,"nickname":{"optional":true},
        "email":null,"verified":null,
        "picture":{"optional":true}},"format":"signed"},
    "id_token":{"max_age":86400,"iso29115":"2"}}"

JWT = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNwb25zZV90eXBlIjoiY29kZ
    SBpZF90b2tlbiIsImNsaWVudF9pZCI6InM2QmhkUmtxdDMiLCJyZWRpcmVjdF91cmkiO
    iJodHRwczpcL1wvY2xpZW50LmV4YW1wbGUuY29tXC9jYiIsInNjb3BlIjoib3BlbmlkI
    HByb2ZpbGUiLCJzdGF0ZSI6ImFmMGlmanNsZGtqIiwidXNlcmluZm8iOnsiY2xhaW1zI
    jp7Im5hbWUiOm51bGwsIm5pY2tuYW1lIjp7Im9wdGlvbmFsIjp0cnVlfSwiZW1haWwiO
    m51bGwsInZlcmlmaWVkIjpudWxsLCJwaWN0dXJlIjp7Im9wdGlvbmFsIjp0cnVlfX0sI
    mZvcm1hdCI6InNpZ25lZCJ9LCJpZF90b2tlbiI6eyJtYXhfYWdlIjo4NjQwMCwiaXNvM
    jkxMTUiOiIyIn19.2OiqRgrbrHkA1FZ5p_7bc_RSdTbH-wo_Agk-ZRpD3wY]]></artwork>
      </figure>
    </section>

    <section title="Authorization Request">
      <t>The client constructs the request URI by adding the following
      parameters to the query component of the authorization endpoint URI
      using the "application/x-www-form-urlencoded" format:</t>

      <t><list style="hanging">
          <t hangText="request">REQUIRED unless <spanx style="verb">request_uri</spanx>
          is specified. The <xref target="aro">authorization request
          object</xref> that holds authorization request parameters stated in
          the section 4 of <xref target="RFC6749">OAuth 2.0</xref>.</t>

          <t hangText="request_uri">REQUIRED unless <spanx style="verb">request</spanx>
          is specified. The absolute URL that points to the <xref
          target="aro">authorization request object</xref> that holds
          authorization request parameters stated in the section 4 of <xref
          target="RFC6749">OAuth 2.0</xref>. When sending the request by <spanx
          style="verb">request_uri</spanx>, the client MAY provide the sha256
          hash as defined in <xref target="FIPS180-2">FIPS180-2</xref>of the
          Request File as the fragment to it to assist the cache utilization
          decision of the Authorization Server.</t>

          <t hangText="state">RECOMMENDED. An opaque value used by the client
          to maintain state between the request and callback. The
          authorization server includes this value when redirecting the
          user-agent back to the client. The parameter SHOULD be used for
          preventing cross-site request forgery as described in Section 10.12.
          of <xref target="RFC6749">OAuth 2.0</xref></t>
        </list>The client directs the resource owner to the constructed URI
      using an HTTP redirection response, or by other means available to it
      via the user-agent.</t>

      <t>For example, the client directs the end-user's user-agent to make the
      following HTTPS request (line breaks are for display purposes only):</t>

      <figure>
        <artwork><![CDATA[GET /authorize?request_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1
Host: server.example.com]]></artwork>
      </figure>

      <t>The autorization request object MAY be signed AND/OR encrypted.</t>

      <t>Upon receipt of <spanx style="verb">request_uri</spanx> in the
      request, the authorization server MUST send a GET request to the <spanx
      style="verb">request_uri</spanx> to retrieve the authorization request
      object unless it is already cached at the Authorization Server.</t>

      <t>If the response was signed AND/OR encrypted, it has to be decoded
      accordingly before being processed.</t>

      <t>Then, the Authorization Server MUST reconstruct the complete client
      request from the original HTTP request and the content of the request
      object. Then, the process continues as described in Section 3 of <xref
      target="RFC6749">OAuth 2.0</xref> .</t>
    </section>

    <section title="Authorization Server Response">
      <t>Authorization Server Response is created and sent to the client as in
      Section 4 of <xref target="RFC6749">OAuth 2.0</xref> .</t>

      <t>In addition, this document defines additional 'error' values as
      follows:</t>

      <t><list style="symbols">
          <t>"invalid_request_uri" - The provided request_uri was not
          available.</t>

          <t>"invalid_request_format" - The Request Object format was
          invalid.</t>

          <t>"invalid_request_params" - The parameter set provided in the
          Request Object was invalid.</t>
        </list></t>
    </section>

    <section anchor="IANA" title="IANA  Considerations">
      <t>This document registers following error strings to the OAuth Error
      Registry.</t>

      <t><list style="symbols">
          <t>"invalid_request_uri" - The provided request_uri was not
          available.</t>

          <t>"invalid_request_format" - The Request Object format was
          invalid.</t>

          <t>"invalid_request_params" - The parameter set provided in the
          Request Object was invalid.</t>
        </list></t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>In addition to the all the security considerations discussed in <xref
      target="RFC6749">OAuth 2.0</xref>, the following security considerations
      SHOULD be taken into account. </t>

      <t>When sending the authorization request object through <spanx
      style="verb">request</spanx> parameter, it SHOULD be signed with <xref
      target="JWS"></xref>. </t>

      <t>When obtaining the Request FIle, the Authorization Server SHOULD use
      either HTTP over TLS 1.2 as defined in <xref
      target="RFC5246">RFC5246</xref> AND/OR <xref target="JWS"></xref>.</t>

      <t>If the request object contains personally identifiable or sensitive
      information, the "request_uri" MUST be of one-time use and MUST have
      large enough entropy deemed necessary with applicable security policy.
      For higher security requirement, using <xref target="JWE"></xref> is
      strongly recommended.</t>

      <t>[[ToDo]]</t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>Following people contributed to creating this document through <xref
      target="openid_ab">the OpenID Connect 1.0</xref> .</t>

      <t>Breno de Medeiros (Google), Hideki Nara (TACT), John Bradley
      (Ping Identity) &lt;author&gt;, Nat Sakimura (NRI) &lt;author/editor&gt;,
      Ryo Itou (Yahoo! Japan), George Fletcher (AOL), Justin Richer (Mitre),
      Edmund Jay (MGI1), (add yourself).</t>

      <t>In addition following people contributed to this and previous
      versions through The OAuth Working Group.</t>

      <t>David Recordon (Facebook), Luke Shepard (Facebook), James H. Manger
      (Telstra), Marius Scurtescu (Google), John Panzer (Google), Dirk Balfanz
      (Google), (add yourself).</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119"?>

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.4627'?>

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246'?>

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.6749'?>

      <reference anchor="FIPS180-2">
        <front>
          <title>Secure Hash Signature Standard</title>

          <author>
            <organization>U.S. Department of Commerce</organization>
          </author>

          <author>
            <organization>National Institute of Standards and
            Technology</organization>
          </author>

          <date day="1" month="August" year="2002" />
        </front>

        <seriesInfo name="FIPS" value="180-2" />

        <format target="http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf"
                type="PDF" />

        <annotation>Defines Secure Hash Algorithm 256 (SHA256)</annotation>
      </reference>

      <reference anchor="JWT">
        <front>
          <title>JSON Web Token</title>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization>Microsoft</organization>

            <address>
              <email>mbj@microsoft.com</email>

              <uri>http://self-issued.info/</uri>
            </address>
          </author>

          <author fullname="Dirk Balfanz" initials="D." surname="Balfanz">
            <organization>Google</organization>

            <address>
              <email>balfanz@google.com</email>
            </address>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization>Ping Identity</organization>

            <address>
              <email>ve7jtb@ve7jtb.com</email>
            </address>
          </author>

          <author fullname="Yaron Y. Goland" initials="Y.Y." surname="Goland">
            <organization>Microsoft</organization>

            <address>
              <email>yarong@microsoft.com</email>
            </address>
          </author>

          <author fullname="John Panzer" initials="J." surname="Panzer">
            <organization>Google</organization>

            <address>
              <email>jpanzer@google.com</email>
            </address>
          </author>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization>Nomura Research Institute</organization>

            <address>
              <email>n-sakimura@nri.co.jp</email>
            </address>
          </author>

          <author fullname="Paul Tarjan" initials="P." surname="Tarjan">
            <organization>Facebook</organization>

            <address>
              <email>pt@fb.com</email>
            </address>
          </author>

          <date day="11" month="July" year="2011" />
        </front>
      </reference>

      <reference anchor="JWS">
        <front>
          <title>JSON Web Signature (JWS)</title>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization>Microsoft</organization>

            <address>
              <email>mbj@microsoft.com</email>

              <uri>http://self-issued.info/</uri>
            </address>
          </author>

          <author fullname="Dirk Balfanz" initials="D." surname="Balfanz">
            <organization>Google</organization>

            <address>
              <email>balfanz@google.com</email>
            </address>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization>Ping Identity</organization>

            <address>
              <email>ve7jtb@ve7jtb.com</email>
            </address>
          </author>

          <author fullname="Yaron Y. Goland" initials="Y.Y." surname="Goland">
            <organization>Microsoft</organization>

            <address>
              <email>yarong@microsoft.com</email>
            </address>
          </author>

          <author fullname="John Panzer" initials="J." surname="Panzer">
            <organization>Google</organization>

            <address>
              <email>jpanzer@google.com</email>
            </address>
          </author>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization>Nomura Research Institute</organization>

            <address>
              <email>n-sakimura@nri.co.jp</email>
            </address>
          </author>

          <author fullname="Paul Tarjan" initials="P." surname="Tarjan">
            <organization>Facebook</organization>

            <address>
              <email>pt@fb.com</email>
            </address>
          </author>

          <date day="29" month="April" year="2011" />
        </front>

        <format target="http://self-issued.info/docs/draft-jones-json-web-signature.html"
                type="HTML" />
      </reference>

      <reference anchor="JWE">
        <front>
          <title>JSON Web Encryption (JWE)</title>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization>Microsoft</organization>

            <address>
              <email>mbj@microsoft.com</email>

              <uri>http://self-issued.info/</uri>
            </address>
          </author>

          <date day="28" month="March" year="2011" />
        </front>

        <format target="http://self-issued.info/docs/draft-jones-json-web-encryption.html"
                type="HTML" />
      </reference>

      <reference anchor="JWA">
        <front>
          <title>JSON Web Algorithms (JWA)</title>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization>Microsoft</organization>

            <address>
              <email>mbj@microsoft.com</email>

              <uri>http://self-issued.info/</uri>
            </address>
          </author>

          <date day="28" month="March" year="2011" />
        </front>

        <format target="http://self-issued.info/docs/draft-jones-json-web-encryption.html"
                type="HTML" />
      </reference>
    </references>

    <references title="Informative References">
      <reference anchor="openid_ab">
        <front>
          <title>OpenID Connect 1.0</title>

          <author fullname="openid-specs-ab@openid.net" initials=""
                  surname="openid-specs-ab@openid.net">
            <organization></organization>
          </author>

          <date day="14" month="October" year="2011" />
        </front>
      </reference>
    </references>
  </back>
</rfc>
