<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>

<?rfc rfcedstyle="yes"?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc category="std" ipr="trust200902" number="7519" submissionType="IETF" consensus="yes">

  <front>
    <title>JSON Web Token (JWT)</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="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="Nat Sakimura" initials="N." surname="Sakimura">
      <organization abbrev="NRI">Nomura Research Institute</organization>
      <address>
	<email>n-sakimura@nri.co.jp</email>
	<uri>http://nat.sakimura.org/</uri>
      </address>
    </author>

    <date month="May" year="2015"/>

    <area>Security</area>
    <workgroup>OAuth Working Group</workgroup>

    <keyword>Assertion</keyword>
    <keyword>Claim</keyword>
    <keyword>Security Token</keyword>
    <keyword>JavaScript Object Notation</keyword>
    <keyword>JSON</keyword>
    <keyword>JSON Web Token</keyword>
    <keyword>JWT</keyword>
    <keyword>JSON Object Signing and Encryption</keyword>
    <keyword>JOSE</keyword>
    <keyword>JSON Web Signature</keyword>
    <keyword>JWS</keyword>
    <keyword>JSON Web Encryption</keyword>
    <keyword>JWE</keyword>
    <keyword>JSON Web Key</keyword>
    <keyword>JWK</keyword>
    <keyword>JSON Web Algorithms</keyword>
    <keyword>JWA</keyword>

    <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>

  <middle>
    <section title="Introduction" anchor="Introduction">
      <t>
	JSON Web Token (JWT) is a compact claims representation format intended for
	space constrained environments such as HTTP Authorization headers
	and URI query parameters.
	JWTs encode claims to be transmitted as a
	JSON <xref target="RFC7159"/> object that is
	used as the payload of a JSON Web Signature (JWS) <xref target="JWS"/> structure
	or as the plaintext of a JSON Web Encryption (JWE) <xref target="JWE"/> structure,
	enabling the claims to be digitally signed or
	integrity protected with a Message Authentication Code (MAC)
	and/or encrypted.
	JWTs are always represented using the JWS Compact Serialization
	or the JWE Compact Serialization.
      </t>
      <t>
        The suggested pronunciation of JWT is the same as the English
        word "jot".
      </t>

      <section title="Notational Conventions" anchor="NotationalConventions">
        <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
	  "Key words for use in RFCs to Indicate Requirement Levels" <xref target='RFC2119' />.
	  The interpretation should only be applied when the terms appear in all capital letters.
        </t>
      </section>

    </section>

    <section title="Terminology" anchor="Terminology">

      <t>
	The terms 
	"JSON Web Signature (JWS)",
	"Base64url Encoding",
	"Header Parameter",
	"JOSE Header",
	"JWS Compact Serialization",
	"JWS Payload",
	"JWS Signature",
	and "Unsecured JWS" are defined by
	the JWS specification <xref target="JWS"/>.
      </t>

      <t>
	The terms 
	"JSON Web Encryption (JWE)",
	"Content Encryption Key (CEK)",
	"JWE Compact Serialization",
	"JWE Encrypted Key",
	and "JWE Initialization Vector"
	are defined by
	the JWE specification <xref target="JWE"/>.
      </t>

      <t>
	The terms 
	"Ciphertext",
	"Digital Signature",
	"Message Authentication Code (MAC)",
	and "Plaintext" are defined by
	the <xref target="RFC4949">"Internet Security Glossary, Version 2"</xref>.
      </t>

      <t>
	These terms are defined by this specification:
      </t>

      <t>
	<list style="hanging">

          <t hangText="JSON Web Token (JWT)">
	    <vspace/>
	    A string representing a set of claims as a JSON object that is
	    encoded in a JWS or JWE,
	    enabling the claims to be digitally signed or MACed and/or encrypted.
	  </t>

          <t hangText="JWT Claims Set">
	    <vspace/>
	    A JSON object that
	    contains the claims conveyed by the JWT.
	  </t>

	  <t hangText="Claim">
	    <vspace/>
	    A piece of information asserted about a subject.
	    A claim is represented as a name/value pair
	    consisting of a Claim Name and a Claim Value.
	  </t>

	  <t hangText="Claim Name">
	    <vspace/>
	    The name portion of a claim representation.
	    A Claim Name is always a string.
	  </t>
	  <t hangText="Claim Value">
	    <vspace/>
	    The value portion of a claim representation.
	    A Claim Value can be any JSON value.
	  </t>

	  <t hangText="Nested JWT">
	    <vspace/>
	    A JWT in which nested signing and/or encryption are employed.
	    In Nested JWTs, a JWT is used as the payload or plaintext value
	    of an enclosing JWS or JWE structure, respectively.
	  </t>

	  <t hangText="Unsecured JWT">
	    <vspace/>
	    A JWT whose claims are not integrity protected or encrypted.
	  </t>

	  <t hangText="Collision-Resistant Name">
	    <vspace/>
	    A name in a namespace that enables names to be allocated in a manner
	    such that they are highly unlikely to collide with other names.
	    Examples of collision-resistant namespaces include:
	    Domain Names,
	    Object Identifiers (OIDs) as defined in the ITU-T X.660
	    and X.670 Recommendation series, and
	    Universally Unique IDentifiers (UUIDs)
	    <xref target="RFC4122"/>.
	    When using an administratively delegated namespace,
	    the definer of a name needs to take
	    reasonable precautions to ensure they are in control of
	    the portion of the namespace they use to define the name.
	  </t>

	  <t hangText="StringOrURI">
	    <vspace/>
	    A JSON string value, with the additional requirement that
	    while arbitrary string values MAY be used, any value
	    containing a ":" character MUST be a URI
	    <xref target="RFC3986"/>.
	    StringOrURI values are compared as case-sensitive strings
	    with no transformations or canonicalizations applied.
	  </t>

	  <t hangText="NumericDate">
	    <vspace/>
	    A JSON numeric value representing the number of seconds
	    from 1970-01-01T00:00:00Z UTC until the specified UTC date/time,
	    ignoring leap seconds.
	    This is equivalent to the
	    <xref target="POSIX.1">IEEE Std 1003.1, 2013 Edition</xref>
	    definition "Seconds Since the Epoch",
	    in which each day is accounted for by exactly 86400 seconds,
	    other than that non-integer values can be represented.
	    See <xref target="RFC3339">RFC 3339</xref> for details
	    regarding date/times in general and UTC in particular.
	  </t>

        </list>

      </t>
    </section>

    <section title="JSON Web Token (JWT) Overview" anchor="Overview">

      <t>
	JWTs represent a set of claims as a JSON object that is
	encoded in a JWS and/or JWE structure.
	This JSON object is the JWT Claims Set.
	As per Section 4 of <xref target="RFC7159">RFC 7159</xref>,
	the JSON object consists of zero or more
	name/value pairs (or members), where the names are strings and
	the values are arbitrary JSON values.
	These members are the claims represented by the JWT.
	This JSON object MAY contain whitespace and/or line breaks
	before or after any JSON values or structural characters,
	in accordance with Section 2 of <xref target="RFC7159">RFC 7159</xref>.
      </t>
      <t>
	The member names within the JWT Claims Set are
	referred to as Claim Names.  The
	corresponding values are referred to as Claim Values.
      </t>
      <t>
	The contents of the JOSE Header describe the cryptographic
	operations applied to the JWT Claims Set.
	If the JOSE Header is for a JWS, the JWT is represented as a JWS
	and the claims are digitally signed or MACed,
	with the JWT Claims Set being the JWS Payload.
	If the JOSE Header is for a JWE, the JWT is represented as a JWE
	and the claims are encrypted,
	with the JWT Claims Set being the plaintext encrypted by the JWE.
	A JWT may be enclosed in another JWE or JWS structure
	to create a Nested JWT,
	enabling nested signing and encryption to be performed.
      </t>
      <t>
	A JWT is represented as a sequence of URL-safe parts
	separated by period ('.') characters.
	Each part contains a base64url-encoded value.
	The number of parts in the JWT is dependent upon
	the representation of the resulting
	JWS using the JWS Compact Serialization or
	JWE using the JWE Compact Serialization.
      </t>

      <section title="Example JWT" anchor="ExampleJWT">

	<t>
	  The following example JOSE Header declares that the
	  encoded object is a JWT, and the JWT is
	  a JWS that is MACed using the HMAC SHA-256 algorithm:
	</t>

	<figure><artwork><![CDATA[
  {"typ":"JWT",
   "alg":"HS256"}
]]></artwork></figure>

	  <t>
	    To remove potential ambiguities in the representation of the JSON object above,
	    the octet sequence for the actual UTF-8 representation used in this example
	    for the JOSE Header above
	    is also included below.
	    (Note that ambiguities can arise due to
	    differing platform representations of line breaks (CRLF versus LF),
	    differing spacing at the beginning and ends of lines,
	    whether the last line has a terminating line break or not,
	    and other causes.
	    In the representation used in this example,
	    the first line has no leading or trailing spaces,
	    a CRLF line break (13, 10) occurs between the first and second lines,
	    the second line has one leading space (32) and no trailing spaces,
	    and the last line does not have a terminating line break.)
	    The octets representing the UTF-8 representation
	    of the JOSE Header in this example
	    (using JSON array notation) are:
	  </t>
	  <t>

[123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125]

	  </t>
	<t>
	  Base64url encoding the octets of the UTF-8 representation of
	  the JOSE Header yields this encoded JOSE Header value:
	</t>

	<figure><artwork><![CDATA[
  eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
]]></artwork></figure>

	<t>
	  The following is an example of a JWT Claims Set:
	</t>

	<figure><artwork><![CDATA[
  {"iss":"joe",
   "exp":1300819380,
   "http://example.com/is_root":true}
]]></artwork></figure>

	<t>
	  The following octet sequence, which is the UTF-8 representation
	  used in this example for the JWT Claims Set above, is the JWS Payload:
	</t>
	<t>

[123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 111, 116, 34, 58, 116, 114, 117, 101, 125]

	</t>

	<t>
	  Base64url encoding the JWS Payload yields this encoded JWS Payload
	  (with line breaks for display purposes only):
	</t>

	<figure><artwork><![CDATA[
  eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly
  9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ
]]></artwork></figure>

	<t>
	  Computing the MAC of the encoded JOSE Header and encoded JWS Payload with
	  the HMAC SHA-256 algorithm and base64url encoding the
	  HMAC value in the 
          manner specified in <xref target="JWS" />
	  yields this encoded JWS Signature:
	</t>

	<figure><artwork><![CDATA[
  dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>

	<t>
	  Concatenating these encoded parts in this order
	  with period ('.') characters between the
	  parts yields this complete JWT
	  (with line breaks for display purposes only):
	</t>

	<figure><artwork><![CDATA[
  eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
  .
  eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
  cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
  .
  dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>

	<t>
	  This computation is illustrated in more detail in
	  Appendix A.1 of <xref target="JWS" />.
	  See <xref target="EncryptedJWTExample"/> for an example of
	  an encrypted JWT.
	</t>

      </section>

    </section>

    <section title="JWT Claims" anchor="Claims">

      <t>
	The JWT Claims Set represents a JSON object whose members
	are the claims conveyed by the JWT.
	The Claim Names within a JWT Claims Set MUST be unique;
	JWT parsers MUST either reject JWTs with duplicate Claim Names
	or use a JSON parser that returns only the lexically last duplicate member name,
	as specified in Section 15.12 ("The JSON Object") of
	ECMAScript 5.1 <xref target="ECMAScript"/>.
      </t>
      <t>
	The set of claims that a
	JWT must contain to be considered valid is context dependent
	and is outside the scope of this specification.
	Specific applications of JWTs will require implementations
	to understand and process some claims in particular ways.
	However, in the absence of such requirements, all claims
	that are not understood by implementations MUST be ignored.
      </t>
      <t>
        There are three classes of JWT Claim Names:
	Registered Claim Names, Public Claim Names, and Private Claim Names.
      </t>

      <section title="Registered Claim Names" anchor="RegisteredClaimName">
	<t>
	  The following Claim Names are registered
	  in the IANA
	  "JSON Web Token Claims" registry
	  established by
	  <xref target="JWTClaimsReg"/>.
	  None of the claims
	  defined below are intended to be mandatory to use or implement in all cases, but
	  rather they provide a starting point for a set of useful,
	  interoperable claims.
	  Applications using JWTs should define which specific claims they use
	  and when they are required or optional.
	  All the names are short because a
	  core goal of JWTs is for the representation to be compact.
	</t>

	<section title='"iss" (Issuer) Claim' anchor="issDef">
	  <t>
	    The <spanx style="verb">iss</spanx> (issuer) claim
	    identifies the principal that issued the JWT.  The
	    processing of this claim is generally application
	    specific.
	    The <spanx style="verb">iss</spanx> value is a case-sensitive string
	    containing a StringOrURI value.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"sub" (Subject) Claim' anchor="subDef">
	  <t>
	    The <spanx style="verb">sub</spanx> (subject) claim
	    identifies the principal that is the subject of the JWT.
	    The claims in a JWT are normally statements about the subject.
	    The subject value MUST either be scoped to be locally unique
	    in the context of the issuer or be globally unique.
	    The processing of this claim is generally application specific.
	    The <spanx style="verb">sub</spanx> value is a case-sensitive string
	    containing a StringOrURI value.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"aud" (Audience) Claim' anchor="audDef">
	  <t>
	    The <spanx style="verb">aud</spanx> (audience) claim
	    identifies the recipients that the JWT is intended for.
	    Each principal intended to process the JWT MUST identify itself
	    with a value in the audience claim.  If the principal
	    processing the claim does not identify itself with a
	    value in the <spanx style="verb">aud</spanx> claim when this claim is present,
	    then the JWT MUST be rejected.
	    In the general case, 
	    the <spanx style="verb">aud</spanx> value is an array of
	    case-sensitive strings, each containing a StringOrURI value.
	    In the special case when the JWT has one audience,
	    the <spanx style="verb">aud</spanx> value MAY be a single
	    case-sensitive string containing a StringOrURI value.
	    The interpretation of audience values is generally application specific.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"exp" (Expiration Time) Claim' anchor="expDef">
	  <t>
	    The <spanx style="verb">exp</spanx> (expiration time)
	    claim identifies the expiration time on or after which the
	    JWT MUST NOT be accepted for processing.  The processing
	    of the <spanx style="verb">exp</spanx> claim requires that
	    the current date/time MUST be before the expiration
	    date/time listed in the <spanx style="verb">exp</spanx>
	    claim. Implementers MAY provide for some small leeway,
	    usually no more than a few minutes, to account for clock skew.
	    Its value MUST be a number containing a NumericDate value.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"nbf" (Not Before) Claim' anchor="nbfDef">
	  <t>
	    The <spanx style="verb">nbf</spanx> (not before) claim
	    identifies the time before which the JWT MUST NOT be
	    accepted for processing.  The processing of the <spanx
	    style="verb">nbf</spanx> claim requires that the current
	    date/time MUST be after or equal to the not-before
	    date/time listed in the <spanx style="verb">nbf</spanx>
	    claim. Implementers MAY provide for some small leeway,
	    usually no more than a few minutes, to account for clock skew.
	    Its value MUST be a number containing a NumericDate value.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"iat" (Issued At) Claim' anchor="iatDef">
	  <t>
	    The <spanx style="verb">iat</spanx> (issued at) claim
	    identifies the time at which the JWT was issued.  This
	    claim can be used to determine the age of the JWT.
	    Its value MUST be a number containing a NumericDate value.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

	<section title='"jti" (JWT ID) Claim' anchor="jtiDef">
	  <t>
	    The <spanx style="verb">jti</spanx> (JWT ID) claim
	    provides a unique identifier for the JWT.  The identifier
	    value MUST be assigned in a manner that ensures that there
	    is a negligible probability that the same value will be
	    accidentally assigned to a different data object;
	    if the application uses multiple issuers, collisions MUST be prevented
	    among values produced by different issuers as well.
	    The <spanx style="verb">jti</spanx> claim can be used to
	    prevent the JWT from being replayed.
	    The <spanx style="verb">jti</spanx> value is a case-sensitive string.
	    Use of this claim is OPTIONAL.
	  </t>
	</section>

      </section>

      <section title="Public Claim Names" anchor="PublicClaimName">

        <t>
	  Claim Names can be defined at will by those using
	  JWTs. However, in order to prevent collisions, any new
	  Claim Name should either be registered in the IANA
	  "JSON Web Token Claims" registry
	  established by
	  <xref target="JWTClaimsReg" />
	  or be a Public Name: 
	  a value that contains a Collision-Resistant Name.
	  In each case, the definer of the name
	  or value needs to take reasonable precautions to make sure they
	  are in control of the part of the namespace they use to
	  define the Claim Name.
	</t>
      </section>

      <section title="Private Claim Names" anchor="PrivateClaimName">

         <t>
	   A producer and consumer of a JWT MAY agree to use Claim Names
	   that are Private Names: names that are
	   not Registered Claim Names (<xref target="RegisteredClaimName"/>)
	   or Public Claim Names (<xref target="PublicClaimName"/>).
	   Unlike Public Claim Names, Private Claim Names are subject to collision and
	   should be used with caution.
	 </t>

      </section>
    </section>

    <section title="JOSE Header" anchor="Header">

      <t>
	For a JWT object,
	the members of the JSON object represented by the JOSE Header
	describe the cryptographic operations applied to the JWT and
	optionally, additional properties of the JWT.
	Depending upon whether the JWT is a JWS or JWE,
	the corresponding rules for the JOSE Header values apply.
      </t>
      <t>
	This specification further specifies the use of the following
	Header Parameters in both the cases where the JWT is a JWS and
	where it is a JWE.
      </t>

      <section title='"typ" (Type) Header Parameter' anchor="typHdrDef">
	<t>
	  The <spanx style="verb">typ</spanx> (type) Header Parameter
	  defined by <xref target="JWS" /> and <xref target="JWE" />
	  is used by JWT applications to declare the
	  media type <xref target="IANA.MediaTypes"/>
	  of this complete JWT.
	  This is intended for use by the JWT application when
	  values that are not JWTs could also be present in
	  an application data structure that can contain a JWT object;
	  the application can use this value to disambiguate among
	  the different kinds of objects that might be present.
	  It will typically not be used by applications when
	  it is already known that the object is a JWT.
	  This parameter is ignored by JWT implementations;
	  any processing of this parameter is performed by the JWT application.
	  If present, it is RECOMMENDED that its value be
	  <spanx style="verb">JWT</spanx>
	  to indicate that this object is a JWT.
	  While media type names are not case sensitive,
	  it is RECOMMENDED that <spanx style="verb">JWT</spanx>
	  always be spelled using uppercase characters
	  for compatibility with legacy implementations.
	  Use of this Header Parameter is OPTIONAL.
	</t>
      </section>

      <section title='"cty" (Content Type) Header Parameter' anchor="ctyHdrDef">
	<t>
	  The <spanx style="verb">cty</spanx> (content type) Header Parameter
	  defined by <xref target="JWS" /> and <xref target="JWE" />
	  is used by this specification
	  to convey structural information about the JWT.
	</t>
	<t>
	  In the normal case in which nested signing or encryption
	  operations are not employed, the use of this Header Parameter
	  is NOT RECOMMENDED.
	  In the case that nested signing or encryption is
	  employed, this Header Parameter MUST be present; in
	  this case, the value MUST be <spanx style="verb">JWT</spanx>, to indicate that
	  a Nested JWT is carried in this JWT.
	  While media type names are not case sensitive,
	  it is RECOMMENDED that <spanx style="verb">JWT</spanx>
	  always be spelled using uppercase characters
	  for compatibility with legacy implementations.
	  See <xref target="NestedJWTExample"/> for an example of a Nested JWT.
	</t>
      </section>

      <section title="Replicating Claims as Header Parameters" anchor="ClaimsAsHeaders">
	<t>
	  In some applications using encrypted JWTs, it is useful to
	  have an unencrypted representation of some claims.
	  This might be used, for instance, in application processing rules
	  to determine whether and how to process the JWT before
	  it is decrypted.
	</t>
	<t>
	  This specification allows claims present in the JWT Claims Set
	  to be replicated as Header Parameters in a JWT that is a JWE,
	  as needed by the application.
	  If such replicated claims are present, the application receiving them
	  SHOULD verify that their values are identical,
	  unless the application defines other specific processing rules for these claims.
	  It is the responsibility of the application to ensure that
	  only claims that are safe to be transmitted in an unencrypted manner
	  are replicated as Header Parameter values in the JWT.
	</t>
	<t>
	  <xref target="HdrContents"/> of this specification registers the
	  <spanx style="verb">iss</spanx> (issuer),
	  <spanx style="verb">sub</spanx> (subject), and
	  <spanx style="verb">aud</spanx> (audience)
	  Header Parameter names for the purpose of
	  providing unencrypted replicas of these claims in encrypted JWTs
	  for applications that need them.
	  Other specifications MAY similarly register other names
	  that are registered Claim Names as Header Parameter names, as needed.
	</t>
      </section>

    </section>

    <section title="Unsecured JWTs" anchor="UnsecuredJWT">

      <t>
	To support use cases in which the JWT content is secured by a
	means other than a signature and/or encryption contained
	within the JWT (such as a signature on a data structure
	containing the JWT), JWTs MAY also be created without a
	signature or encryption.  An Unsecured JWT is a JWS using the
	<spanx style="verb">alg</spanx> Header Parameter value
	<spanx style="verb">none</spanx> and
	with the empty string for its JWS Signature value,
	as defined in the JWA specification <xref target="JWA"/>;
	it is an Unsecured JWS with the JWT Claims Set as its JWS Payload.
      </t>

      <section title="Example Unsecured JWT" anchor="ExampleUnsecuredJWT">

	<t>
	  The following example JOSE Header declares that the
	  encoded object is an Unsecured JWT:
	</t>

	<figure><artwork><![CDATA[
  {"alg":"none"}
]]></artwork></figure>

	<t>
	  Base64url encoding the octets of the UTF-8 representation of
	  the JOSE Header yields this encoded JOSE Header value:
	</t>

	<figure><artwork><![CDATA[
  eyJhbGciOiJub25lIn0
]]></artwork></figure>

	<t>
	  The following is an example of a JWT Claims Set:
	</t>

	<figure><artwork><![CDATA[
  {"iss":"joe",
   "exp":1300819380,
   "http://example.com/is_root":true}
]]></artwork></figure>

	<t>
	  Base64url encoding the octets of the UTF-8 representation of
	  the JWT Claims Set yields this encoded JWS Payload
	  (with line breaks for display purposes only):
	</t>

	<figure><artwork><![CDATA[
  eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
  cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
]]></artwork></figure>

	<t>
	  The encoded JWS Signature is the empty string.
	</t>

	<t>
	  Concatenating these encoded parts in this order
	  with period ('.') characters between the
	  parts yields this complete JWT
	  (with line breaks for display purposes only):
	</t>

	<figure><artwork><![CDATA[
  eyJhbGciOiJub25lIn0
  .
  eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
  cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
  .
]]></artwork></figure>
      </section>

    </section>

    <section title="Creating and Validating JWTs" anchor="JWTRules">

      <section title="Creating a JWT" anchor="Creating">
	<t>
	  To create a JWT, the following steps are performed.
	  The order of the steps is not significant in cases where
	  there are no dependencies between the inputs and outputs of the steps.

	  <list style="numbers">

	    <t>
	      Create a JWT Claims Set containing the desired claims.
	      Note that whitespace is explicitly allowed in the
	      representation and no canonicalization need be performed before
	      encoding.
	    </t>
	    <t>
	      Let the Message be the octets of the UTF-8 representation
	      of the JWT Claims Set.
	    </t>
	    <t>
	      Create a JOSE Header containing the desired set of Header Parameters.
	      The JWT
	      MUST conform to either the <xref target="JWS" /> or <xref
	      target="JWE" /> specification.
	      Note that whitespace
	      is explicitly allowed in the representation and no
	      canonicalization need be performed before encoding.
	    </t>
	    <t>
	      Depending upon whether the JWT is a JWS or JWE,
	      there are two cases:
	      <list style='symbols'>
		<t>
		  If the JWT is a JWS, create a JWS using
		  the Message as the JWS Payload;
		  all steps specified in <xref target="JWS" />
		  for creating a JWS MUST be followed.
		</t>
		<t>
		  Else, if the JWT is a JWE, create a JWE using
		  the Message as the plaintext for the JWE;
		  all steps specified in <xref target="JWE" />
		  for creating a JWE MUST be followed.
		</t>
	      </list>
	    </t>
	    <t>
	      If a nested signing or encryption operation will be
	      performed, let the Message be the JWS or JWE, and
	      return to Step 3, using a <spanx style="verb">cty</spanx> (content type)
	      value of <spanx style="verb">JWT</spanx>
	      in the new JOSE Header created in that step.
	    </t>
	    <t>
	      Otherwise, let the resulting JWT be the JWS or JWE.
	    </t>
	  </list>
	</t>

      </section>

      <section title="Validating a JWT" anchor="Validating">

	<t>
	  When validating a JWT, the following steps are performed.
	  The order of the steps is not significant in cases where
	  there are no dependencies between the inputs and outputs of the steps.
	  If any of the listed steps fail, then the JWT MUST be rejected
	  -- that is, treated by the application as an invalid input.
	</t>
	<t>
	  <list style="numbers">
	    <t>
	      Verify that the JWT contains at least one period ('.') character.
	    </t>
	    <t>
	      Let the Encoded JOSE Header be the portion of the JWT
	      before the first period ('.') character.
	    </t>
	    <t>
	      Base64url decode the Encoded JOSE Header
	      following the restriction that no line breaks, whitespace, or other additional characters have been used.
	    </t>
	    <t>
	      Verify that the resulting octet sequence
	      is a UTF-8-encoded representation of
	      a completely valid JSON object
	      conforming to <xref target="RFC7159">RFC 7159</xref>;
	      let the JOSE Header be this JSON object.
	    </t>
	    <t>
	      Verify that the resulting JOSE Header includes only
	      parameters and values whose syntax and semantics are both
	      understood and supported
	      or that are specified as being ignored when not understood.
	    </t>
	    <t>
	      Determine whether the JWT is a JWS or a JWE
	      using any of the methods described in
	      Section 9 of <xref target="JWE"/>.
	    </t>
	    <t>
	      Depending upon whether the JWT is a JWS or JWE,
	      there are two cases:
	      <list style='symbols'>
		<t>
		  If the JWT is a JWS, follow the steps specified in
		  <xref target="JWS" /> for validating a JWS.
		  Let the Message be the result of base64url decoding
		  the JWS Payload.
		</t>
		<t>
		  Else, if the JWT is a JWE, follow the steps specified in
		  <xref target="JWE" /> for validating a JWE.
		  Let the Message be the resulting plaintext.
		</t>
	      </list>
	    </t>
	    <t>
	      If the JOSE Header contains a <spanx style="verb">cty</spanx> (content type)
	      value of <spanx style="verb">JWT</spanx>,
	      then the Message is a JWT that was the subject of
	      nested signing or encryption operations.  In
	      this case, return to Step 1, using the Message as the JWT.
	    </t>
	    <t>
	      Otherwise, base64url decode the Message
	      following the restriction that no line breaks, whitespace, or other additional characters have been used.
	    </t>
	    <t>
	      Verify that the resulting octet sequence
	      is a UTF-8-encoded representation of
	      a completely valid JSON object
	      conforming to <xref target="RFC7159">RFC 7159</xref>;
	      let the JWT Claims Set be this JSON object.
	    </t>
	  </list>
	</t>
	<t>
	  Finally, note that it is an application decision which algorithms
	  may be used in a given context.
	  Even if a JWT can be successfully validated,
	  unless the algorithms used in the JWT are acceptable
	  to the application, it SHOULD reject the JWT.
	</t>
      </section>

      <section title="String Comparison Rules" anchor="StringComparison">

	<t>
	  Processing a JWT inevitably requires comparing known strings
	  to members and values in JSON objects. For example, in checking what the
	  algorithm is, the Unicode <xref target="UNICODE"/> string encoding
	  <spanx style="verb">alg</spanx> will be
	  checked against the member names in the JOSE Header
	  to see if there is a matching Header Parameter name.
	</t>
	<t>
	  The JSON rules for doing member name comparison are described in
	  Section 8.3 of <xref target="RFC7159">RFC 7159</xref>.
	  Since the only string comparison operations that are performed are
	  equality and inequality, the same rules can be used for comparing
	  both member names and member values against known strings.
	</t>
	<t>
	  These comparison rules MUST be used for all JSON string comparisons
	  except in cases where the definition of the member explicitly calls out that
	  a different comparison rule is to be used for that member value.
	  In this specification, only the <spanx style="verb">typ</spanx> and
	  <spanx style="verb">cty</spanx> member values do not use these comparison rules.
	</t>
	<t>
	  Some applications may include case-insensitive information in
	  a case-sensitive value, such as including a DNS name as part of
	  the <spanx style="verb">iss</spanx> (issuer) claim value.
	  In those cases, the application may need to define a convention
	  for the canonical case to use for representing the case-insensitive portions,
	  such as lowercasing them, if more than one party might need to
	  produce the same value so that they can be compared.
	  (However, if all other parties consume whatever value the producing party
	  emitted verbatim without attempting to compare it to an independently produced
	  value, then the case used by the producer will not matter.)
	</t>
      </section>

    </section>

    <section title="Implementation Requirements" anchor="ImplementationRequirements">

      <t>
	This section defines which algorithms and features of this specification
	are mandatory to implement.
	Applications using this specification can impose additional requirements
	upon implementations that they use.
	For instance, one application might require support for encrypted JWTs and Nested JWTs,
	while another might require support for signing JWTs with the
	Elliptic Curve Digital Signature Algorithm (ECDSA) using the P-256 curve and the SHA-256 hash algorithm
	(<spanx style="verb">ES256</spanx>).
      </t>
      <t>
	Of the signature and MAC algorithms specified in
	JSON Web Algorithms <xref target="JWA"/>, only
	HMAC SHA-256
	(<spanx style="verb">HS256</spanx>) and
	<spanx style="verb">none</spanx>
	MUST be implemented by conforming JWT implementations.
	It is RECOMMENDED that implementations also support
	RSASSA-PKCS1-v1_5 with the SHA-256 hash algorithm
	(<spanx style="verb">RS256</spanx>) and
	ECDSA using the P-256 curve and the SHA-256 hash algorithm
	(<spanx style="verb">ES256</spanx>).
	Support for other algorithms and key sizes is OPTIONAL.
      </t>
      <t>
	Support for encrypted JWTs is OPTIONAL.
	If an implementation provides encryption capabilities,
	of the encryption algorithms specified in
	<xref target="JWA"/>, only
	RSAES-PKCS1-v1_5 with 2048-bit keys
	(<spanx style="verb">RSA1_5</spanx>),
	AES Key Wrap with 128- and 256-bit keys
	(<spanx style="verb">A128KW</spanx> and <spanx style="verb">A256KW</spanx>), and
	the composite authenticated encryption algorithm using AES-CBC and HMAC SHA-2
	(<spanx style="verb">A128CBC-HS256</spanx> and <spanx style="verb">A256CBC-HS512</spanx>)
	MUST be implemented by conforming implementations.
	It is RECOMMENDED that implementations also support using
	Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES)
        to agree upon a key used to wrap the Content Encryption Key
	(<spanx style="verb">ECDH-ES+A128KW</spanx> and <spanx style="verb">ECDH-ES+A256KW</spanx>)
	and
	AES in Galois/Counter Mode (GCM) with 128- and 256-bit keys
	(<spanx style="verb">A128GCM</spanx> and <spanx style="verb">A256GCM</spanx>).
	Support for other algorithms and key sizes is OPTIONAL.
      </t>
      <t>
	Support for Nested JWTs is OPTIONAL.
      </t>

    </section>

    <section title="URI for Declaring that Content is a JWT" anchor="JWTURI">
      <t>
	This specification registers the URN
	<spanx style='verb'>urn:ietf:params:oauth:token&nbhy;type:jwt</spanx>
	for use by applications that declare content types using URIs
	(rather than, for instance, media types)
	to indicate that the content referred to is a JWT.
      </t>
    </section>

    <section title="IANA Considerations" anchor="IANA">

      <section title="JSON Web Token Claims Registry" anchor="JWTClaimsReg">
	<t>
	  This section establishes the
	  IANA "JSON Web Token Claims" registry
	  for JWT Claim Names.
	  The registry records the Claim Name
	  and a reference to the specification that defines it.
	  This section registers the Claim Names
	  defined in <xref target="RegisteredClaimName"/>.
	</t>
	<t>
	  Values are registered on a Specification Required
	  <xref target="RFC5226"/> basis after a three-week review period on the jwt-reg-review@ietf.org mailing
          list, on the advice of one or more Designated Experts. However, to allow for the
          allocation of values prior to publication, the Designated Experts may approve
          registration once they are satisfied that such a specification will be published.
	</t>
        <t>
          Registration requests sent to the mailing list for review should use
          an appropriate subject (e.g., "Request to register claim: example").
        </t>
        <t>
          Within the review period, the Designated Experts will either approve or
          deny the registration request, communicating this decision to the review list and IANA.
          Denials should include an explanation and, if applicable, suggestions as to how to make
          the request successful.
	  Registration requests that are undetermined for
	  a period longer than 21 days can be brought to the IESG's attention
	  (using the iesg@ietf.org mailing list) for resolution.
        </t>
	<t>
	  Criteria that should be applied by the Designated Experts includes
	  determining whether the proposed registration duplicates existing functionality,
	  whether it is likely to be of general applicability
	  or whether it is useful only for a single application,
	  and whether the registration description is clear.
	</t>
        <t>
          IANA must only accept registry updates from the Designated Experts and should direct
          all requests for registration to the review mailing list.
        </t>
	<t>
	  It is suggested that multiple Designated Experts be appointed who are able to
	  represent the perspectives of different applications using this specification,
	  in order to enable broadly informed review of registration decisions.
	  In cases where a registration decision could be perceived as
	  creating a conflict of interest for a particular Expert,
	  that Expert should defer to the judgment of the other Experts.
	</t>

        <section title="Registration Template" anchor="ClaimsTemplate">
          <t>
            <list style='hanging'>
              <t hangText='Claim Name:'>
                <vspace/>
                The name requested (e.g., "iss").
		Because a core goal of this specification is for the resulting
		representations to be compact, it is RECOMMENDED that the name be short
		-- that is, not to exceed 8 characters without a compelling reason to do so.
		This name is case sensitive.
		Names may not match other registered names in a case-insensitive manner
		unless the Designated Experts state that there is a compelling reason
		to allow an exception.
              </t>
              <t hangText='Claim Description:'>
                <vspace/>
                Brief description of the claim (e.g., "Issuer").
              </t>
              <t hangText='Change Controller:'>
                <vspace/>
                For Standards Track RFCs, list the "IESG". For others, give the name of the
                responsible party. Other details (e.g., postal address, email address, home page
                URI) may also be included.
              </t>
              <t hangText='Specification Document(s):'>
                <vspace/>
                Reference to the document or documents that specify the parameter,
		preferably including URIs that
                can be used to retrieve copies of the documents.
		An indication of the relevant
                sections may also be included but is not required.
              </t>
            </list>
          </t>
        </section>

        <section title="Initial Registry Contents" anchor="ClaimsContents">
          <t> <?rfc subcompact="yes"?>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">iss</spanx>
              </t>
              <t>
                Claim Description: Issuer
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="issDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">sub</spanx>
              </t>
              <t>
                Claim Description: Subject
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="subDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">aud</spanx>
              </t>
              <t>
                Claim Description: Audience
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="audDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
	    <list style='symbols'>
	      <t>
		Claim Name: <spanx style="verb">exp</spanx>
	      </t>
	      <t>
		Claim Description: Expiration Time
	      </t>
	      <t>
		Change Controller: IESG
	      </t>
	      <t>
		Specification Document(s): <xref target="expDef"/> of RFC 7519
	      </t>
	    </list>
	  </t>
	  <t>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">nbf</spanx>
              </t>
              <t>
                Claim Description: Not Before
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="nbfDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">iat</spanx>
              </t>
              <t>
                Claim Description: Issued At
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="iatDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
            <list style='symbols'>
              <t>
                Claim Name: <spanx style="verb">jti</spanx>
              </t>
              <t>
                Claim Description: JWT ID
              </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="jtiDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	</section>
	<?rfc subcompact="no"?>

      </section>

      <section title="Sub-Namespace Registration of urn:ietf:params:oauth:token&nbhy;type:jwt" anchor="URNReg">
	<section title="Registry Contents" anchor="URNContents">
	  <t>
	    This section registers the value
	    <spanx style='verb'>token-type:jwt</spanx> in the
	    IANA "OAuth URI" registry established by
	    <xref target="RFC6755">"An IETF URN Sub-Namespace for OAuth"</xref>,
	    which can be used to indicate that the content is a JWT.
	  </t>
	  <t> <?rfc subcompact="yes"?>
	  <list style='symbols'>
	    <t>URN: urn:ietf:params:oauth:token-type:jwt</t>
	    <t>Common Name: JSON Web Token (JWT) Token Type</t>
	    <t>Change Controller: IESG</t>
	    <t>Specification Document(s): RFC 7519</t>
	  </list>
	  </t>
	</section>
	<?rfc subcompact="no"?>
      </section>

      <section title="Media Type Registration" anchor="MediaReg">
	<section title="Registry Contents" anchor="MediaContents">
	  <t>
	    This section registers the <spanx
	    style="verb">application/jwt</spanx> media type <xref target="RFC2046"/>
	    in the "Media Types" registry <xref target="IANA.MediaTypes"/>
	    in the manner described in <xref target="RFC6838">RFC 6838</xref>,
	    which can be used to indicate that the content is a JWT.
	  </t>
	  <t> <?rfc subcompact="yes"?>
	    <list style="symbols">
	      <t>
		Type name: application
	      </t>
	      <t>
		Subtype name: jwt
	      </t>
	      <t>
		Required parameters: n/a
	      </t>
	      <t>
		Optional parameters: n/a
	      </t>
	      <t>
		Encoding considerations: 8bit;
		JWT values are encoded as a
		series of base64url-encoded values (some of which may be the
		empty string) separated by period ('.') characters.
	      </t>
	      <t>
		Security considerations: See the Security Considerations section of RFC 7519
	      </t>
	      <t>
		Interoperability considerations: n/a
	      </t>
	      <t>
		Published specification: RFC 7519
	      </t>
	      <t>
		Applications that use this media type:
		OpenID Connect, Mozilla Persona, Salesforce, Google, Android,
		Windows Azure, Amazon Web Services, and numerous others
	      </t>
	      <t>
		Fragment identifier considerations: n/a
	      </t>
	      <t>
		Additional information:<list style="empty">
	        <t>Magic number(s): n/a</t>
		<t>File extension(s): n/a</t>
		<t>Macintosh file type code(s): n/a </t></list>
<vspace/>
	      </t>
	      <t>
		Person &amp; email address to contact for further information:
<vspace/>
		Michael B.&nbsp;Jones, mbj@microsoft.com
	      </t>
	      <t>
		Intended usage: COMMON
	      </t>
	      <t>
		Restrictions on usage: none
	      </t>
	      <t>
		Author: Michael B.&nbsp;Jones, mbj@microsoft.com
	      </t>
	      <t>
		Change controller: IESG
	      </t>
	      <t>
		Provisional registration? No
	      </t>
	    </list>
	  </t>
	</section>
	<?rfc subcompact="no"?>
      </section>

      <section title="Header Parameter Names Registration" anchor="HdrReg">
	<t>
	  This section registers specific Claim Names defined in
	  <xref target="RegisteredClaimName"/> in the IANA
	  "JSON Web Signature and Encryption Header Parameters" registry
	  established by
	  <xref target="JWS" />
	  for use by claims replicated as Header Parameters in JWEs,
	  per <xref target="ClaimsAsHeaders"/>.
	</t>

        <section title="Registry Contents" anchor="HdrContents">
          <t> <?rfc subcompact="yes"?>
            <list style='symbols'>
              <t>
                Header Parameter Name: <spanx style="verb">iss</spanx>
              </t>
              <t>
                Header Parameter Description: Issuer
              </t>
	      <t>
		Header Parameter Usage Location(s): JWE
	      </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="issDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
 	    <list style='symbols'>
              <t>
                Header Parameter Name: <spanx style="verb">sub</spanx>
              </t>
              <t>
                Header Parameter Description: Subject
              </t>
	      <t>
		Header Parameter Usage Location(s): JWE
	      </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="subDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	  <t>
 	    <list style='symbols'>
              <t>
                Header Parameter Name: <spanx style="verb">aud</spanx>
              </t>
              <t>
                Header Parameter Description: Audience
              </t>
	      <t>
		Header Parameter Usage Location(s): JWE
	      </t>
              <t>
                Change Controller: IESG
              </t>
              <t>
                Specification Document(s): <xref target="audDef"/> of RFC 7519
              </t>
            </list>
	  </t>
	</section>
	<?rfc subcompact="no"?>
      </section>

    </section>

    <section title="Security Considerations" anchor="Security">
      <t>
	All of the security issues that are pertinent to any cryptographic application
	must be addressed by JWT/JWS/JWE/JWK agents.  Among these issues are protecting
	the user's asymmetric private and symmetric secret keys and
	employing countermeasures to various attacks.
      </t>
      <t>
	All the security considerations in the JWS specification also
	apply to JWT, as do the JWE security considerations when
	encryption is employed.  
	In particular,
	Sections 10.12 ("JSON Security Considerations") and
	10.13 ("Unicode Comparison Security Considerations")
	of <xref target="JWS"/>
	apply equally to the JWT Claims Set in the same manner that
	they do to the JOSE Header.
      </t>

      <section title="Trust Decisions" anchor="TrustDecisions">
	<t>
	  The contents of a JWT cannot be relied upon in a trust decision
	  unless its contents have been cryptographically secured and
	  bound to the context necessary for the trust decision.
	  In particular, the key(s) used to sign and/or encrypt the JWT
	  will typically need to verifiably be under the control
	  of the party identified as the issuer of the JWT.
	</t>
      </section>

      <section title="Signing and Encryption Order" anchor="SigEncOrder">
	<t>
	  While syntactically the signing and encryption operations for
	  Nested JWTs may be applied in any order,
	  if both signing and encryption are necessary,
	  normally producers should sign the message and then encrypt the
	  result (thus encrypting the signature). This prevents attacks
	  in which the signature is stripped, leaving just an encrypted
	  message, as well as providing privacy for the signer.
	  Furthermore, signatures over encrypted text are not considered
	  valid in many jurisdictions.
	</t>
	<t>
	  Note that potential concerns about security issues related to
	  the order of signing and encryption operations are already
	  addressed by the underlying JWS and JWE specifications;
	  in particular, because JWE only supports the use of
	  authenticated encryption algorithms, cryptographic concerns
	  about the potential need to sign after encryption that apply
	  in many contexts do not apply to this specification.
	</t>
      </section>

    </section>

    <section title="Privacy Considerations" anchor="Privacy">
      <t>
	A JWT may contain privacy-sensitive information.
	When this is the case, measures MUST be taken to prevent disclosure
	of this information to unintended parties.
	One way to achieve this is to use an encrypted JWT
	and authenticate the recipient.
	Another way is to ensure that JWTs containing unencrypted
	privacy-sensitive information are only transmitted using
	protocols utilizing encryption that support endpoint authentication, such as Transport Layer Security (TLS).
	Omitting privacy-sensitive information from a JWT is the
	simplest way of minimizing privacy issues.
      </t>
    </section>

  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.2119.xml' ?>
      <?rfc include='reference.RFC.2046.xml' ?>
      <?rfc include='reference.RFC.3986.xml' ?>
      <?rfc include='reference.RFC.4949.xml' ?>
      <?rfc include='reference.RFC.7159.xml' ?>

      <reference anchor="RFC20" target="http://www.rfc-editor.org/info/rfc20">
	<front>
	  <title>ASCII format for Network Interchange</title>
	  <author fullname="Vint Cerf" surname="Cerf" initials="V.">
	    <organization>University California Los Angeles (UCLA)</organization>
	  </author>
	  <date month="October" year="1969"/>
	</front>
	<seriesInfo name="STD" value="80"/>
	<seriesInfo name="RFC" value="20"/>
      </reference>

      <reference anchor="UNICODE" target="http://www.unicode.org/versions/latest/">
	<front>
	  <title abbrev="Unicode">The Unicode Standard</title>
	  <author>
	    <organization>The Unicode Consortium</organization>
	    <address />
	  </author>
	  <date/>
	</front>
      </reference>

     <!--draft-ietf-jose-json-web-signature: RFC 7515 -->
      <reference anchor="JWS" target="http://www.rfc-editor.org/info/rfc7515">
        <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="John Bradley" initials="J." surname="Bradley">
	    <organization abbrev="Ping Identity">Ping Identity</organization>
	    <address>
	      <email>ve7jtb@ve7jtb.com</email>
	    </address>
	  </author>
	  <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
	    <organization abbrev="NRI">Nomura Research Institute</organization>
	    <address>
	      <email>n-sakimura@nri.co.jp</email>
	    </address>
	  </author>
	  <date month="May" year="2015"/>
        </front>
        <seriesInfo name="RFC" value="7515" />
      </reference>

      <!--draft-ietf-jose-json-web-encryption: 7516-->
      <reference anchor="JWE" target="http://www.rfc-editor.org/info/rfc7516">
        <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>
	  <author fullname="Joe Hildebrand" initials="J." surname="Hildebrand">
	    <organization abbrev="Cisco">Cisco Systems, Inc.</organization>
	    <address>
	      <email>jhildebr@cisco.com</email>
	    </address>
	  </author>
	  <date month="May" year="2015"/>
        </front>
        <seriesInfo name="RFC" value="7516" />
      </reference>

      <!--draft-ietf-jose-json-web-algorithms: 7518-->
      <reference anchor="JWA" target="http://www.rfc-editor.org/info/rfc7518">
        <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 month="May" year="2015"/>
        </front>
        <seriesInfo name="RFC" value="7518"/>
      </reference>

      <reference anchor="ECMAScript" target="http://www.ecma-international.org/ecma-262/5.1/ECMA-262.pdf">
	<front>
	  <title>ECMAScript Language Specification, 5.1 Edition</title>
	  <author>
	    <organization>Ecma International</organization>
	  </author>
	  <date month="June" year="2011"/>
	</front>
	<seriesInfo name="ECMA Standard" value="262"/>
      </reference>

 <reference anchor="IANA.MediaTypes" target="http://www.iana.org/assignments/media-types">
        <front>
          <title>Media Types</title>
          <author>
            <organization>IANA</organization>
          </author>
	  <date/>
        </front>
      </reference>
    </references>

    <references title="Informative References">
      <?rfc include='reference.RFC.3275.xml' ?>
      <?rfc include='reference.RFC.3339.xml' ?>
      <?rfc include='reference.RFC.4122.xml' ?>
      <?rfc include='reference.RFC.5226.xml' ?>
      <?rfc include='reference.RFC.6755.xml' ?>
      <?rfc include='reference.RFC.6838.xml' ?>

<reference anchor="OASIS.saml-core-2.0-os" target="http://docs.oasis&nbhy;open.org/security/saml/v2.0/saml-core-2.0-os.pdf">
    <front>
        <title>Assertions and Protocols for the OASIS Security Assertion Markup Language
            (SAML) V2.0</title>
        <author fullname="Scott Cantor" initials="S." surname="Cantor">
            <organization>Internet2</organization>
            <address>
                <email>cantor.2@osu.edu</email>
            </address>
        </author>
        <author fullname="John Kemp" initials="J." surname="Kemp">
            <organization>Nokia</organization>
            <address>
                <email>John.Kemp@nokia.com</email>
            </address>
        </author>
        <author fullname="Rob Philpott" initials="R." surname="Philpott">
            <organization>RSA Security</organization>
            <address>
                <email>rphilpott@rsasecurity.com</email>
            </address>
        </author>
         <author fullname="Eve Maler" initials="E." surname="Maler">
            <organization>Sun Microsystems</organization>
            <address>
                <email>eve.maler@sun.com</email>
            </address>
        </author>
        <date year="2005" month="March"/>
    </front>
    <seriesInfo name="OASIS Standard" value="saml-core-2.0-os"/>
</reference>

<reference anchor='W3C.CR-xml11-20060816' target='http://www.w3.org/TR/2006/REC-xml11-20060816'>
<front>
<title>Extensible Markup Language (XML) 1.1 (Second Edition)</title>
<author initials='J' surname='Cowan' fullname='John Cowan'>
    <organization />
</author>
<date month='August' year='2006' />
</front>
<seriesInfo name='World Wide Web Consortium Recommendation' value='REC-xml11-20060816' />
</reference>


<reference anchor='W3C.REC-xml-c14n-20010315'
           target='http://www.w3.org/TR/2001/REC-xml-c14n-20010315'>
<front>
<title>Canonical XML Version 1.0</title>
<author initials='J.' surname='Boyer' fullname='John Boyer'>
    <organization />
</author>
<date month='March' year='2001' />
</front>
<seriesInfo name='World Wide Web Consortium Recommendation' value='REC-xml-c14n-20010315' />
</reference>

     <reference anchor="POSIX.1" target="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_15">
	<front>
	  <title>The Open Group Base Specifications Issue 7</title>
	  <author>
	    <organization>IEEE</organization>
	  </author>
	  <date year="2013"/>
	</front>
	<seriesInfo name="IEEE" value="Std 1003.1, 2013 Edition"/>
      </reference>

       <reference anchor="SWT" target="http://msdn.microsoft.com/en&nbhy;us/library/windowsazure/hh781551.aspx">
        <front>
          <title>Simple Web Token (SWT)</title>
          <author fullname="Dick Hardt" initials="D." surname="Hardt"></author>
          <author fullname="Yaron Y. Goland" initials="Y.Y." surname="Goland"></author>
          <date month="November" year="2009" />
        </front>
        <seriesInfo name="Version" value="0.9.5.1" />
      </reference>

       <reference anchor="MagicSignatures" target="http://salmon&nbhy;protocol.googlecode.com/svn/trunk/draft-panzer-magicsig-01.html">
        <front>
          <title>Magic Signatures</title>
          <author fullname="John Panzer" initials="J." surname="Panzer" role="editor"></author>
          <author fullname="Ben Laurie" initials="B." surname="Laurie"></author>
          <author fullname="Dirk Balfanz" initials="D." surname="Balfanz"></author>
          <date month="January" year="2011" />
        </front>
      </reference>

     <reference anchor="JSS" target="http://jsonenc.info/jss/1.0/">
        <front>
          <title>JSON Simple Sign</title>
	  <author fullname="John Bradley" initials="J." surname="Bradley">
	    <organization>Protivity Government Services</organization>
	  </author>
	  <author fullname="Nat Sakimura (editor)" initials="N. " surname="Sakimura (editor)">
	    <organization abbrev="NRI">Nomura Research Institute</organization>
	  </author>
          <date month="September" year="2010" />
        </front>
      </reference>

      <reference anchor="CanvasApp" target="http://developers.facebook.com/docs/authentication/canvas">
        <front>
          <title>Canvas Applications</title>
          <author><organization>Facebook</organization></author>
          <date year="2010" />
        </front>
      </reference>
    </references>

    <section title="JWT Examples" anchor="JWTExamples">
      
      <t>
	This section contains examples of JWTs.
	For other example JWTs, see <xref target="ExampleUnsecuredJWT"/> of this document and
	Appendices A.1 - A.3 of <xref target="JWS"/>.
      </t>

      <section title="Example Encrypted JWT" anchor="EncryptedJWTExample">
	<t>
	  This example encrypts the same claims as used in <xref target="ExampleJWT"/>
	  to the recipient using RSAES-PKCS1-v1_5 and AES_128_CBC_HMAC_SHA_256.
	</t>
	<t>
	  The following example JOSE Header declares that:
	  <list style="symbols">
	    <t>
	      The Content Encryption Key is encrypted to the recipient
	      using the RSAES-PKCS1-v1_5 algorithm to produce
	      the JWE Encrypted Key.
	    </t>
	    <t>
	      Authenticated encryption is performed on the plaintext
	      using the AES_128_CBC_HMAC_SHA_256 algorithm
	      to produce the JWE Ciphertext and the JWE Authentication Tag.
	    </t>
	  </list>
	</t>

	<figure><artwork><![CDATA[
  {"alg":"RSA1_5","enc":"A128CBC-HS256"}
]]></artwork></figure>

	<t>
	  Other than using the octets of the UTF-8 representation of
	  the JWT Claims Set from <xref target="ExampleJWT"/>
	  as the plaintext value, the computation of this JWT is
	  identical to the computation of the JWE in
	  Appendix A.2 of <xref target="JWE"/>,
	  including the keys used.
	</t>
	<t>
	  The final result in this example
	  (with line breaks for display purposes only) is:
	</t>
	<figure><artwork><![CDATA[
  eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
  QR1Owv2ug2WyPBnbQrRARTeEk9kDO2w8qDcjiHnSJflSdv1iNqhWXaKH4MqAkQtM
  oNfABIPJaZm0HaA415sv3aeuBWnD8J-Ui7Ah6cWafs3ZwwFKDFUUsWHSK-IPKxLG
  TkND09XyjORj_CHAgOPJ-Sd8ONQRnJvWn_hXV1BNMHzUjPyYwEsRhDhzjAD26ima
  sOTsgruobpYGoQcXUwFDn7moXPRfDE8-NoQX7N7ZYMmpUDkR-Cx9obNGwJQ3nM52
  YCitxoQVPzjbl7WBuB7AohdBoZOdZ24WlN1lVIeh8v1K4krB8xgKvRU8kgFrEn_a
  1rZgN5TiysnmzTROF869lQ.
  AxY8DCtDaGlsbGljb3RoZQ.
  MKOle7UQrG6nSxTLX6Mqwt0orbHvAKeWnDYvpIAeZ72deHxz3roJDXQyhxx0wKaM
  HDjUEOKIwrtkHthpqEanSBNYHZgmNOV7sln1Eu9g3J8.
  fiK51VwhsxJ-siBMR-YFiA
]]></artwork></figure>
      </section>

      <section title="Example Nested JWT" anchor="NestedJWTExample">
	<t>
	  This example shows how a JWT can be used as the payload
	  of a JWE or JWS to create a Nested JWT.
	  In this case, the JWT Claims Set is first signed, and then encrypted.
	</t>
	<t>
	  The inner signed JWT is identical to the example in
	  Appendix A.2 of <xref target="JWS"/>.
	  Therefore, its computation is not repeated here.
	  This example then encrypts this inner JWT
	  to the recipient using RSAES&nbhy;PKCS1-v1_5 and AES_128_CBC_HMAC_SHA_256.
	</t>
	<t>
	  The following example JOSE Header declares that:
	  <list style="symbols">
	    <t>
	      The Content Encryption Key is encrypted to the recipient
	      using the RSAES-PKCS1-v1_5 algorithm to produce
	      the JWE Encrypted Key.
	    </t>
	    <t>
	      Authenticated encryption is performed on the plaintext
	      using the AES_128_CBC_HMAC_SHA_256 algorithm
	      to produce the JWE Ciphertext and the JWE Authentication Tag.
	    </t>
	    <t>
	      The plaintext is itself a JWT.
	    </t>
	  </list>
	</t>

	<figure><artwork><![CDATA[
  {"alg":"RSA1_5","enc":"A128CBC-HS256","cty":"JWT"}
]]></artwork></figure>
	  <t>
	    Base64url encoding the octets of the UTF-8 representation of
	    the JOSE Header yields this encoded JOSE Header value:
	  </t>

	  <figure><artwork><![CDATA[
  eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiY3R5IjoiSldUIn0
]]></artwork></figure>

	<t>
	  The computation of this JWT is
	  identical to the computation of the JWE in
	  Appendix A.2 of <xref target="JWE"/>,
	  other than that different
	  JOSE Header,
	  plaintext,
	  JWE Initialization Vector, and
	  Content Encryption Key
	  values are used.
	  (The RSA key used is the same.)
	</t>
	<t>
	  The plaintext used is the octets of the ASCII <xref target="RFC20"/> representation of
	  the JWT at the end of Appendix A.2.1 of <xref target="JWS"/>
	  (with all whitespace and line breaks removed),
	  which is a sequence of 458 octets.
	</t>
	<t>
	  The JWE Initialization Vector value used (using JSON array notation) is:
	</t>
	<t>
	  [82, 101, 100, 109, 111, 110, 100, 32, 87, 65, 32, 57, 56, 48, 53, 50]
	</t>
	<t>
	  This example uses the Content Encryption Key
	  represented by the base64url-encoded value below:
	</t>
	<figure><artwork><![CDATA[
  GawgguFyGrWKav7AX4VKUg
]]></artwork></figure>
	<t>
	  The final result for this Nested JWT
	  (with line breaks for display purposes only) is:
	</t>
	<figure><artwork><![CDATA[
  eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiY3R5IjoiSldU
  In0.
  g_hEwksO1Ax8Qn7HoN-BVeBoa8FXe0kpyk_XdcSmxvcM5_P296JXXtoHISr_DD_M
  qewaQSH4dZOQHoUgKLeFly-9RI11TG-_Ge1bZFazBPwKC5lJ6OLANLMd0QSL4fYE
  b9ERe-epKYE3xb2jfY1AltHqBO-PM6j23Guj2yDKnFv6WO72tteVzm_2n17SBFvh
  DuR9a2nHTE67pe0XGBUS_TK7ecA-iVq5COeVdJR4U4VZGGlxRGPLRHvolVLEHx6D
  YyLpw30Ay9R6d68YCLi9FYTq3hIXPK_-dmPlOUlKvPr1GgJzRoeC9G5qCvdcHWsq
  JGTO_z3Wfo5zsqwkxruxwA.
  UmVkbW9uZCBXQSA5ODA1Mg.
  VwHERHPvCNcHHpTjkoigx3_ExK0Qc71RMEParpatm0X_qpg-w8kozSjfNIPPXiTB
  BLXR65CIPkFqz4l1Ae9w_uowKiwyi9acgVztAi-pSL8GQSXnaamh9kX1mdh3M_TT
  -FZGQFQsFhu0Z72gJKGdfGE-OE7hS1zuBD5oEUfk0Dmb0VzWEzpxxiSSBbBAzP10
  l56pPfAtrjEYw-7ygeMkwBl6Z_mLS6w6xUgKlvW6ULmkV-uLC4FUiyKECK4e3WZY
  Kw1bpgIqGYsw2v_grHjszJZ-_I5uM-9RA8ycX9KqPRp9gc6pXmoU_-27ATs9XCvr
  ZXUtK2902AUzqpeEUJYjWWxSNsS-r1TJ1I-FMJ4XyAiGrfmo9hQPcNBYxPz3GQb2
  8Y5CLSQfNgKSGt0A4isp1hBUXBHAndgtcslt7ZoQJaKe_nNJgNliWtWpJ_ebuOpE
  l8jdhehdccnRMIwAmU1n7SPkmhIl1HlSOpvcvDfhUN5wuqU955vOBvfkBOh5A11U
  zBuo2WlgZ6hYi9-e3w29bR0C2-pp3jbqxEDw3iWaf2dc5b-LnR0FEYXvI_tYk5rd
  _J9N0mg0tQ6RbpxNEMNoA9QWk5lgdPvbh9BaO195abQ.
  AVO9iT5AV4CzvDJCdhSFlQ
]]></artwork></figure>
      </section>

    </section>

    <section title="Relationship of JWTs to SAML Assertions" anchor="SAMLRelationship">
      <t>
	<xref target="OASIS.saml-core-2.0-os">Security Assertion Markup Language (SAML) 2.0</xref> provides
	a standard for creating security tokens with greater expressivity
	and more security options than supported by JWTs. However, the
	cost of this flexibility and expressiveness is both size and complexity.
	SAML's use of XML <xref target="W3C.CR-xml11-20060816"/> and
	XML Digital Signature (DSIG) <xref target="RFC3275"/> contributes to the size
	of SAML Assertions; its use of XML and especially
	XML Canonicalization <xref target="W3C.REC-xml-c14n-20010315"/>
	contributes to their complexity.
      </t>
      <t>
	JWTs are intended to provide a simple security token format that is
	small enough to fit into HTTP headers and query arguments in
	URIs. It does this by supporting a much simpler token model
	than SAML and using the JSON <xref target="RFC7159"/>
	object encoding syntax. It also supports securing tokens using
	Message Authentication Codes (MACs) and digital
	signatures using a smaller (and less flexible) format than XML
	DSIG.
      </t>
      <t>
	Therefore, while JWTs can do some of the things SAML Assertions
	do, JWTs are not intended as a full replacement for SAML
	Assertions, but rather as a token format to be used
	when ease of implementation or compactness are considerations.
      </t>
      <t>
	SAML Assertions are always statements made by an entity about a subject.
	JWTs are often used in the same manner, with the entity making the
	statements being represented by the <spanx style="verb">iss</spanx> (issuer) claim, and
	the subject being represented by the <spanx style="verb">sub</spanx> (subject) claim.
	However, with these claims being optional, other uses of the JWT format are also permitted.
      </t>
    </section>

    <section title="Relationship of JWTs to Simple Web Tokens (SWTs)" anchor="SWTRelationship">

      <t>
	Both JWTs and <xref target="SWT">SWTs</xref>,
	at their core, enable sets of claims to be communicated
	between applications.  For SWTs, both the claim names and
	claim values are strings.  For JWTs, while claim names are
	strings, claim values can be any JSON type.  Both token types
	offer cryptographic protection of their content: SWTs with
	HMAC SHA-256 and JWTs with a choice of algorithms, including
	signature, MAC, and encryption algorithms.
      </t>

    </section>

    <section title="Acknowledgements" anchor="Acknowledgements" numbered="no">

      <t>
	The authors acknowledge that the design of JWTs was
	intentionally influenced by the design and simplicity of <xref
	target="SWT">SWTs</xref> and ideas for JSON
	tokens that Dick Hardt discussed within the OpenID community.
      </t>
      <t>
	Solutions for signing JSON content were previously explored by
	<xref target="MagicSignatures">Magic Signatures</xref>, <xref
	target="JSS">JSON Simple Sign</xref>, and <xref
	target="CanvasApp">Canvas Applications</xref>, all of which
	influenced this document.
      </t>
      <t>
        This specification is the work of the OAuth working group,
	which includes dozens of active and dedicated participants.
	In particular, the following individuals contributed ideas,
        feedback, and wording that influenced this specification:
      </t>

      <t>
	Dirk Balfanz,
	Richard Barnes,
	Brian Campbell,
	Alissa Cooper,
	Breno de Medeiros,
	Stephen Farrell,
	Yaron Y.&nbsp;Goland,
	Dick Hardt,
	Joe Hildebrand,
	Jeff Hodges,
	Edmund Jay,
	Warren Kumari,
	Ben Laurie,
	Barry Leiba,
	Ted Lemon,
	James Manger,
	Prateek Mishra,
	Kathleen Moriarty,
	Tony Nadalin,
	Axel Nennker,
	John Panzer,
	Emmanuel Raviart,
	David Recordon,
	Eric Rescorla,
	Jim Schaad,
	Paul Tarjan,
	Hannes Tschofenig,
	Sean Turner,
	and Tom Yu.
      </t>
      <t>
	Hannes Tschofenig and Derek Atkins chaired the OAuth working group and
	Sean Turner, Stephen Farrell, and Kathleen Moriarty served as Security Area Directors
	during the creation of this specification.
      </t>
    </section>
  </back>
</rfc>
