<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?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 category="std" docName="draft-sakimura-oauth-jpop-00"
     ipr="trust200902">
  <front>
    <title abbrev="JPOP">The OAuth 2.0 Authorization Framework: JWT Pop Token Usage</title>

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

      <address>
        <postal>
          <street>Otemachi Financial City Grand Cube, 1-9-2 Otemachi</street>
          <city>Chiyoda-ku</city>
          <code>100-0004</code>
          <region>Tokyo</region>
          <country>Japan</country>
        </postal>
        <phone>+81-3-5533-2111</phone>
        <email>n-sakimura@nri.co.jp</email>
        <uri>https://nat.sakimura.org/</uri>
      </address>
    </author>
	
    <author fullname="Kepeng Li" initials="K." surname="Li">
      <organization>Alibaba Group</organization>

      <address>
        <email>kepeng.lkp@alibaba-inc.com</email>
      </address>
    </author>
    
    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization abbrev="Ping Identity">Ping Identity</organization>
      <address>
		<email>ve7jtb@ve7jtb.com</email>
		<uri>http://www.thread-safe.com/</uri>
      </address>
    </author>


    <date day="10" month="March" year="2017"/>

    <area>Security Area</area>

    <workgroup>OAuth Working Group</workgroup>

    <keyword>JWT</keyword>
    <keyword>PoP</keyword>
    <keyword>HoK</keyword>
    <keyword>OAuth</keyword>
    <keyword>Draft</keyword>

    <abstract>
      <t>
      This specification describes how to use JWT POP (Jpop) tokens 
      that were obtained through <xref target="POPKD" />
      in HTTP requests to access OAuth 2.0 protected resources.  
      Only the party in possession of a corresponding 
      cryptographic key with the Jpop token can use it to get access to
      the associated resources unlike in the case of the bearer token 
      described in <xref target="RFC6750" /> where any party 
      in posession of the access token can access the resource. 
	  </t>
    </abstract>

    <note 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>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>This document specifies the method for the client to use a proof-of-possestion 
      token against a protected resource. The format of such token is 
      defined in section 3 of <xref target="RFC7800" />. 
	  </t>

      <section title="Notational Conventions" anchor="nconv">
        <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 RFC
        2119 [RFC2119]. </t>

        <t>Unless otherwise noted, all the protocol parameter names and values
        are case sensitive.</t>
      </section>
    </section>

    <section title="Terms and definitions" anchor="tnd">
      <t>For the purpose of this document, the terms defined in <xref
      target="RFC6749"/> and <xref target="RFC7800" /> 
      are used. </t>
    </section>
    
    <section title="JWT POP Token" anchor="Jpopt">
      <t>
      JWT PoP token is a JWS signed JWT whose payload is a JWT Claims Set. 
      The JWT claims set MUST include the following: 
      </t>
      <t><list style="hanging">
         <t hangText="iss">The issuer identifier of the auhtorization server. </t>
         <t hangText="aud">The identifier of the resource server.</t>
         <t hangText="iat">The issuance time of this token.</t>
         <t hangText="exp">The expiry time of this token.</t>
         <t hangText="cnf">The confirmation method. </t>
      </list></t>
      <t>
      Their semantics are defined in <xref target="RFC7519"/> and 
      <xref target="RFC7800"/>. 
      </t> 
        <figure anchor="eg_jpop_at" title="Example of JWT PoP Token.">
          <preamble>Following is an example of such. </preamble>

          <artwork><![CDATA[     {
      "iss": "https://server.example.com",
      "aud": "https://resource.example.org",
      "iat": "1360189224",
      "exp": "1361398868",
      "cnf":{...}
     }

]]>      </artwork>

          <postamble></postamble>
        </figure>
     </section>
        
      <section title="Sender Constrained Token" anchor="sct">
        <t>There are several varieties of 
        sender constrained token. Namely: </t>
        <t><list style="numbers">
          <t>CN Constrained Token</t>
          <t>Client ID Constrained Token</t>
        </list></t>
        
        <section title="CN Constrained Token" anchor="cnct">
			<t>CN constrained token is typically used when 
			X.509 client certificate authentication 
			is used at the token endpoint. 
			In this case, the constraint is expressed 
			by including the following member at
			the top level of cnf claim. </t>

		    <t><list style="hanging">
			  <t hangText="cn">The Common Name of the client certificate 
			  that the client used in the authorization request. 
			   </t>
			</list></t>
			<t>
			The authorization server finds the relevant CN 
			from the X.509 client certificate authentication 
			that is performed at the token endpoint. 
			</t>
        
			<figure anchor="eg_cnf_cn" title="Example of CN Constrained JWT.">
			  <preamble> </preamble>

  <artwork><![CDATA[{
"iss": "https://server.example.com",
"sub": "joe@example.com",
"aud": "https://resource.example.org",
"exp": "1361398824",
"nbf": "1360189224",
"cnf":{
  "cn": "client.example.com"
}

	]]>      </artwork>

			  <postamble></postamble>
			</figure>
		</section>
		<section title="Client ID Constrained Token" anchor="cid_ct">
			<t>The constraint in the Client ID constrained token 
			is expressed by including the following member at
			the top level of cnf claim. 
			</t>
		    <t><list style="hanging">
				<t hangText="cid">The client_id of the client 
				that the client used in the authorization request. 
				The combination of the "iss" of the access token 
				and this value forms  
				a globally unique identifier for the client.
				</t>
			</list></t>
			<t>
			The authorization server finds the client ID 
			from the client ID used in the client authentication 
			at the token endpoint. 
			</t>
		</section>
      </section>
      
      <section title="Key Constrained Token" anchor="kct">
        <t>
        Methods to express key constraints 
        are extensively described in the section 3 of 
        <xref target="RFC7800" />. Such cnf claim is 
        used in the access token described in section 3 
        to form a key constrained token. 
        <xref target="RFC7800" /> defines 4 
        confirmation methods.
        </t>
        <t><list style="hanging">
        	<t hangText="jwk">JSON Web Key Representing Public Key</t>
        	<t hangText="jwe">Encrypted JSON Web Key</t>
        	<t hangText="kid">Key Identifier</t>
        	<t hangText="jku">JWK Set URL</t>
        </list></t>

        <t>Following is an example of such JWT payload. </t>

        <figure anchor="eg_kct" title="Example of a Key Constrained JWT.">
          <preamble> </preamble>

          <artwork><![CDATA[     {
      "iss": "https://server.example.com",
      "sub": "joe@example.com",
      "aud": "https://resource.example.org",
      "exp": "1361398824",
      "nbf": "1360189224",
      "cnf":{
        "jwk":{
          "kty": "EC",
          "use": "sig",
          "crv": "P-256",
          "x": "18wHLeIgW9wVN6VD1Txgpqy2LszYkMf6J8njVAibvhM",
          "y": "-V4dS4UaLMgP_4fY4j8ir7cl1TXlFdAgcx55o7TkcSA"
         }
       }
     }

]]>      </artwork>

          <postamble></postamble>
        </figure>
    </section>

    <section title="Resource access method" anchor="resource_access_method">
      <t>The resource server that supports this specification MUST authenticate the
      Client by having it demonstrate that it is the holder of the key associated 
      with the access token being used. The confirmation method 
      can be broadly categorized in two forms. </t>
      
      <t><list style="hanging">
      	<t hangText="CN method">A method leveraging on the X.509 client certificate authentication</t>
      	<t hangText="Signature method">A method leveraging the signature on the nonce. 
      	Cases with confirmation methods equal to one of 
      	cid, jwk, jwe, kid, and jku falls into this category. 
      	</t>
      </list></t>
      
      <section title="CN method"> 
      	<t>Under this method, X.509 client certificate authentication 
      	at the resource endpoint is being leveraged. 
      	The resource endpoint MUST obtain the CN of the client certificate 
      	used for the authentication and MUST verify that the value of the 
      	cn member in the cnf member matches with it. 
      	</t>
      	<t>If it does not match, 
      	the process stops here and the resource access MUST be denied.</t>

      	<t>If it was valid, then the resource server 
      	MUST verify the access token. If it is valid,
      	the resource SHOULD be returned as HTTP response.</t>
      </section>
      
      <section title="Signature method" anchor="jwx_method">
		  <t>For this, the following steps are taken: </t>
	  
		  <t>1. The client prepares a nonce. </t>

		  <t>2. The client creates JWS compact serialization over the nonce.</t>
		  <t>
		  To obtain it, first create a JSON with a name "nonce" and 
		  the value being what was received in the previous step. e.g., 
		  </t>
		  <figure>
			<artwork><![CDATA[
{
	"nonce":"dcd98b7102dd2f0e8b11d0f600bfb0c093"
} 
			]]></artwork>
		  </figure>
		  <t>
		  Then, 
		  <spanx style="verb">jws-on-nonce</spanx> is obtained by creating a 
		  compact serialization of JWS on this JSON. 
		  </t>

		  <t>3. The client sends the request to the resource server, this time with
		  Authorization Request Header as defined in section 4.2 
		  of <xref target="RFC7235" /> with the credential as follows:
		  </t>

		  <figure>
			<artwork><![CDATA[
	credentials      =  "Jpop" jpop-response
	jpop-response    =  at-response "," s-response
	at-response      =  "at" "=" access-token; As specified by [POPKD]
	s-response       =  "s" "=" jws-on-nonce; Created in the step 3. 
	access-token     =  quoted-string
	jws-on-nonce     =  quoted-string
			]]></artwork>
		  </figure>
	  
		  <t>
		  In the following example, the access token and the jws-on-nonce 
		  are represented as access.token.jwt and jws.of.nonce for the sake 
		  of brevity. 
		  </t>
	  
		  <figure anchor="eg_resource_request" title="Example resouce request">
			<artwork><![CDATA[
	GET /resource/1234 HTTP/1.0
	Host: server.example.com
	Authorization: Jpop at="access.token.jwt", s="jws.of.nonce"]]></artwork>

			<postamble/>
		  </figure>

		  <t>4. The resource server finds the client's public key form the 
		  access token through the methods described in <xref target="RFC7800" />. </t>

		  <t>5. The resource server MUST verify 
		  the value of <spanx style="verb">s</spanx> of the Authorization
		  header. If it fails, the process stops here and the resource access MUST
		  be denied.</t>

		  <t>6. The resource server MUST verify the access token. If it is valid,
		  the resource SHOULD be returned as HTTP response.</t>
      </section>
    </section>
    
    <section anchor="Authz_error" title="Authorization Error">
          <t>If the client requests the resource without the proper authoization header, 
          the resource server returns a HTTP 401 response with <spanx style="verb">WWW-Authenticate</spanx>
      header as defined in section 4.1 of <xref target="RFC7235" /> with the challenge as follows: 
      </t>
      
      <figure>
        <artwork><![CDATA[
          challenge        =  "Jpop" jpop-challenge
          jpop-challenge   =  "nonce" "=" nonce-value
          nonce-value      =  quoted-string
        ]]></artwork>
      </figure>
      
      <t>Following example depicts what the response would look like. 
      </t>

      <figure anchor="eg_unauthorized" title="Example error response.">
        <artwork><![CDATA[HTTP/1.0 401 Unauthorized
Server: HTTPd/0.9
Date: Wed, 14 March 2017 09:26:53 GMT
WWW-Authenticate: Jpop nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093"]]></artwork>
      </figure>


    </section>

    <section anchor="IANA" title="IANA Considerations">
      <section anchor="jpop_authentication_scheme" title="Jpop Authentication Scheme">
        <t>A new scheme has been registered in the HTTP Authentication Scheme 
        Registry as follows:
        </t>
        <t>Authentication Scheme Name: Jpop</t>
        <t>Reference: Section 3 of this specification</t>
        <t>Notes (optional): The Named Authentication scheme is 
        intended to be used only with OAuth Resource Access, 
        and thus does not support proxy authentication. 
        </t>
      </section>
      <section title="JWT Confirmation Methods" anchor="iana_jcm">
      <t><list style="symbols">
      	<t>Confirmation Method Value: "cn"</t>
      	<t>Confirmation Method Description: CN match with the TLS client auth. </t>
      	<t>Change Controller: IESG</t>
      	<t>Specification Document(s): This document. </t>
      </list></t>
        <t><list style="symbols">   	
      	<t>Confirmation Method Value: "cid"</t>
      	<t>Confirmation Method Description: Client ID Confirmation</t>
      	<t>Change Controller: IESG</t>
      	<t>Specification Document(s): This document. </t>
      </list></t>
      </section>
    </section>

    <section anchor="Security" title="Security Considerations">
    	<section anchor="sec.1" title="Certificate validation">
    		<t>The "cn" JWT confirmation method relies 
    		its security property on the X.509 client 
    		certificate authentication. In particular, 
    		the validity of the certificate needs to be 
    		verified properly. It involves the traversal of 
    		all the certificate chain and the certificate 
    		validation (e.g., with OCSP). </t>
    	</section>
    	<section anchor="sec.key" title="Key protection">
      		<t>The client's secret key must be kept securely. 
      		Otherwise, the notion of PoP breaks down. 
      		</t>
      		<t>It should be noted that JWE confirmation 
      		method is significantly weaker form of the 
      		PoP, as the resource server and the 
      		authorization server can masquerade 
      		as the client. 
      		</t>
      	</section>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>The authors thank the following people for 
      providing valuable feedback to this document. 
      Nov Matake (YAuth). </t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include='reference.RFC.2617'?>
      <?rfc include='reference.RFC.6749'?>
      <?rfc include='reference.RFC.6750'?>
      <?rfc include='reference.RFC.7519'?>
      <?rfc include='reference.RFC.7235'?>
      <?rfc include='reference.RFC.7800'?>
      <reference anchor="POPKD" target="https://tools.ietf.org/html/draft-ietf-oauth-pop-key-distribution-03">
        <front>
		  <title>OAuth 2.0 Proof-of-Possession: Authorization Server to Client Key
                              Distribution</title>
    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization abbrev="Ping Identity">Ping Identity</organization>
      <address>
	<email>ve7jtb@ve7jtb.com</email>
  <uri>http://www.thread-safe.com/</uri>
      </address>
    </author>

      <author fullname="Phil Hunt" initials="P." surname="Hunt">
      <organization>Oracle Corporation</organization>

      <address>
        <email>phil.hunt@yahoo.com</email>
        <uri>http://www.indepdentid.com</uri>
      </address>
    </author>
    
    
    <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
      <organization abbrev="Microsoft">Microsoft</organization>

      <address>
        <email>mbj@microsoft.com</email>
        <uri>http://self-issued.info/</uri>
      </address>
    </author>


    <author initials="H." surname="Tschofenig" fullname="Hannes Tschofenig">
      <organization>ARM Limited</organization>
      <address>
        <postal>
          <street></street>
          <city></city>
          <code></code>
          <country>Austria</country>
        </postal>
        <phone></phone>
        <email>Hannes.Tschofenig@gmx.net</email>
        <uri>http://www.tschofenig.priv.at</uri>
      </address>
    </author>

          <date day="2" month="March" year="2017"/>
        </front>
      </reference>
    </references>

    <references title="Informative References">
      <reference anchor="POPA" target="https://tools.ietf.org/html/draft-ietf-oauth-pop-architecture-08">
        <front>
          <title>OAuth 2.0 Proof-of-Possession (PoP) Security
          Architecture</title>

          <author fullname="Phil Hunt et al." initials="P." role="editor"
                  surname="Hunt">
            <organization>Oralce Corporation</organization>
          </author>

          <date day="3" month="March" year="2015"/>
        </front>
      </reference>
      
      <reference anchor="PKCE">
        <front>
		  <title>Proof Key for Code Exchange by OAuth Public Clients</title>
          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization>Nomura Research Institute</organization>
          </author>

          <date day="10" month="July" year="2015"/>
        </front>
      </reference>
	  
      <reference anchor="TINTRO">
        <front>
		  <title>OAuth 2.0 Token Introspection</title>
          <author fullname="Justin Richer" initials="J." surname="Richer">
            <organization/>
          </author>

          <date day="3" month="July" year="2015"/>
        </front>
      </reference>
    </references>

    <section title="Document History">
      <t><list style="hanging">
		  <t hangText="-00">Initial Version.</t>

        </list> </t>
    </section>
  </back>
</rfc>
