<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN"
"http://xml.resource.org/authoring/rfc2629.dtd">
<rfc category="exp" docName="oauth2-multiple-response-type-encoding-practices-1_0" ipr="trust200902">
  <?rfc toc="yes" ?>

  <?rfc tocdepth="3" ?>

  <?rfc symrefs="yes" ?>

  <?rfc sortrefs="yes"?>

  <?rfc strict="no" ?>

  <?rfc iprnotified="no" ?>

  <?rfc private="Draft" ?>

  <front>
    <title abbrev="Additional OAuth2 Response Type-draft 1">OAuth2 Multiple Response Type Encoding Practices</title>

    <author fullname="Breno" initials="B." role="editor" surname="de Medeiros">
      <organization abbrev="Google">Google, Inc.</organization>

      <address>
        <email>breno@google.com</email>
      </address>
    </author>

    <author fullname="Marius" initials="M." surname="Scurtescu">
      <organization abbrev="Google">Google, Inc.</organization>

      <address>
        <email>mscurtescu@google.com</email>
      </address>
    </author>

    <author fullname="Paul" initials="P." surname="Tarjan">
      <organization abbrev="Facebook">Facebook</organization>

      <address>
        <email>pt@fb.com</email>
      </address>
    </author>


    <date day="22" month="September" year="2011" />

    <abstract>
      <t>This specification aims to provide guidance on proper encoding of responses to
        OAuth2 Authorization requests, where the request specifies a response type including
        space characters.</t>

      <t>This specification also serves as the registration document for several
        specific new response types, in accordance with the stipulations of
        the OAuth Parameters Registry.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="rnc" title="Requirements Notation and Conventions">
      <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"></xref> .</t>

      <t>Throughout this document, values are quoted to indicate that they are
      to be taken literally. When using these values in protocol messages, the
      quotes MUST NOT be used as part of the value.</t>
    </section>

    <section anchor="terminology" title="Terminology">
      <t>The following definitions define additional terminology used in this
      specification in addition to those defined in <xref
      target="OAuth.2.0">OAuth 2.0</xref>.</t>

      <t><list style="hanging">
          <t hangText="Client and Server">In the traditional client-server
            authentication model, the client requests an access restricted
            resource (protected resource) on the server by authenticating
            with the server using the resource owner's credentials. </t>

          <t hangText="Authorization Endpoint">A web resource mantained by
            the server, and used to obtain authorization (grant) from the
            resource owner via user-agent redirection.</t>

	  <t hangText="Response Type">The client informs the
            authorization server of the desired authorization processing flow using the
            parameter response_type.</t>

          <t hangText="Authorization Endpoint Response Type Registry">
	    Process established by the OAuth2 specification for the registration of new
            response_type parameters.</t>

          <t hangText="Multiple-valued Response Types">The OAuth2 specification allows
            for registration of space-separated response_type values. 
            If a response type contains one of more space characters (%20), it is
            compared as a space-delimited list of values in which the order of
            values does not matter.</t>
       </list></t>
    </section>

    <section title="Encoding Multiple-valued Response Types">
      <t>This specification does not provide guidance if, in a request, response_type includes
        a value that requires the server to return data partially encoded in the query string
        and partially encoded in the fragment.</t>

      <t>Otherwise, if a multiple-valued response type is defined, then it is RECOMMENDED
        that the following encoding rules be applied for the issued response.</t>

      <t>If, in a request, response_type includes only values that require the server
         to return data fully encoded within the query string then
         the returned data in the response for this multiple-valued response_type
         MUST be fully encoded within the query string. This recommendation
         applies to both success and error responses.</t>

      <t>If, in a request, response_type includes any value that requires the server to
        return data fully encoded within the fragment then the returned data in the
        response for this multiple-valued response_type MUST be fully encoded
        within the fragment. This recommendation applies to both success and error responses.</t>

      <t>Rationale: Whenever response_type values include fragment-encoded parts,
        a user-agent client component must be involved to complete processing of the response.
        If a new query parameter is added to the client URI, it will cause the user-agent
        to re-fetch the client URI,
        causing discontinuity of operation of the user-agent-based client components. If instead
        only fragment encoding is used, the user-agent will simply re-active the client
        component, at which time this component may process the fragment and
        also convey any parameters to a client host as necessary, e.g., via XmlHttpRequest.
        Therefore, full fragment encoding always results in lower latency for response processing.</t>
    </section>

    <section title="Id Token Response Type">
      <t>This section registers a new response type, the id_token, in accordance
        with the stipulations in the OAuth2 specification, Section 8.4. The intended purpose of
        the id_token is that it MUST provide an assertion of
        the identity of the resource owner as understood by the server. The assertion MUST 
        specify a targeted audience, e.g. the requesting client. However, the specific semantics of
        the assertion and how it can be validated are not specified in this document.</t>

      <t><list style="hanging">
        <t hangText="id_token">If supplied as the response_type parameter in an OAuth2
          Authorization Request, a successful response should include the parameter
          id_token encoded in the fragment of the response URI.</t>
      </list></t>

      <t>Returning the id_token in a fragment reduces the likelihood that the id_token leaks
        during transport and mitigates the associated risks to the privacy of the user (resource owner).</t>
    </section>

    <section title="None Response Type">
      <t>This section registers the response type none, in accordance
        with the stipulations in the OAuth2 specification, Section 8.4.
        The intended purpose is to enable
        use cases where a party requests the server to register a grant of access to a protected
        resource on behalf of a client but requires
        no access credentials to be returned to the client at that time. The means
        by which the client eventually obtains the access credentials is left unspecified here.</t>

      <t>One scenario is where a user wishes to purchase an
        application from a market, and desires to authorize application installation and grant
        the application access to protected resources in a single step. However, since the user is
        not presently interacting with the (not yet active) application, it is not appropriate
        to return access credentials simultaneously to the authorization step.</t>

      <t><list style="hanging">
        <t hangText="none">When supplied as the response_type parameter in an OAuth2 authorization
          request, the Authorization server SHOULD NOT return an OAuth2 code nor a token in a succesful
          response to the grant request. If a redirect_uri is supplied, the user-agent SHOULD be redirected
          there after granting or denying access. The request MAY include a state parameter, and if so the
          server MUST echo its value by adding it to the redirect_uri when issuing a successful response.
          Any parameters added to the redirect_uri should be query encoded. This applies to both successful
          responses or error responses.</t>
      </list></t>
      <t>The response type none SHOULD NOT be combined with other response types.</t>
    </section>
    <section title="Registration of Some Multiple-Valued Response Type Combinations">
      <t>This section registers combinations of the values code, token, and id_token, which are each
        individually registered response types.</t>

      <t><list style="hanging">
        <t hangText="code token">When supplied as the value for the response_type parameter, a successful
          response MUST include both an access token and an authorization code as defined in the OAuth2
          specification. Both successful and error responses SHOULD be fragment-encoded.</t>
        <t hangText="code id_token">When supplied as the value for the response_type parameter,
          a successful response MUST include both an authorization code as well as an id_token.
          Both success and error responses SHOULD be fragment-encoded.</t>
        <t hangText="id_token token">When supplied as the value for the response_type parameter,
          a successful response MUST include both an access token as well as an id_token.
          Both success and error responses SHOULD be fragment-encoded.</t>
        <t hangText="code id_token token">When supplied as the value for the response_type parameter,
          a successful response MUST include an authorization code, an id_token, and an access token.
          Both success and error responses SHOULD be fragment-encoded.</t> 
      </list></t>
    <t>A non-normative request/response example as issued/received by the user-agent:
          <figure>
            <artwork><![CDATA[GET https://server.example.com/authorize?
response_type=token%20id_token
&client_id=s6BhdRkqt3
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
&state=af0ifjsldkj HTTP/1.1
]]></artwork></figure>
          <figure>
<artwork><![CDATA[HTTP/1.1 302 Found
Location: https://client.example.com/#
access_token=SlAV32hkKG&
token_type=bearer&
id_token=1234567.SlAV32hkKG.abcde1234&
expires_in=3600&
&state=af0ifjsldkj]]></artwork>
          </figure>
    </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/bibxml4/reference.W3C.REC-html401-19991224.xml' ?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616"?>

      <?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.3339"?>

      <reference anchor="OAuth.2.0">
        <front>
          <title>OAuth 2.0 Authorization Protocol</title>

          <author fullname="Eran Hammer-Lahav" initials="E." role="editor"
                  surname="Hammer-Lahav">
            <organization abbrev="Yahoo">Yahoo</organization>
          </author>

          <author fullname="David Recordon" initials="D." surname="Recordon">
            <organization abbrev="Facebook">Facebook</organization>
          </author>

          <author fullname="Dick Hardt" initials="D." surname="Hardt">
            <organization abbrev="Microsoft">Microsoft</organization>
          </author>

          <date day="25" month="July" year="2011" />
        </front>

        <format target="http://tools.ietf.org/html/draft-ietf-oauth-v2"
                type="HTML" />
      </reference>
    </references>
    <section title="Acknowledgements">
      <t>The OpenID Community would like to thank the following people for the
      work they've done in the drafting and editing of this specification.</t>

      <t><list style="empty">
          <t>Naveen Agarwal (naa@google.com), Google</t>
          <t>Breno de Medeiros (breno@google.com), Google</t>
          <t>David Recordon (dr@fb.com), Facebook</t>
          <t>Marius Scurtescu (mscurtescu@google.com), Google</t>
          <t>Paul Tarjan (pt@fb.com), Facebook</t>
        </list></t>
    </section>

    <section title="Document History">
      <t>[[ To be removed from the final specification ]]</t>

      <t>-01 <list style="symbols">
          <t>Initial draft</t>
        </list></t>
    </section>
  </back>
</rfc>
