<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" submissionType="IETF" docName="draft-yusef-oauth-nested-jwt-05" category="std" ipr="pre5378Trust200902" obsoletes="" updates="" xml:lang="en" sortRefs="true" symRefs="true" tocInclude="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.12.10 -->
  <!-- Generated by id2xml 1.5.0 on 2020-04-06T20:09:19Z -->
	<front>
    <title abbrev="Nested JWT">Multi-Subject JSON Web Token (JWT)</title>
    <seriesInfo name="Internet-Draft" value="draft-yusef-oauth-nested-jwt-05"/>
    <author fullname="Rifaat Shekh-Yusef" initials="R." surname="Shekh-Yusef">
      <organization>Okta</organization>
      <address>
        <postal>
          <street>Ottawa, Ontario, Canada</street>
        </postal>
        <email>rifaat.s.ietf@gmail.com</email>
      </address>
    </author>
    <date day="14" month="June" year="2022"/>
    <workgroup>OAuth Working Group</workgroup>
    <abstract>
      <t>
   This specification defines a mechanism for including multiple subjects in a JWT. 
   A primary subject in an enclosing JWT with its own claims, and a related secondary
   subject in a nested JWT with its own claims. 
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="sect-1" numbered="true" toc="default">
      <name>Introduction</name>
      <t>
   JSON Web Token (JWT) <xref target="RFC7519" format="default"/> is a mechanism that is used to
   transfer claims between two parties across security domains.  Nested
   JWT is a JWT in which the payload is another JWT.  The current
   specification does not define a means by which the enclosing JWT
   could have its own Claims Set, only the enclosed JWT would have
   claims.
      </t>
      <t>
   There are a number of use cases where there is a need to represent multiple related subjects in one JWT; 
   a primary subject and a related secondary subject.
      </t>
      <t>
    This specification defines a mechanism for including multiple subjects in a JWT. 
   A primary subject in an enclosing JWT with its own claims, and a related secondary
   subject in a nested JWT with its own claims. 
      </t>
      <section anchor="sect-1.1" numbered="true" toc="default">
        <name>Terminology</name>
        <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="RFC8174" format="default"/>.</t>
      </section>
    </section>
    <section anchor="use-cases" numbered="true" toc="default">
      <name>Use Cases</name>
      <t>
   The following are few use cases that might benefit from such a concept, that fall into two different categories:
      </t>
      <section anchor="one-issuer" numbered="true" toc="default">
        <name>One Issuer Category</name>
        <t>
   In the following cases, both JWTs are issued by the same issuer.
        </t>
        <section anchor="prim-with-sec-authority" numbered="true" toc="default">
          <name>Primary Subject with Secondary Authority Subject</name>
          <t>
   A primary subject with a related secondary subject that has authority over the primary subject, e.g. Child/Parent, Pet/Owner.
          </t>
          <t>
   The secondary user (e.g., parent) logs in to an application (e.g., pharmacy application), gets redirected 
   to the authorization server, authenticates, and asks for permission to access resources (e.g., medication) 
   for the primary subject (e.g., child). 
   The authorization server then issues a JWT with the primary subject in the enclosing JWT and the secondary 
   subject in the nested JWT.
          </t>
        </section>
        <section anchor="multiple-primary-subjects" numbered="true" toc="default">
          <name>Multiple Primary Subjects</name>
          <t>
   Two or more primary related subjects e.g. a married couple. The authorization server is setup to provide one of 
   the subjects with permissions to access the other related subject resources.
          </t>
          <t>  
   One user (e.g., wife) logs in to a application (e.g., pharmacy application), gets redirected to the authorization server, 
   authenticates, and asks for permission to access resources (e.g., medication) for the other primary subject (e.g., husband). 
   The authorization server then issues a JWT with the primary subject in the enclosing JWT and the other 
   primary subject in the nested JWT.
          </t>
        </section>
        <section anchor="delegation-of-authority" numbered="true" toc="default">
          <name>Delegation of Authority</name>
          <t>
   A primary subject delegates authority over a resource to a secondary subject who acts on behalf of the primary subject, 
   as defined in <xref target="RFC8693" format="default"/>. 
          </t>
        </section>
      </section>
      <section anchor="multiple-issuers" numbered="true" toc="default">
        <name>Multiple Issuers Category</name>
        <t>
   In the following cases, the JWTs are issued by different issuers.
        </t>
        <section anchor="stir" numbered="true" toc="default">
          <name>STIR</name>
          <t>
   <xref target="RFC8225" format="default"/> defines a PASSporT, which is a JWT, that is used to verify
   the identity of a caller in an incoming call.</t>
          <t>
   The PASSporT Extension for Diverted Calls draft <xref target="STIR" format="default"/> uses a nested
   PASSporT to deliver the details of an incoming call that get
   redirected.  An authentication service acting for a retargeting
   entity generates new PASSporT and embeds the original PASSporT inside
   the new one.  When the new target receives the nested PASSporT it
   will be able to validate the enclosing PASSporT and use the details
   of the enclosed PASSporT to identify the original target.
          </t>
          <t>
   In this case, the original JWT is issued by the calling service, and the new enclosing 
   JWT is issued by the retargeting service.
          </t>
        </section>
        <section anchor="nsm" numbered="true" toc="default">
          <name>Network Service Mesh (NSM)</name>
          <t>
   Network Service Mesh [NSM] is a mechanism that maps the concept of a
   service mesh in Kubernetes to L2/L3 payloads.</t>
          <t>
   NSM GRPS messages may pass through multiple intermediaries, each of
   which may transform the message.  Each intermediary is expected to
   create its own JWT token, and include a claim that contains the JWT it
   received with the message it has transformed.</t>
          <t>
   In this case, the original JWT is issued by the entity sending the initial message, 
   and the new enclosing JWT is issued by the intermediate entity.
          </t>
        </section>
      </section>
    </section>
    <section anchor="authz-request" numbered="true" toc="default">
      <name>Authorization Request</name>
      <t>
   To allow the AS to differentiate between an authorization request for a single subject 
   and an authorization request for multiple subjects, this document defines the following parameter:

      </t>
      <dl newline="true" spacing="normal" indent="3">
        <dt>issuer-hint:</dt>
        <dd>
          <t>
     A hint to the AS that the request is for a multi-subject token, which can take one of two values:

          </t>
          <dl newline="true" spacing="normal" indent="3">
            <dt>Internal</dt>
            <dd>
     Indicates that the AS handling the current request will be issuing both enclosing and enclosed JWTs.
      </dd>
          </dl>
          <dl newline="true" spacing="normal" indent="3">
            <dt>External</dt>
            <dd>
      Indicates that an external entity has issued the JWT to be enclosed, which will be carried in access_token parameter.
      </dd>
          </dl>
        </dd>
      </dl>
      <t>
   If the access_token query parameter is included in the request, then the AS SHOULD embed the provided
   token in the issued token, if the issuer-hint has the "External" value.
      </t>
    </section>
    <section anchor="jwt-content" numbered="true" toc="default">
      <name>JWT Content</name>
      <t>
   The payload of the enclosing JWT is JSON object that contains the
   Claims Set of the primary subject, and one new claim that is used to 
   hold the enclosed JWT and its relation to the primary subject.</t>
      <t>
   This document defines a new claim, "rsub" (Related Subject) Claim, that is used 
   to contain the enclosed JWT and its relation to the primary subject. The "rsub" 
   contains two claims:  

      </t>
      <dl newline="true" spacing="normal" indent="3">
        <dt>rel:</dt>
        <dd>
      Defines the relationship between the enclosed JWT and the enclosing JWT. It can 
      take one of the values defined in section <xref target="token-relationship" format="default"/> </dd>
      </dl>
      <dl newline="true" spacing="normal" indent="3">
        <dt>jwt:</dt>
        <dd>
      Contains the enclosed JWT.</dd>
      </dl>
    </section>
    <section anchor="token-relationship" numbered="true" toc="default">
      <name>Token Relationship</name>
      <t>
   The following relathionship types are defined by this specification:

      </t>
      <dl newline="true" spacing="normal" indent="3">
        <dt>urn:ietf:params:oauth:subject-type:authority</dt>
        <dd>
     Indicates that the subject in the enclosed JWT has authority over the subject in the enclosing JWT. 
     </dd>
        <dt/>
        <dd>
     This URN could be used in the child/parent use case described in <xref target="prim-with-sec-authority" format="default"/>.
     </dd>
      </dl>
      <dl newline="true" spacing="normal" indent="3">
        <dt>urn:ietf:params:oauth:subject-type:primary</dt>
        <dd>
      Indicates that the subject in the enclosed JWT is related primary subject</dd>
        <dt/>
        <dd>
      This URN could be used in the married couple use case described in <xref target="multiple-primary-subjects" format="default"/>.
      </dd>
      </dl>
      <dl newline="true" spacing="normal" indent="3">
        <dt>urn:ietf:params:oauth:subject-type:actor</dt>
        <dd>
     Indicates that the subject in the enclosed JWT is acting on behalf of the primary subject</dd>
        <dt/>
        <dd>
      This URN could be used in the delegation use case described in <xref target="delegation-of-authority" format="default"/>.
      </dd>
      </dl>
      <dl newline="true" spacing="normal" indent="3">
        <dt>urn:ietf:params:oauth:subject-type:original</dt>
        <dd>
     Indicates that the subject in the enclosed JWT is the original JWT that resulted in the primary subject JWT</dd>
        <dt/>
        <dd>
      This URN could be used in all the use cases described in <xref target="multiple-issuers" format="default"/>.
      </dd>
      </dl>
    </section>
    <section anchor="example" numbered="true" toc="default">
      <name>Example</name>
      <t>
   The following example is for a multi-subject token that represents a child/parent relashionship.
   The enclosing JWT represents the primary user, the child in this case, and the enclosed token in 
   the "rsub" claim represents the secondary user, the parent in this case.
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
{
  "alg": "HS256",
  "typ": "JWT",
}
{
   "sub": "1234567890",
   "name": "John Doe",
   "iat": 1516239022,
   "rsub": {
      “rel” :  "urn:ietf:params:oauth:subject-type:authority"
      “jwt” : {
         "sub": "9876543210",
         "name": "Alice Doe",
         "iat": 1516239022,
      }
   }
}
]]></artwork>
      <t>
   In this use case, both JWTs are issued by the same entity handling the authorization request.
      </t>
    </section>
    <section anchor="sect-7" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>
   The existing security considerations apply to the use cases where the JWTs are issued by the same entity.
   Allowing more than one subject to access the same account might open the door for potential abuse.
   Care must be taken to ensure that when a secondary subject is added to an account that an adequate approval process is in place.
      </t>
      <t>
   In the multiple issuers use cases, the entity handling the incoming authorization request that contains a JWT MUST validate 
   the token and ensure that it is coming from a trusted entity, before attempting to embed that JWT into a new multi-subject JWT issued 
   by the AS.
      </t>
    </section>
    <section anchor="sect-8" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>
   TODO</t>
    </section>
    <section anchor="sect-9" numbered="true" toc="default">
      <name>Acknowledgments</name>
      <t>
   TODO</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="RFC7519" target="https://www.rfc-editor.org/info/rfc7519" xml:base="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7519.xml">
          <front>
            <title>JSON Web Token (JWT)</title>
            <author initials="M." surname="Jones" fullname="M. Jones">
              <organization/>
            </author>
            <author initials="J." surname="Bradley" fullname="J. Bradley">
              <organization/>
            </author>
            <author initials="N." surname="Sakimura" fullname="N. Sakimura">
              <organization/>
            </author>
            <date year="2015" month="May"/>
            <abstract>
              <t>JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties.  The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7519"/>
          <seriesInfo name="DOI" value="10.17487/RFC7519"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174" xml:base="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author initials="B." surname="Leiba" fullname="B. Leiba">
              <organization/>
            </author>
            <date year="2017" month="May"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
        <reference anchor="RFC8225" target="https://www.rfc-editor.org/info/rfc8225" xml:base="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8225.xml">
          <front>
            <title>PASSporT: Personal Assertion Token</title>
            <author initials="C." surname="Wendt" fullname="C. Wendt">
              <organization/>
            </author>
            <author initials="J." surname="Peterson" fullname="J. Peterson">
              <organization/>
            </author>
            <date year="2018" month="February"/>
            <abstract>
              <t>This document defines a method for creating and validating a token that cryptographically verifies an originating identity or, more generally, a URI or telephone number representing the originator of personal communications.  The Personal Assertion Token, PASSporT, is cryptographically signed to protect the integrity of the identity of the originator and to verify the assertion of the identity information at the destination.  The cryptographic signature is defined with the intention that it can confidently verify the originating persona even when the signature is sent to the destination party over an insecure channel.  PASSporT is particularly useful for many personal-communications applications over IP networks and other multi-hop interconnection scenarios where the originating and destination parties may not have a direct trusted relationship.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8225"/>
          <seriesInfo name="DOI" value="10.17487/RFC8225"/>
        </reference>
        <reference anchor="RFC8693">
          <front>
            <title>OAuth 2.0 Token Exchange</title>
            <author fullname="M. Jones" initials="M." surname="Jones">
         </author>
            <author fullname="A. Nadalin" initials="A." surname="Nadalin">
         </author>
            <author fullname="B. Campbell" initials="B." surname="Campbell"/>
            <author fullname="J. Bradley" initials="J." surname="Bradley"/>
            <author fullname="C. Mortimore" initials="C." surname="Mortimore"/>
            <date month="October" year="2018"/>
          </front>
        </reference>
        <reference anchor="STIR">
          <front>
            <title>PASSporT Extension for Diverted Calls</title>
            <author fullname="J. Peterson" initials="J." surname="Peterson">
         </author>
            <date month="October" year="2018"/>
          </front>
        </reference>
      </references>
    </references>
  </back>
</rfc>
