JSON Web Token (JWT)Microsoftmbj@microsoft.comhttp://self-issued.info/Googlebalfanz@google.comPing Identityve7jtb@ve7jtb.comMicrosoftyarong@microsoft.comGooglejpanzer@google.comNomura Research Instituten-sakimura@nri.co.jpFacebookpt@fb.com
Security
RFCRequest for CommentsI-DInternet-DraftAssertionClaimSimple Web TokenSecurity TokenSWTJavaScript Object NotationJSONJSON Web TokenJWTJSON Web SignatureJWSJSON Web EncryptionJWEJSON Web KeyJWKJSON Web AlgorithmsJWA
JSON Web Token (JWT) is a means of representing claims to be
transferred between two parties. The claims in a JWT are
encoded as a JSON object that is digitally signed or MACed using JSON
Web Signature (JWS) and/or encrypted using JSON Web Encryption
(JWE).
The suggested pronunciation of JWT is the same as the English
word "jot".
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 RFC 2119.
JSON Web Token (JWT) is a compact token format intended for
space constrained environments such as HTTP Authorization
headers and URI query parameters. JWTs encode claims to be
transmitted as a JSON object (as defined in RFC 4627) that is base64url encoded
and digitally signed or MACed and/or encrypted. Signing and MACing is
performed using JSON Web Signature (JWS) . Encryption is performed using JSON Web Encryption
(JWE) .
The suggested pronunciation of JWT is the same as the English
word "jot".
A string consisting of multiple parts, the first being the
Encoded JWT Header, plus additional parts depending upon
the contents of the header, with the parts being separated
by period ('.') characters, and each part containing
base64url encoded content.
A string representing a JSON object that
describes the cryptographic operations applied to the JWT.
When the JWT is digitally signed or MACed, the JWT Header is a JWS Header.
When the JWT is encrypted, the JWT Header is a JWE Header.
The names of the members within the JWT Header.
The values of the members within the JWT Header.
A string representing a JSON object that
contains the claims conveyed by the JWT.
When the JWT is digitally signed or MACed, the bytes of the UTF-8 representation of the
JWT Claims Set are base64url encoded to create the Encoded JWS Payload.
When the JWT is encrypted, the bytes of the UTF-8 representation of the
JWT Claims Set are used as the JWE Plaintext.
The names of the members of the JSON object represented by
the JWT Claims Set.
The values of the members of the JSON object represented by
the JWT Claims Set.
Base64url encoding of the bytes of the
UTF-8 RFC 3629
representation of the JWT Header.
For the purposes of this specification, this term always
refers to the URL- and filename-safe Base64 encoding
described in RFC 4648,
Section 5, with the (non URL-safe) '=' padding characters
omitted, as permitted by Section 3.2. (See Appendix C of
for notes on implementing base64url
encoding without padding.)
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 as defined in
RFC 3986.
A JSON numeric value representing the number of seconds
from 1970-01-01T0:0:0Z UTC until the specified UTC date/time.
See RFC 3339 for details
regarding date/times in general and UTC in particular.
JWTs represent a set of claims as a JSON object that is
base64url encoded and digitally signed or MACed and/or
encrypted. The JWT Claims Set represents this JSON object.
As per RFC 4627
Section 2.2, 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.
The member names within the JWT Claims Set are
referred to as Claim Names. The
corresponding values are referred to as Claim Values.
The bytes of the UTF-8 representation of the JWT Claims Set
are digitally signed or MACed in the manner described in JSON Web Signature (JWS)
and/or encrypted in the manner described
in JSON Web Encryption (JWE) .
The contents of the JWT Header describe the cryptographic
operations applied to the JWT Claims Set.
If the JWT Header is a JWS Header, the claims are digitally signed or MACed.
If the JWT Header is a JWE Header, the claims are encrypted.
A JWT is represented as a JWS or JWE. The number of parts is
dependent upon the representation of the resulting JWS or JWE.
The following example JWT Header declares that the
encoded object is a JSON Web Token (JWT) and the JWT is
MACed using the HMAC SHA-256 algorithm:
Base64url encoding the bytes of the UTF-8 representation of
the JWT Header yields this Encoded JWS Header value,
which is used as the Encoded JWT Header:
The following is an example of a JWT Claims Set:
Base64url encoding the bytes of the UTF-8 representation of
the JSON Claims Set yields this Encoded JWS Payload
(with line breaks for display purposes only):
Signing the Encoded JWS Header and Encoded JWS Payload with
the HMAC SHA-256 algorithm and base64url encoding the
signature in the manner specified in ,
yields this Encoded JWS Signature:
Concatenating these parts in this order
with period characters between the
parts yields this complete JWT (with line breaks for
display purposes only):
This computation is illustrated in more detail in , Appendix A.1.
The JWT Claims Set represents a JSON object whose members
are the claims conveyed by the JWT.
The Claim Names within this object MUST be unique;
JWTs with duplicate Claim Names MUST be rejected.
Note however, that the set of claims that a
JWT must contain to be considered valid is context-dependent
and is outside the scope of this specification. When used in
a security-related context, implementations MUST understand
and support all of the claims present; otherwise, the JWT MUST
be rejected for processing.
There are three classes of JWT Claim Names: Reserved Claim
Names, Public Claim Names, and Private Claim Names.
The following claim names are reserved. None of the claims
defined below are intended to be mandatory, but
rather, provide a starting point for a set of useful,
interoperable claims. All the names are short because a
core goal of JWTs is for the tokens to be compact.
Additional reserved claim names MAY be defined via the
IANA JSON Web Token Claims registry .
The exp (expiration time)
claim identifies the expiration time on or after which the
token MUST NOT be accepted for processing. The processing
of the exp claim requires that
the current date/time MUST be before the expiration
date/time listed in the exp
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 an IntDate value.
This claim is OPTIONAL.
The nbf (not before) claim
identifies the time before which the token MUST NOT be
accepted for processing. The processing of the nbf claim requires that the current
date/time MUST be after or equal to the not-before
date/time listed in the nbf
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 an IntDate value.
This claim is OPTIONAL.
The iat (issued at) claim
identifies the time at which the JWT was issued. This
claim can be used to determine the age of the token.
Its value MUST be a number containing an IntDate value.
This claim is OPTIONAL.
The iss (issuer) claim
identifies the principal that issued the JWT. The
processing of this claim is generally application
specific.
The iss value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This claim is OPTIONAL.
The aud (audience) claim
identifies the audience that the JWT is intended for. The
principal intended to process the JWT MUST be identified
with the value of the audience claim. If the principal
processing the claim does not identify itself with the
identifier in the aud claim
value then the JWT MUST be rejected. The interpretation
of the audience value is generally
application specific.
The aud value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This claim is OPTIONAL.
The prn (principal) claim
identifies the subject of the JWT. The processing of this
claim is generally application specific.
The prn value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This claim is OPTIONAL.
The jti (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. The
jti claim can be used to
prevent the JWT from being replayed.
The jti value is case sensitive.
Its value MUST be a string.
This claim is OPTIONAL.
The typ (type) claim is used
to declare a type for the contents of this JWT Claims Set.
The typ value is case sensitive.
Its value MUST be a string.
This claim is OPTIONAL.
The values used for the typ
claim SHOULD come from the same value space as the
typ header parameter,
with the same rules applying.
Claim names can be defined at will by those using
JWTs. However, in order to prevent collisions, any new claim
name SHOULD either be defined in the
IANA JSON Web Token Claims registry
or be
a URI that contains a collision resistant namespace.
Examples of collision resistant namespaces include:
Domain Names,
Object Identifiers (OIDs) as defined in the ITU-T X.660
and X.670 Recommendation series, or
Universally Unique IDentifier (UUID) as defined in RFC 4122.
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.
A producer and consumer of a JWT may agree to any claim
name that is not a Reserved Name or a Public Name . Unlike Public Names,
these private names are subject to collision and should be
used with caution.
The members of the JSON object represented by the JWT Header
describe the cryptographic operations applied to the JWT and
optionally, additional properties of the JWT.
The member names within the JWT Header are
referred to as Header Parameter Names.
These names MUST be unique;
JWTs with duplicate Header Parameter Names MUST be rejected.
The corresponding values are referred to as Header Parameter Values.
Implementations MUST understand the entire contents of the
header; otherwise, the JWT MUST be rejected for processing.
There are two ways of distinguishing whether the JWT is a JWS
or JWE. The first is by examining the alg (algorithm) header value. If the
value represents a signature algorithm, the JWT is a JWS; if
it represents an encryption algorithm, the JWT is a JWE. A
second method is determining whether an enc (encryption method) member exists.
If the enc member exists, the JWT
is a JWE; otherwise, the JWT is a JWS. Both methods will
yield the same result.
JWS Header Parameters are defined by .
JWE Header Parameters are defined by .
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.
The typ (type) header parameter
is used to declare structural information about the JWT.
In the normal case where nested signing or encryption
operations are not employed, the use of this header
parameter is OPTIONAL, and if present, it is RECOMMENDED that
its value be either "JWT" or
"urn:ietf:params:oauth:token-type:jwt".
In the case that nested signing or encryption steps are
employed, the use of this header parameter is REQUIRED; in
this case, the value MUST either be "JWS", to indicate that
a nested digitally signed or MACed JWT is carried in this JWT or "JWE", to
indicate that a nested encrypted JWT is carried in this JWT.
To support use cases where the JWT content is secured by a
means other than a signature and/or encryption contained
within the token (such as a signature on a data structure
containing the token), JWTs MAY also be created without a
signature or encryption. A plaintext JWT is a JWS using the
none JWS alg header parameter value defined in
JSON Web Algorithms (JWA) ; it is a
JWS with an empty JWS Signature value.
The following example JWT Header declares that the
encoded object is a Plaintext JWT:
Base64url encoding the bytes of the UTF-8 representation of
the JWT Header yields this Encoded JWT Header:
The following is an example of a JWT Claims Set:
Base64url encoding the bytes of the UTF-8 representation of
the JSON Claims Set yields this Encoded JWS Payload
(with line breaks for display purposes only):
The Encoded JWS Signature is the empty string.
Concatenating these parts in this order
with period characters between the
parts yields this complete JWT (with line breaks for
display purposes only):
To create a JWT, one MUST perform these steps. The order of
the steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps.
Create a JWT Claims Set containing the desired claims.
Note that white space is explicitly allowed in the
representation and no canonicalization is performed before
encoding.
Let the Message be the bytes of the UTF-8 representation
of the JWT Claims Set.
Create a JWT Header containing the desired set of header
parameters. The JWT
MUST conform to either the or specifications.
Note that white
space is explicitly allowed in the representation and no
canonicalization is performed before encoding.
Base64url encode the bytes of the UTF-8 representation of
the JWT Header. Let this be the Encoded JWT Header.
Depending upon whether the JWT is a JWS or JWE,
there are two cases:
If the JWT is a JWS, create a JWS using the JWT
Header as the JWS Header and the Message as the JWS
Payload; all steps specified in
for creating a JWS MUST be followed.
Else, if the JWT is a JWE, create a JWE using the
JWT Header as the JWE Header and the Message as the
JWE Plaintext; all steps specified in for creating a JWE MUST be followed.
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 typ
value of either "JWS" or "JWE" respectively in the
new JWT Header created in that step.
Otherwise, let the resulting JWT be the JWS or JWE.
When validating a JWT the following steps MUST be taken. 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 fails then the token MUST be
rejected for processing.
The JWT MUST contain at least one period character.
Let the Encoded JWT Header be the portion of the JWT
before the first period character.
The Encoded JWT Header MUST be successfully base64url
decoded following the restriction given in this
specification that no padding characters have been used.
The resulting JWT Header MUST be completely valid JSON syntax
conforming to RFC 4627.
The resulting JWT Header MUST be validated to only include
parameters and values whose syntax and semantics are both
understood and supported.
Determine whether the JWT is a JWS or a JWE by
examining the alg
(algorithm) header value and optionally, the enc (encryption method) header value,
if present.
Depending upon whether the JWT is a JWS or JWE,
there are two cases:
If the JWT is a JWS, all steps specified in for validating a JWS MUST be followed.
Let the Message be the result of base64url decoding
the JWS Payload.
Else, if the JWT is a JWE, all steps specified in for validating a JWE MUST be followed.
Let the Message be the JWE Plaintext.
If the JWT Header contains a typ value of either "JWS" or "JWE",
then the Message contains a JWT that was the subject of
nested signing or encryption operations, respectively. In
this case, return to Step 1, using the Message as the JWT.
Otherwise, let the JWT Claims Set be the Message.
The JWT Claims Set MUST be completely valid
JSON syntax conforming to RFC
4627.
When used in a security-related context, the
JWT Claims Set MUST be validated to only include claims
whose syntax and semantics are both understood and
supported.
Processing a JWT inevitably requires comparing known strings
to values in the token. For example, in checking what the
algorithm is, the Unicode string encoding alg will be
checked against the member names in the JWT Header
to see if there is a matching header parameter
name. A similar process occurs when determining if the value
of the alg header parameter represents a supported
algorithm.
Comparisons between JSON strings and other Unicode strings
MUST be performed as specified below:
Remove any JSON applied escaping to produce an array of
Unicode code points.
Unicode Normalization MUST NOT
be applied at any point to either the JSON string or to
the string it is to be compared against.
Comparisons between the two strings MUST be performed as a
Unicode code point to code point equality comparison.
JWTs use JSON Web Signature (JWS) and
JSON Web Encryption (JWE) to sign and/or
encrypt the contents of the JWT.
Of the JWS signing algorithms, only HMAC SHA-256 and none MUST be
implemented by conforming JWT implementations. It is
RECOMMENDED that implementations also support the RSA SHA-256
and ECDSA P-256 SHA-256 algorithms. Support for other
algorithms and key sizes is OPTIONAL.
If an implementation provides encryption capabilities,
of the JWE encryption algorithms, only RSA-PKCS1-1.5 with 2048 bit keys,
AES-128-KW, AES-256-KW,
AES-128-CBC, and AES-256-CBC MUST be implemented by conforming
implementations. It is RECOMMENDED that implementations also
support ECDH-ES with 256 bit keys, AES-128-GCM, and
AES-256-GCM. Support for other algorithms and key sizes is
OPTIONAL.
This specification establishes the
IANA JSON Web Token Claims registry
for reserved JWT claim names.
Inclusion in the registry is RFC Required in the
RFC 5226 sense.
The registry records the reserved claim name
and a reference to the RFC that defines it.
This specification registers the claim names
defined in .
This specification registers the value
token-type:jwt in the
registry urn:ietf:params:oauth established in
An IETF URN Sub-Namespace for OAuth.
URN: urn:ietf:params:oauth:token-type:jwtCommon Name: JSON Web Token (JWT) Token TypeChange controller: IETFDescription: [[this document]]
This specification registers the application/jwt MIME Media Type
RFC 2045.
application
jwt
n/a
n/a
n/a
See the Security Considerations section of this document
n/a
[[ this document ]]
OpenID Connect, Mozilla Browser ID, Salesforce, Google, numerous others
Magic number(s): n/a
File extension(s): n/a
Macintosh file type code(s): n/a
Michael B. Jones
mbj@microsoft.com
COMMON
none
Michael B. Jones
mbj@microsoft.com
Michael B. Jones
mbj@microsoft.com
This specification registers the following typ
header parameter value in the
JSON Web Signature and Encryption "typ" Values registry established by the
JSON Web Algorithms (JWA) specification:
"JWT"
application/jwt
Michael B. Jones
mbj@microsoft.com
[[ this document ]]
All the security considerations in the JWS specification also
apply to JWT, as do the JWE security considerations when
encryption is employed. In particular, the JWS
JSON Security Considerations and Unicode Comparison Security Considerations
apply equally to the JWT Claims Set in the same manner that
they do to the JWS Header.
The following items remain to be done in this draft:
Provide an example of an encrypted JWT.
Unicode Normalization Formsmarkdavis@google.comken@unicode.orgJSON Web Signature (JWS)Microsoftmbj@microsoft.comhttp://self-issued.info/Ping Identityve7jtb@ve7jtb.comNomura Research Instituten-sakimura@nri.co.jpJSON Web Encryption (JWE)Microsoftmbj@microsoft.comhttp://self-issued.info/RTFM, Inc.ekr@rtfm.comCisco Systems, Inc.jhildebr@cisco.comJSON Web Algorithms (JWA)Microsoftmbj@microsoft.comhttp://self-issued.info/Simple Web Token (SWT)Magic SignaturesJSON Simple SignindependentNomura Research InstituteCanvas ApplicationsSAML 2.0 provides
a standard for creating tokens with much greater expressivity
and more security options than supported by JWTs. However, the
cost of this flexibility and expressiveness is both size and
complexity. In addition, SAML's use of XML and XML DSIG only contributes to the size
of SAML tokens.
JWTs are intended to provide a simple 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
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.
Therefore, while JWTs can do some of the things SAML tokens
do, JWTs are not intended as a full replacement for SAML
tokens, but rather as a compromise token format to be used
when space is at a premium.
Both JWTs and Simple Web Tokens SWT,
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
HMAC SHA-256, RSA SHA-256, and ECDSA P-256 SHA-256.
The authors acknowledge that the design of JWTs was
intentionally influenced by the design and simplicity of Simple Web Tokens and ideas for JSON
tokens that Dick Hardt discussed within the OpenID community.
Solutions for signing JSON content were previously explored by
Magic Signatures, JSON Simple Sign, and Canvas Applications, all of which
influenced this draft.
-10
Clarified the relationship between
typ header parameter values,
typ claim values,
and MIME types.
Clarified that JWTs with duplicate Header Parameter Names
or Duplicate Claim names MUST be rejected.
Required implementation of AES-128-KW and AES-256-KW
when the implementation provides encryption capabilities.
Registered "JWT" typ header parameter value.
Generalized language to refer to Message Authentication Codes (MACs)
rather than Hash-based Message Authentication Codes (HMACs)
unless in a context specific to HMAC algorithms.
Reformatted to give each claim definition and
header parameter its own section heading.
-09
Changed "http://openid.net/specs/jwt/1.0" to
"urn:ietf:params:oauth:token-type:jwt" in preparation for
OAuth WG draft.
-08
Removed language that required that a JWT must have three
parts. Now the number of parts is explicitly dependent
upon the representation of the underlying JWS or JWE.
Moved the "alg":"none" definition to the JWS spec.
Registered the application/jwt
MIME Media Type.
Clarified that the order of the creation and validation
steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps.
Corrected the Magic Signatures and Simple Web Token (SWT) references.
-07
Defined the prn (principal)
claim to identify the subject of the JWT.
Defined the jti (JWT ID)
claim to enable replay protection.
Use the term "JWT Claims Set" rather than "JWT Claims Object"
since this is actually a string representing a JSON object
and not the JSON object itself.
Moved "MUST" requirements from the Overview to later in
the spec.
Respect line length restrictions in examples.
Applied other editorial improvements.
-06
Reference and use content from and
, rather than repeating it here.
Simplified terminology to better match JWE, where the
terms "JWT Header" and "Encoded JWT Header" are now used,
for instance, rather than the previous terms "Decoded JWT
Header Segment" and "JWT Header Segment". Also changed to
"Plaintext JWT" from "Unsigned JWT".
Describe how to perform nested encryption and signing
operations.
Changed "integer" to "number", since that is the correct
JSON type.
Changed StringAndURI to StringOrURI.
-05
Added the nbf (not before)
claim and clarified the meaning of the iat (issued at) claim.
-04
Correct typo found by John Bradley: "the JWT Claim Segment
is the empty string" -> "the JWT Crypto Segment is the
empty string".
-03
Added "http://openid.net/specs/jwt/1.0" as a token type
identifier URI for JWTs.
Added iat (issued at) claim.
Changed RSA SHA-256 from MUST be supported to RECOMMENDED
that it be supported. Rationale: Several people have
objected to the requirement for implementing RSA SHA-256,
some because they will only be using HMACs and symmetric
keys, and others because they only want to use ECDSA when
using asymmetric keys, either for security or key length
reasons, or both.
Defined alg value none to represent unsigned JWTs.
-02
Split signature specification out into separate
draft-jones-json-web-signature-00. This split introduced
no semantic changes.
The JWT Compact Serialization is now the only token
serialization format specified in this draft. The JWT
JSON Serialization can continue to be defined in a
companion specification.
-01
Draft incorporating consensus decisions reached at IIW.
-00
Public draft published before November 2010 IIW based upon
the JSON token convergence proposal incorporating input
from several implementers of related specifications.