<?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-ietf-oauth-jwsreq-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-jws-req">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>
        <uri>http://nat.sakimura.org/</uri>
      </address>
    </author>

    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization>Ping Identity</organization>

      <address>
        <postal>
          <street>Casilla 177, Sucursal Talagante</street>

          <city>Talagante</city>

          <region>RM</region>

          <code/>

          <country>Chile</country>
        </postal>

        <phone>+44 20 8133 3718</phone>

        <facsimile/>

        <email>ve7jtb@ve7jtb.com</email>

        <uri>http://www.thread-safe.com/</uri>
      </address>
    </author>

    <date day="05" month="July" year="2015"/>

    <area>Security</area>

    <workgroup>OAuth Working Group</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
      serialization. This specification defines the authorization request
      using JWT serialization. The request is sent through <spanx
      style="verb">request</spanx> parameter or by reference through <spanx
      style="verb">request_uri</spanx> parameter that points to the JWT,
      allowing the request to be optionally signed and encrypted.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The parameters <spanx style="verb">request</spanx> and <spanx
      style="verb">request_uri</spanx> are introduced as additional
      authorization request parameters for the <xref target="RFC6749">OAuth
      2.0</xref> flows. The <spanx style="verb">request</spanx> parameter is a
      JSON Web Token (JWT) <xref target="RFC7519"/> whose JWT Claims Set holds the JSON
      encoded OAuth 2.0 authorization request parameters. The <xref
      target="RFC7519"/> can be passed to the authorization endpoint by reference,
      in which case the parameter <spanx style="verb">request_uri</spanx> is
      used instead of the <spanx style="verb">request</spanx>.</t>

      <t>Using <xref target="RFC7519"/> 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 are useful such
      as:</t>

      <t><list style="numbers">
          <t>When it is detected that the User Agent does not support long
          URLs: 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 Object and
          put it at the place where the Authorization Server can access. 
		  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 cache-able: 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 <spanx style="verb">request_uri</spanx> 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 <xref target="openid_ab" />.</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>For the purposes of this specification, the following terms and
      definitions apply.</t>

      <section anchor="request_object" title="Request Object">
        <t><xref target="RFC7519">JWT</xref> that holds OAuth 2.0 authorization
        requests as JWT Claims Set</t>
      </section>

      <section anchor="request_uri" title="Request Object URI">
        <t>Absolute URI from which the <xref target="request_object">Request
        Object</xref> can be obtained</t>
      </section>
    </section>

    <section anchor="aro" title="Request Object">
      <t>A <xref target="request_object">Request Object</xref> is used to
      provide authorization request parameters for OAuth 2.0 authorization
      request. It contains <xref target="RFC6749">OAuth 2.0</xref>
      authorization request parameters including extension parameters. It is a
      <xref target="RFC7515">JSON Web Signature (JWS)</xref> signed <xref
      target="RFC7519">JWT</xref> . The parameters are included as the top-level
      members of <xref target="RFC7159">JSON</xref>. Parameter names and
      string values MUST be included as JSON strings. Numerical values MUST be
      included as JSON numbers. It MAY include any extension parameters. This
      <xref target="RFC7159">JSON</xref> constitutes the <xref
      target="RFC7519">JWT</xref> Claims Set.</t>

      <t>The 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="RFC7518">JWA</xref> 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="RFC7519">JWT</xref> specification.</t>

      <t>The Request Object MAY also be encrypted using <xref
      target="RFC7516">JWE</xref> after signing, with nesting performed in the
      same manner as specified for <xref target="RFC7519">JWT</xref>. The
      Authorization Request Object MAY alternatively be sent by reference
      using <spanx style="verb">request_uri</spanx> parameter.</t>

      <t>REQUIRED OAuth 2.0 Authorization Request parameters that are not
      included in the Request Object MUST be sent as a query parameter. If a
      required parameter is not present in neither the query parameter nor the
      Request Object, it forms a malformed request.</t>

      <t>If the parameter exists in both the query string and the
      Authorization Request Object, 
      the values in the Request Object takes precedence. 
      This means that if it intends to use a cached request object, 
      it cannot include such parameters like 
      <spanx style="verb">state</spanx> that is expected to differ 
      in every request. It is fine to include them in the request object 
      if it is going to be prepared afresh every time. 
      </t>

      <t>Following is the example of the JSON that constitutes the 
      <xref target="RFC7519"/> Claims Set.</t>

      <figure>
        <artwork><![CDATA[{
    "redirect_url":"https://example.com/rp/endpoint_url",
    "cliend_id":"http://example.com/rp/"
}]]></artwork>
      </figure>

      <t/>

      <t>The following is a non-normative example of a <xref target="RFC7519"/>
      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="Request Object URI">
      <t>Instead of sending the Request Object in an OAuth 2.0 authorization
      request directly, this specification allows it to be obtained from the
      Request Object URI. Using this method has an advantage of reducing the
      request size, enabling the caching of the Request Object, and generally
      not requiring integrity protection through a cryptographic operation on
      the Request Object if the channel itself is protected.</t>

      <t>The Request Object URI is sent as a part of the OAuth Authorization
      Request as the value for the parameter called <spanx style="verb">request_uri</spanx>.
      How the Request Object is registered at Request Object URI is out of
      scope of this specification, but it MUST be done in a protected
      channel.</t>

      <t>NOTE: the Request Object MAY be registered at the Authorization
      Server at the client registration time.</t>

      <t>When the Authorization Server obtains the Request Object from Request
      Object URI, it MUST do so over a protected channel. If it is obtained
      from a remote server, it SHOULD use either HTTP over TLS 1.2 as defined
      in <xref target="RFC5246" /> AND/OR <xref target="RFC7515"/>
      with the algorithm considered appropriate at the time.</t>

      <t>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 Object as the fragment
      to it to assist the cache utilization decision of the Authorization
      Server.</t>
    </section>

    <section title="Authorization Request">
      <t>The client constructs the authorization request URI by adding the
      following parameters to the query component of the authorization
      endpoint URI using the <spanx style="verb">application/x-www-form-urlencoded</spanx>
      format:</t>

      <t><list style="hanging">
          <t hangText="request">REQUIRED unless <spanx style="verb">request_uri</spanx>
          is specified. The <xref target="aro">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">Request Object</xref> that holds authorization request
          parameters stated in the section 4 of <xref target="RFC6749">OAuth
          2.0</xref>.</t>

          <t hangText="state">RECOMMENDED. <xref target="RFC6749">OAuth
          2.0</xref> state.</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 authorization 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:<list style="hanging">
          <t hangText="invalid_request_uri">The provided request_uri was not
          available.</t>

          <t hangText="invalid_request_format">The Request Object format was
          invalid.</t>

          <t hangText="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="hanging">
          <t hangText="invalid_request_uri">The provided request_uri was not
          available.</t>

          <t hangText="invalid_request_format">The Request Object format was
          invalid.</t>

          <t hangText="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 <xref target="RFC6819">
      the security considerations discussed in 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 then
      considered appropriate algorithm using <xref target="RFC7515"/>. The <spanx
      style="verb">alg=none</spanx> SHOULD NOT be used in such a case.</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="RFC7516"/> is strongly
      recommended.</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 (Illumila), (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>
	<section title="Revision History" anchor="hist">
		<t>-03</t>
		<t>
			<list style="symbols">
				<t>Fixed the non-normative description about the advantage of static signature. </t>
				<t>Changed the requement for the parameter values in the request iteself and the request object from 'MUST MATCH" to 'Req Obj takes precedence.</t>
			</list>
		</t>
		<t>-02</t>
		<t>
			<list style="symbols">
				<t>Now that they are RFCs, replaced JWS, JWE, etc. with RFC numbers. </t>
			</list>
		</t>

		<t>-01</t>
		<t>
			<list style="symbols">
				<t>Copy Edits.</t>
			</list>
		</t>
	</section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include='reference.RFC.5246'?>
      <?rfc include='reference.RFC.6749'?>
      <?rfc include='reference.RFC.6819'?>
      <?rfc include='reference.RFC.7159'?>
      <?rfc include='reference.RFC.7515'?>
      <?rfc include='reference.RFC.7516'?>
      <?rfc include='reference.RFC.7518'?>
      <?rfc include='reference.RFC.7519'?>

      <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>
    </references>


    <references title="Informative References">
      <reference anchor="openid_ab">
        <front>
          <title>OpenID Connect Core 1.0</title>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization abbrev="NRI">Nomura Research Institute, Ltd.</organization>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization abbrev="Ping Identity">Ping Identity</organization>
          </author>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization abbrev="Microsoft">Microsoft</organization>
          </author>

          <author fullname="Breno de Medeiros" initials="B." surname="de Medeiros">
            <organization abbrev="Google">Google</organization>
          </author>

		  <author fullname="Chuck Mortimore" initials="C." surname="Mortimore">
			<organization abbrev="Salesforce">Salesforce</organization>
		  </author>

          <date day="25" month="February" year="2014"/>
        </front>

	<format target="http://openid.net/specs/openid-connect-core-1_0.html"
                type="HTML" />
      </reference>
    </references>
  </back>
</rfc>
