idnits 2.17.00 (12 Aug 2021) /tmp/idnits16643/draft-ietf-oauth-json-web-token-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to use 'NOT RECOMMENDED' as an RFC 2119 keyword, but does not include the phrase in its RFC 2119 key words list. -- The document date (July 16, 2012) is 3595 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Outdated reference: draft-ietf-oauth-urn-sub-ns has been published as RFC 6755 ** Downref: Normative reference to an Informational draft: draft-ietf-oauth-urn-sub-ns (ref. 'I-D.ietf-oauth-urn-sub-ns') -- Possible downref: Non-RFC (?) normative reference: ref. 'JWA' -- Possible downref: Non-RFC (?) normative reference: ref. 'JWE' -- Possible downref: Non-RFC (?) normative reference: ref. 'JWS' ** Obsolete normative reference: RFC 4288 (Obsoleted by RFC 6838) ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) -- Possible downref: Non-RFC (?) normative reference: ref. 'USA15' Summary: 4 errors (**), 0 flaws (~~), 3 warnings (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 OAuth Working Group M. Jones 3 Internet-Draft Microsoft 4 Intended status: Standards Track J. Bradley 5 Expires: January 17, 2013 Ping Identity 6 N. Sakimura 7 NRI 8 July 16, 2012 10 JSON Web Token (JWT) 11 draft-ietf-oauth-json-web-token-02 13 Abstract 15 JSON Web Token (JWT) is a means of representing claims to be 16 transferred between two parties. The claims in a JWT are encoded as 17 a JavaScript Object Notation (JSON) object that is digitally signed 18 or MACed using JSON Web Signature (JWS) and/or encrypted using JSON 19 Web Encryption (JWE). 21 The suggested pronunciation of JWT is the same as the English word 22 "jot". 24 Status of this Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at http://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on January 17, 2013. 41 Copyright Notice 43 Copyright (c) 2012 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 59 1.1. Notational Conventions . . . . . . . . . . . . . . . . . . 5 60 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 61 3. JSON Web Token (JWT) Overview . . . . . . . . . . . . . . . . 6 62 3.1. Example JWT . . . . . . . . . . . . . . . . . . . . . . . 7 63 4. JWT Claims . . . . . . . . . . . . . . . . . . . . . . . . . . 8 64 4.1. Reserved Claim Names . . . . . . . . . . . . . . . . . . . 8 65 4.1.1. "exp" (Expiration Time) Claim . . . . . . . . . . . . 8 66 4.1.2. "nbf" (Not Before) Claim . . . . . . . . . . . . . . . 8 67 4.1.3. "iat" (Issued At) Claim . . . . . . . . . . . . . . . 9 68 4.1.4. "iss" (Issuer) Claim . . . . . . . . . . . . . . . . . 9 69 4.1.5. "aud" (Audience) Claim . . . . . . . . . . . . . . . . 9 70 4.1.6. "prn" (Principal) Claim . . . . . . . . . . . . . . . 9 71 4.1.7. "jti" (JWT ID) Claim . . . . . . . . . . . . . . . . . 9 72 4.1.8. "typ" (Type) Claim . . . . . . . . . . . . . . . . . . 10 73 4.2. Public Claim Names . . . . . . . . . . . . . . . . . . . . 10 74 4.3. Private Claim Names . . . . . . . . . . . . . . . . . . . 10 75 5. JWT Header . . . . . . . . . . . . . . . . . . . . . . . . . . 10 76 5.1. "typ" (Type) Header Parameter . . . . . . . . . . . . . . 10 77 5.2. "cty" (Content Type) Header Parameter . . . . . . . . . . 11 78 6. Plaintext JWTs . . . . . . . . . . . . . . . . . . . . . . . . 11 79 6.1. Example Plaintext JWT . . . . . . . . . . . . . . . . . . 11 80 7. Rules for Creating and Validating a JWT . . . . . . . . . . . 12 81 8. Cryptographic Algorithms . . . . . . . . . . . . . . . . . . . 14 82 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 83 9.1. JSON Web Token Claims Registry . . . . . . . . . . . . . . 15 84 9.1.1. Registration Template . . . . . . . . . . . . . . . . 15 85 9.1.2. Initial Registry Contents . . . . . . . . . . . . . . 16 86 9.2. Sub-Namespace Registration of 87 urn:ietf:params:oauth:token-type:jwt . . . . . . . . . . . 17 88 9.2.1. Registry Contents . . . . . . . . . . . . . . . . . . 17 89 9.3. JSON Web Signature and Encryption Type Values 90 Registration . . . . . . . . . . . . . . . . . . . . . . . 17 91 9.3.1. Registry Contents . . . . . . . . . . . . . . . . . . 17 92 9.4. Media Type Registration . . . . . . . . . . . . . . . . . 17 93 9.4.1. Registry Contents . . . . . . . . . . . . . . . . . . 17 94 10. Security Considerations . . . . . . . . . . . . . . . . . . . 18 95 11. Open Issues . . . . . . . . . . . . . . . . . . . . . . . . . 19 96 12. References . . . . . . . . . . . . . . . . . . . . . . . . . . 19 97 12.1. Normative References . . . . . . . . . . . . . . . . . . . 19 98 12.2. Informative References . . . . . . . . . . . . . . . . . . 20 99 Appendix A. Example Encrypted JWT . . . . . . . . . . . . . . . . 21 100 Appendix B. Relationship of JWTs to SAML Tokens . . . . . . . . . 22 101 Appendix C. Relationship of JWTs to Simple Web Tokens (SWTs) . . 22 102 Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 22 103 Appendix E. Document History . . . . . . . . . . . . . . . . . . 23 104 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 23 106 1. Introduction 108 JSON Web Token (JWT) is a compact token format intended for space 109 constrained environments such as HTTP Authorization headers and URI 110 query parameters. JWTs encode claims to be transmitted as a 111 JavaScript Object Notation (JSON) [RFC4627] object that is base64url 112 encoded and digitally signed or MACed and/or encrypted. Signing and 113 MACing is performed using JSON Web Signature (JWS) [JWS]. Encryption 114 is performed using JSON Web Encryption (JWE) [JWE]. 116 The suggested pronunciation of JWT is the same as the English word 117 "jot". 119 1.1. Notational Conventions 121 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 122 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 123 document are to be interpreted as described in Key words for use in 124 RFCs to Indicate Requirement Levels [RFC2119]. 126 2. Terminology 128 JSON Web Token (JWT) A string representing a set of claims as a JSON 129 object that is digitally signed or MACed and/or encrypted. The 130 string consists of multiple parts, the first being the Encoded JWT 131 Header, plus additional parts depending upon the contents of the 132 header, with the parts being separated by period ('.') characters, 133 and each part containing base64url encoded content. 135 Base64url Encoding The URL- and filename-safe Base64 encoding 136 described in RFC 4648 [RFC4648], Section 5, with the (non URL- 137 safe) '=' padding characters omitted, as permitted by Section 3.2. 138 (See Appendix C of [JWS] for notes on implementing base64url 139 encoding without padding.) 141 JWT Header A string representing a JSON object that describes the 142 cryptographic operations applied to the JWT. When the JWT is 143 digitally signed or MACed, the JWT Header is a JWS Header. When 144 the JWT is encrypted, the JWT Header is a JWE Header. 146 Header Parameter Name The name of a member of the JSON object 147 representing a JWT Header. 149 Header Parameter Value The value of a member of the JSON object 150 representing a JWT Header. 152 JWT Claims Set A string representing a JSON object that contains the 153 claims conveyed by the JWT. When the JWT is digitally signed or 154 MACed, the bytes of the UTF-8 representation of the JWT Claims Set 155 are base64url encoded to create the Encoded JWS Payload. When the 156 JWT is encrypted, the bytes of the UTF-8 representation of the JWT 157 Claims Set are used as the JWE Plaintext. 159 Claim Name The name of a member of the JSON object representing a 160 JWT Claims Set. 162 Claim Value The value of a member of the JSON object representing a 163 JWT Claims Set. 165 Encoded JWT Header Base64url encoding of the bytes of the UTF-8 166 [RFC3629] representation of the JWT Header. 168 Collision Resistant Namespace A namespace that allows names to be 169 allocated in a manner such that they are highly unlikely to 170 collide with other names. For instance, collision resistance can 171 be achieved through administrative delegation of portions of the 172 namespace or through use of collision-resistant name allocation 173 functions. Examples of Collision Resistant Namespaces include: 174 Domain Names, Object Identifiers (OIDs) as defined in the ITU-T 175 X.660 and X.670 Recommendation series, and Universally Unique 176 IDentifiers (UUIDs) [RFC4122]. When using an administratively 177 delegated namespace, the definer of a name needs to take 178 reasonable precautions to ensure they are in control of the 179 portion of the namespace they use to define the name. 181 StringOrURI A JSON string value, with the additional requirement 182 that while arbitrary string values MAY be used, any value 183 containing a ":" character MUST be a URI [RFC3986]. 185 IntDate A JSON numeric value representing the number of seconds from 186 1970-01-01T0:0:0Z UTC until the specified UTC date/time. See RFC 187 3339 [RFC3339] for details regarding date/times in general and UTC 188 in particular. 190 3. JSON Web Token (JWT) Overview 192 JWTs represent a set of claims as a JSON object that is base64url 193 encoded and digitally signed or MACed and/or encrypted. The JWT 194 Claims Set represents this JSON object. As per RFC 4627 [RFC4627] 195 Section 2.2, the JSON object consists of zero or more name/value 196 pairs (or members), where the names are strings and the values are 197 arbitrary JSON values. These members are the claims represented by 198 the JWT. 200 The member names within the JWT Claims Set are referred to as Claim 201 Names. The corresponding values are referred to as Claim Values. 203 The bytes of the UTF-8 representation of the JWT Claims Set are 204 digitally signed or MACed in the manner described in JSON Web 205 Signature (JWS) [JWS] and/or encrypted in the manner described in 206 JSON Web Encryption (JWE) [JWE]. 208 The contents of the JWT Header describe the cryptographic operations 209 applied to the JWT Claims Set. If the JWT Header is a JWS Header, the 210 claims are digitally signed or MACed. If the JWT Header is a JWE 211 Header, the claims are encrypted. 213 A JWT is represented as a JWS or JWE. The number of parts is 214 dependent upon the representation of the resulting JWS or JWE. 216 3.1. Example JWT 218 The following example JWT Header declares that the encoded object is 219 a JSON Web Token (JWT) and the JWT is MACed using the HMAC SHA-256 220 algorithm: 221 {"typ":"JWT", 222 "alg":"HS256"} 224 Base64url encoding the bytes of the UTF-8 representation of the JWT 225 Header yields this Encoded JWS Header value, which is used as the 226 Encoded JWT Header: 227 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 229 The following is an example of a JWT Claims Set: 230 {"iss":"joe", 231 "exp":1300819380, 232 "http://example.com/is_root":true} 234 Base64url encoding the bytes of the UTF-8 representation of the JSON 235 Claims Set yields this Encoded JWS Payload (with line breaks for 236 display purposes only): 237 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly 238 9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 240 Signing the Encoded JWS Header and Encoded JWS Payload with the HMAC 241 SHA-256 algorithm and base64url encoding the signature in the manner 242 specified in [JWS], yields this Encoded JWS Signature: 243 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 245 Concatenating these parts in this order with period characters 246 between the parts yields this complete JWT (with line breaks for 247 display purposes only): 249 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 250 . 251 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 252 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 253 . 254 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 256 This computation is illustrated in more detail in [JWS], Appendix 257 A.1. See Appendix A for an example of an encrypted JWT. 259 4. JWT Claims 261 The JWT Claims Set represents a JSON object whose members are the 262 claims conveyed by the JWT. The Claim Names within this object MUST 263 be unique; JWTs with duplicate Claim Names MUST be rejected. Note 264 however, that the set of claims that a JWT must contain to be 265 considered valid is context-dependent and is outside the scope of 266 this specification. When used in a security-related context, 267 implementations MUST understand and support all of the claims 268 present; otherwise, the JWT MUST be rejected for processing. 270 There are three classes of JWT Claim Names: Reserved Claim Names, 271 Public Claim Names, and Private Claim Names. 273 4.1. Reserved Claim Names 275 The following claim names are reserved. None of the claims defined 276 below are intended to be mandatory, but rather, provide a starting 277 point for a set of useful, interoperable claims. All the names are 278 short because a core goal of JWTs is for the tokens to be compact. 279 Additional reserved claim names MAY be defined via the IANA JSON Web 280 Token Claims registry Section 9.1. 282 4.1.1. "exp" (Expiration Time) Claim 284 The "exp" (expiration time) claim identifies the expiration time on 285 or after which the token MUST NOT be accepted for processing. The 286 processing of the "exp" claim requires that the current date/time 287 MUST be before the expiration date/time listed in the "exp" claim. 288 Implementers MAY provide for some small leeway, usually no more than 289 a few minutes, to account for clock skew. Its value MUST be a number 290 containing an IntDate value. This claim is OPTIONAL. 292 4.1.2. "nbf" (Not Before) Claim 294 The "nbf" (not before) claim identifies the time before which the 295 token MUST NOT be accepted for processing. The processing of the 296 "nbf" claim requires that the current date/time MUST be after or 297 equal to the not-before date/time listed in the "nbf" claim. 298 Implementers MAY provide for some small leeway, usually no more than 299 a few minutes, to account for clock skew. Its value MUST be a number 300 containing an IntDate value. This claim is OPTIONAL. 302 4.1.3. "iat" (Issued At) Claim 304 The "iat" (issued at) claim identifies the time at which the JWT was 305 issued. This claim can be used to determine the age of the token. 306 Its value MUST be a number containing an IntDate value. This claim 307 is OPTIONAL. 309 4.1.4. "iss" (Issuer) Claim 311 The "iss" (issuer) claim identifies the principal that issued the 312 JWT. The processing of this claim is generally application specific. 313 The "iss" value is a case sensitive string containing a StringOrURI 314 value. This claim is OPTIONAL. 316 4.1.5. "aud" (Audience) Claim 318 The "aud" (audience) claim identifies the audience that the JWT is 319 intended for. The principal intended to process the JWT MUST be 320 identified with the value of the audience claim. If the principal 321 processing the claim does not identify itself with the identifier in 322 the "aud" claim value then the JWT MUST be rejected. The 323 interpretation of the audience value is generally application 324 specific. The "aud" value is a case sensitive string containing a 325 StringOrURI value. This claim is OPTIONAL. 327 4.1.6. "prn" (Principal) Claim 329 The "prn" (principal) claim identifies the subject of the JWT. The 330 processing of this claim is generally application specific. The 331 "prn" value is a case sensitive string containing a StringOrURI 332 value. This claim is OPTIONAL. 334 4.1.7. "jti" (JWT ID) Claim 336 The "jti" (JWT ID) claim provides a unique identifier for the JWT. 337 The identifier value MUST be assigned in a manner that ensures that 338 there is a negligible probability that the same value will be 339 accidentally assigned to a different data object. The "jti" claim 340 can be used to prevent the JWT from being replayed. The "jti" value 341 is a case sensitive string. This claim is OPTIONAL. 343 4.1.8. "typ" (Type) Claim 345 The "typ" (type) claim is used to declare a type for the contents of 346 this JWT Claims Set. The "typ" value is a case sensitive string. 347 This claim is OPTIONAL. 349 The values used for the "typ" claim come from the same value space as 350 the "typ" header parameter, with the same rules applying. 352 4.2. Public Claim Names 354 Claim names can be defined at will by those using JWTs. However, in 355 order to prevent collisions, any new claim name SHOULD either be 356 registered in the IANA JSON Web Token Claims registry Section 9.1 or 357 be a URI that contains a Collision Resistant Namespace. 359 4.3. Private Claim Names 361 A producer and consumer of a JWT may agree to any claim name that is 362 not a Reserved Name Section 4.1 or a Public Name Section 4.2. Unlike 363 Public Names, these private names are subject to collision and should 364 be used with caution. 366 5. JWT Header 368 The members of the JSON object represented by the JWT Header describe 369 the cryptographic operations applied to the JWT and optionally, 370 additional properties of the JWT. The member names within the JWT 371 Header are referred to as Header Parameter Names. These names MUST 372 be unique; JWTs with duplicate Header Parameter Names MUST be 373 rejected. The corresponding values are referred to as Header 374 Parameter Values. 376 Implementations MUST understand the entire contents of the header; 377 otherwise, the JWT MUST be rejected for processing. 379 JWS Header Parameters are defined by [JWS]. JWE Header Parameters 380 are defined by [JWE]. This specification further specifies the use 381 of the following header parameter in both the cases where the JWT is 382 a JWS and where it is a JWE. 384 5.1. "typ" (Type) Header Parameter 386 The "typ" (type) header parameter is used to declare the type of this 387 object. If present, it is RECOMMENDED that its value be either "JWT" 388 or "urn:ietf:params:oauth:token-type:jwt" to indicate that this 389 object is a JWT. The "typ" value is a case sensitive string. This 390 header parameter is OPTIONAL. 392 5.2. "cty" (Content Type) Header Parameter 394 The "cty" (content type) header parameter is used to declare 395 structural information about the JWT. Its value MUST be a string. 397 In the normal case where nested signing or encryption operations are 398 not employed, the use of this header parameter is NOT RECOMMENDED. 399 In the case that nested signing or encryption is employed, the use of 400 this header parameter is REQUIRED; in this case, the value MUST be 401 "JWT", to indicate that a nested JWT is carried in this JWT. 403 The values used for the "cty" header parameter come from the same 404 value space as the "typ" header parameter, with the same rules 405 applying. 407 6. Plaintext JWTs 409 To support use cases where the JWT content is secured by a means 410 other than a signature and/or encryption contained within the token 411 (such as a signature on a data structure containing the token), JWTs 412 MAY also be created without a signature or encryption. A plaintext 413 JWT is a JWS using the "none" JWS "alg" header parameter value 414 defined in JSON Web Algorithms (JWA) [JWA]; it is a JWS with an empty 415 JWS Signature value. 417 6.1. Example Plaintext JWT 419 The following example JWT Header declares that the encoded object is 420 a Plaintext JWT: 421 {"alg":"none"} 423 Base64url encoding the bytes of the UTF-8 representation of the JWT 424 Header yields this Encoded JWT Header: 425 eyJhbGciOiJub25lIn0 427 The following is an example of a JWT Claims Set: 428 {"iss":"joe", 429 "exp":1300819380, 430 "http://example.com/is_root":true} 432 Base64url encoding the bytes of the UTF-8 representation of the JSON 433 Claims Set yields this Encoded JWS Payload (with line breaks for 434 display purposes only): 435 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 436 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 437 The Encoded JWS Signature is the empty string. 439 Concatenating these parts in this order with period characters 440 between the parts yields this complete JWT (with line breaks for 441 display purposes only): 442 eyJhbGciOiJub25lIn0 443 . 444 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 445 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 446 . 448 7. Rules for Creating and Validating a JWT 450 To create a JWT, one MUST perform these steps. The order of the 451 steps is not significant in cases where there are no dependencies 452 between the inputs and outputs of the steps. 454 1. Create a JWT Claims Set containing the desired claims. Note that 455 white space is explicitly allowed in the representation and no 456 canonicalization is performed before encoding. 458 2. Let the Message be the bytes of the UTF-8 representation of the 459 JWT Claims Set. 461 3. Create a JWT Header containing the desired set of header 462 parameters. The JWT MUST conform to either the [JWS] or [JWE] 463 specifications. Note that white space is explicitly allowed in 464 the representation and no canonicalization is performed before 465 encoding. 467 4. Base64url encode the bytes of the UTF-8 representation of the JWT 468 Header. Let this be the Encoded JWT Header. 470 5. Depending upon whether the JWT is a JWS or JWE, there are two 471 cases: 473 * If the JWT is a JWS, create a JWS using the JWT Header as the 474 JWS Header and the Message as the JWS Payload; all steps 475 specified in [JWS] for creating a JWS MUST be followed. 477 * Else, if the JWT is a JWE, create a JWE using the JWT Header 478 as the JWE Header and the Message as the JWE Plaintext; all 479 steps specified in [JWE] for creating a JWE MUST be followed. 481 6. If a nested signing or encryption operation will be performed, 482 let the Message be the JWS or JWE, and return to Step 3, using a 483 "cty" (content type) value of "JWT" in the new JWT Header created 484 in that step. 486 7. Otherwise, let the resulting JWT be the JWS or JWE. 488 When validating a JWT the following steps MUST be taken. The order 489 of the steps is not significant in cases where there are no 490 dependencies between the inputs and outputs of the steps. If any of 491 the listed steps fails then the token MUST be rejected for 492 processing. 494 1. The JWT MUST contain at least one period character. 496 2. Let the Encoded JWT Header be the portion of the JWT before the 497 first period character. 499 3. The Encoded JWT Header MUST be successfully base64url decoded 500 following the restriction given in this specification that no 501 padding characters have been used. 503 4. The resulting JWT Header MUST be completely valid JSON syntax 504 conforming to RFC 4627 [RFC4627]. 506 5. The resulting JWT Header MUST be validated to only include 507 parameters and values whose syntax and semantics are both 508 understood and supported. 510 6. Determine whether the JWT is a JWS or a JWE by examining the 511 "alg" (algorithm) header value and optionally, the "enc" 512 (encryption method) header value, if present. 514 7. Depending upon whether the JWT is a JWS or JWE, there are two 515 cases: 517 * If the JWT is a JWS, all steps specified in [JWS] for 518 validating a JWS MUST be followed. Let the Message be the 519 result of base64url decoding the JWS Payload. 521 * Else, if the JWT is a JWE, all steps specified in [JWE] for 522 validating a JWE MUST be followed. Let the Message be the 523 JWE Plaintext. 525 8. If the JWT Header contains a "cty" (content type) value of 526 "JWT", then the Message contains a JWT that was the subject of 527 nested signing or encryption operations. In this case, return 528 to Step 1, using the Message as the JWT. 530 9. Otherwise, let the JWT Claims Set be the Message. 532 10. The JWT Claims Set MUST be completely valid JSON syntax 533 conforming to RFC 4627 [RFC4627]. 535 11. When used in a security-related context, the JWT Claims Set MUST 536 be validated to only include claims whose syntax and semantics 537 are both understood and supported. 539 Processing a JWT inevitably requires comparing known strings to 540 values in the token. For example, in checking what the algorithm is, 541 the Unicode string encoding "alg" will be checked against the member 542 names in the JWT Header to see if there is a matching header 543 parameter name. A similar process occurs when determining if the 544 value of the "alg" header parameter represents a supported algorithm. 546 Comparisons between JSON strings and other Unicode strings MUST be 547 performed as specified below: 549 1. Remove any JSON applied escaping to produce an array of Unicode 550 code points. 552 2. Unicode Normalization [USA15] MUST NOT be applied at any point to 553 either the JSON string or to the string it is to be compared 554 against. 556 3. Comparisons between the two strings MUST be performed as a 557 Unicode code point to code point equality comparison. 559 8. Cryptographic Algorithms 561 JWTs use JSON Web Signature (JWS) [JWS] and JSON Web Encryption (JWE) 562 [JWE] to sign and/or encrypt the contents of the JWT. 564 Of the JWS signing algorithms, only HMAC SHA-256 and "none" MUST be 565 implemented by conforming JWT implementations. It is RECOMMENDED 566 that implementations also support the RSA SHA-256 and ECDSA P-256 567 SHA-256 algorithms. Support for other algorithms and key sizes is 568 OPTIONAL. 570 If an implementation provides encryption capabilities, of the JWE 571 encryption algorithms, only RSA-PKCS1-1.5 with 2048 bit keys, AES- 572 128-KW, AES-256-KW, AES-128-CBC, and AES-256-CBC MUST be implemented 573 by conforming implementations. It is RECOMMENDED that 574 implementations also support ECDH-ES with 256 bit keys, AES-128-GCM, 575 and AES-256-GCM. Support for other algorithms and key sizes is 576 OPTIONAL. 578 9. IANA Considerations 580 9.1. JSON Web Token Claims Registry 582 This specification establishes the IANA JSON Web Token Claims 583 registry for reserved JWT Claim Names. The registry records the 584 reserved Claim Name and a reference to the specification that defines 585 it. This specification registers the Claim Names defined in 586 Section 4.1. 588 Values are registered with a Specification Required [RFC5226] after a 589 two week review period on the [TBD]@ietf.org mailing list, on the 590 advice of one or more Designated Experts. However, to allow for the 591 allocation of values prior to publication, the Designated Expert(s) 592 may approve registration once they are satisfied that such a 593 specification will be published. 595 Registration requests must be sent to the [TBD]@ietf.org mailing list 596 for review and comment, with an appropriate subject (e.g., "Request 597 for access token type: example"). [[ Note to RFC-EDITOR: The name of 598 the mailing list should be determined in consultation with the IESG 599 and IANA. Suggested name: claims-reg-review. ]] 601 Within the review period, the Designated Expert(s) will either 602 approve or deny the registration request, communicating this decision 603 to the review list and IANA. Denials should include an explanation 604 and, if applicable, suggestions as to how to make the request 605 successful. 607 IANA must only accept registry updates from the Designated Expert(s), 608 and should direct all requests for registration to the review mailing 609 list. 611 9.1.1. Registration Template 613 Claim Name: 614 The name requested (e.g., "example"). This name is case 615 sensitive. Names that match other registered names in a case 616 insensitive manner SHOULD NOT be accepted. 618 Change Controller: 619 For standards-track RFCs, state "IETF". For others, give the name 620 of the responsible party. Other details (e.g., postal address, 621 e-mail address, home page URI) may also be included. 623 Specification Document(s): 624 Reference to the document that specifies the parameter, preferably 625 including a URI that can be used to retrieve a copy of the 626 document. An indication of the relevant sections may also be 627 included, but is not required. 629 9.1.2. Initial Registry Contents 631 o Claim Name: "exp" 633 o Change Controller: IETF 635 o Specification Document(s): Section 4.1.1 of [[ this document ]] 637 o Claim Name: "nbf" 639 o Change Controller: IETF 641 o Specification Document(s): Section 4.1.2 of [[ this document ]] 643 o Claim Name: "iat" 645 o Change Controller: IETF 647 o Specification Document(s): Section 4.1.3 of [[ this document ]] 649 o Claim Name: "iss" 651 o Change Controller: IETF 653 o Specification Document(s): Section 4.1.4 of [[ this document ]] 655 o Claim Name: "aud" 657 o Change Controller: IETF 659 o Specification Document(s): Section 4.1.5 of [[ this document ]] 661 o Claim Name: "prn" 663 o Change Controller: IETF 665 o Specification Document(s): Section 4.1.6 of [[ this document ]] 667 o Claim Name: "jti" 669 o Change Controller: IETF 670 o Specification Document(s): Section 4.1.7 of [[ this document ]] 672 o Claim Name: "typ" 674 o Change Controller: IETF 676 o Specification Document(s): Section 4.1.8 of [[ this document ]] 678 9.2. Sub-Namespace Registration of urn:ietf:params:oauth:token-type:jwt 680 9.2.1. Registry Contents 682 This specification registers the value "token-type:jwt" in the IANA 683 urn:ietf:params:oauth registry established in An IETF URN Sub- 684 Namespace for OAuth [I-D.ietf-oauth-urn-sub-ns]. 686 o URN: urn:ietf:params:oauth:token-type:jwt 688 o Common Name: JSON Web Token (JWT) Token Type 690 o Change Controller: IETF 692 o Specification Document(s): [[this document]] 694 9.3. JSON Web Signature and Encryption Type Values Registration 696 9.3.1. Registry Contents 698 This specification registers the "JWT" type value in the IANA JSON 699 Web Signature and Encryption Type Values registry [JWS]: 701 o "typ" Header Parameter Value: "JWT" 703 o Abbreviation for MIME Type: application/jwt 705 o Change Controller: IETF 707 o Specification Document(s): Section 5.1 of [[ this document ]] 709 9.4. Media Type Registration 711 9.4.1. Registry Contents 713 This specification registers the "application/jwt" Media Type 714 [RFC2046] in the MIME Media Type registry [RFC4288] to indicate that 715 the content is a JWT. 717 o Type Name: application 719 o Subtype Name: jwt 721 o Required Parameters: n/a 723 o Optional Parameters: n/a 725 o Encoding considerations: JWT values are encoded as a series of 726 base64url encoded values (some of which may be the empty string) 727 separated by period ('.') characters 729 o Security Considerations: See the Security Considerations section 730 of this document 732 o Interoperability Considerations: n/a 734 o Published Specification: [[ this document ]] 736 o Applications that use this media type: OpenID Connect, Mozilla 737 Browser ID, Salesforce, Google, numerous others 739 o Additional Information: Magic number(s): n/a, File extension(s): 740 n/a, Macintosh file type code(s): n/a 742 o Person & email address to contact for further information: Michael 743 B. Jones, mbj@microsoft.com 745 o Intended Usage: COMMON 747 o Restrictions on Usage: none 749 o Author: Michael B. Jones, mbj@microsoft.com 751 o Change Controller: IETF 753 10. Security Considerations 755 All of the security issues faced by any cryptographic application 756 must be faced by a JWT/JWS/JWE/JWK agent. Among these issues are 757 protecting the user's private key, preventing various attacks, and 758 helping the user avoid mistakes such as inadvertently encrypting a 759 message for the wrong recipient. The entire list of security 760 considerations is beyond the scope of this document, but some 761 significant concerns are listed here. 763 All the security considerations in the JWS specification also apply 764 to JWT, as do the JWE security considerations when encryption is 765 employed. In particular, the JWS JSON Security Considerations and 766 Unicode Comparison Security Considerations apply equally to the JWT 767 Claims Set in the same manner that they do to the JWS Header. 769 11. Open Issues 771 [[ to be removed by the RFC editor before publication as an RFC ]] 773 The following items remain to be considered or done in this draft: 775 o Track changes to the underlying JOSE specifications. 777 12. References 779 12.1. Normative References 781 [I-D.ietf-oauth-urn-sub-ns] 782 Campbell, B. and H. Tschofenig, "An IETF URN Sub-Namespace 783 for OAuth", draft-ietf-oauth-urn-sub-ns-05 (work in 784 progress), June 2012. 786 [JWA] Jones, M., "JSON Web Algorithms (JWA)", July 2012. 788 [JWE] Jones, M., Rescorla, E., and J. Hildebrand, "JSON Web 789 Encryption (JWE)", July 2012. 791 [JWS] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 792 Signature (JWS)", July 2012. 794 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 795 Extensions (MIME) Part Two: Media Types", RFC 2046, 796 November 1996. 798 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 799 Requirement Levels", BCP 14, RFC 2119, March 1997. 801 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the 802 Internet: Timestamps", RFC 3339, July 2002. 804 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 805 10646", STD 63, RFC 3629, November 2003. 807 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 808 Resource Identifier (URI): Generic Syntax", STD 66, 809 RFC 3986, January 2005. 811 [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and 812 Registration Procedures", BCP 13, RFC 4288, December 2005. 814 [RFC4627] Crockford, D., "The application/json Media Type for 815 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 817 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 818 Encodings", RFC 4648, October 2006. 820 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 821 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 822 May 2008. 824 [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode 825 Normalization Forms", Unicode Standard Annex 15, 09 2009. 827 12.2. Informative References 829 [CanvasApp] 830 Facebook, "Canvas Applications", 2010. 832 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 833 September 2010. 835 [MagicSignatures] 836 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 837 Signatures", January 2011. 839 [OASIS.saml-core-2.0-os] 840 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 841 "Assertions and Protocol for the OASIS Security Assertion 842 Markup Language (SAML) V2.0", OASIS Standard saml-core- 843 2.0-os, March 2005. 845 [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup 846 Language) XML-Signature Syntax and Processing", RFC 3275, 847 March 2002. 849 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 850 Unique IDentifier (UUID) URN Namespace", RFC 4122, 851 July 2005. 853 [SWT] Hardt, D. and Y. Goland, "Simple Web Token (SWT)", 854 Version 0.9.5.1, November 2009. 856 [W3C.CR-xml11-20021015] 857 Cowan, J., "Extensible Markup Language (XML) 1.1", W3C 858 CR CR-xml11-20021015, October 2002. 860 Appendix A. Example Encrypted JWT 862 This example encrypts the same claims as used in Section 3.1 to the 863 recipient using RSAES-PKCS1-V1_5 and AES CBC. AES CBC does not have 864 an integrated integrity check, so a separate integrity check 865 calculation is performed using HMAC SHA-256, with separate encryption 866 and integrity keys being derived from a master key using the Concat 867 KDF with the SHA-256 digest function. 869 The following example JWE Header (with line breaks for display 870 purposes only) declares that: 872 o the Content Master Key is encrypted to the recipient using the 873 RSAES-PKCS1-V1_5 algorithm to produce the JWE Encrypted Key, 875 o the Plaintext is encrypted using the AES CBC algorithm with a 128 876 bit key to produce the Ciphertext, 878 o the JWE Integrity Value safeguarding the integrity of the 879 Ciphertext and the parameters used to create it was computed with 880 the HMAC SHA-256 algorithm, and 882 o the 128 bit Initialization Vector (IV) with the base64url encoding 883 "AxY8DCtDaGlsbGljb3RoZQ" was used. 885 {"alg":"RSA1_5","enc":"A128CBC","int":"HS256","iv":"AxY8DCtDaGls 886 bGljb3RoZQ"} 888 Other than using the bytes of the UTF-8 representation of the JSON 889 Claims Set from Section 3.1 as the plaintext value, the computation 890 of this JWT is identical to the computation of the JWE in Appendix 891 A.2 of [JWE], including the keys used. 893 The final result in this example (with line breaks for display 894 purposes only) is: 896 eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDIiwiaW50IjoiSFMyNTYiLCJp 897 diI6IkF4WThEQ3REYUdsc2JHbGpiM1JvWlEifQ. 898 VjBkk22MjrFUMUl8ItbS8CjKjku4HQz4RiHD0eVG4dir-7XbDkPr1q6YtnN1X-av 899 1EKmEnsrbhSxTvqtY4oEbWKLoEQ7zVm_0BW-rnwxdwrj4QJrhXGnqIL6bC4waZVJ 900 qYhVQIahVWSQsCRcS1oYXA-2GhT6rk91y118DUkhGDsvdK2_hQsNGE6BQVN1i-Xw 901 Uoz5sM6_0PRQ1FsYnJATMjVZfa4otHiooZ_KcOlSWIDxhMDqfPOu60--1ej0eZBy 902 O7Ar_IZvzPAWqJ9agGFQIVGRZviXhN0WeErq9fVTcgeSUPsmurRSTYhTrNFLojqP 903 qqk8pI61kn8GmZxA80-RUQ. 904 7kLQQst655TUxmDzysjRLXnD-nfLK5EQK7ODAUkwxc0aRb9NOgu0EMJgOR6Vz8eN 905 baf8six_OP6BRyUTYrCkH73-inD6Rc-7vc9eC5fcfSM. 906 COyXNSm-CdfAL22WIKcoyCgQwb85aLW3ttDkzNj_1Wg 908 Appendix B. Relationship of JWTs to SAML Tokens 910 SAML 2.0 [OASIS.saml-core-2.0-os] provides a standard for creating 911 tokens with much greater expressivity and more security options than 912 supported by JWTs. However, the cost of this flexibility and 913 expressiveness is both size and complexity. In addition, SAML's use 914 of XML [W3C.CR-xml11-20021015] and XML DSIG [RFC3275] only 915 contributes to the size of SAML tokens. 917 JWTs are intended to provide a simple token format that is small 918 enough to fit into HTTP headers and query arguments in URIs. It does 919 this by supporting a much simpler token model than SAML and using the 920 JSON [RFC4627] object encoding syntax. It also supports securing 921 tokens using Message Authentication Codes (MACs) and digital 922 signatures using a smaller (and less flexible) format than XML DSIG. 924 Therefore, while JWTs can do some of the things SAML tokens do, JWTs 925 are not intended as a full replacement for SAML tokens, but rather as 926 a compromise token format to be used when space is at a premium. 928 Appendix C. Relationship of JWTs to Simple Web Tokens (SWTs) 930 Both JWTs and Simple Web Tokens SWT [SWT], at their core, enable sets 931 of claims to be communicated between applications. For SWTs, both 932 the claim names and claim values are strings. For JWTs, while claim 933 names are strings, claim values can be any JSON type. Both token 934 types offer cryptographic protection of their content: SWTs with HMAC 935 SHA-256 and JWTs with a choice of algorithms, including HMAC SHA-256, 936 RSA SHA-256, and ECDSA P-256 SHA-256. 938 Appendix D. Acknowledgements 940 The authors acknowledge that the design of JWTs was intentionally 941 influenced by the design and simplicity of Simple Web Tokens [SWT] 942 and ideas for JSON tokens that Dick Hardt discussed within the OpenID 943 community. 945 Solutions for signing JSON content were previously explored by Magic 946 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 947 Applications [CanvasApp], all of which influenced this draft. Dirk 948 Balfanz, Yaron Y. Goland, John Panzer, and Paul Tarjan all made 949 significant contributions to the design of this specification. 951 Appendix E. Document History 953 [[ to be removed by the RFC editor before publication as an RFC ]] 955 -02 957 o Added an example of an encrypted JWT. 959 o Added this language to Registration Templates: "This name is case 960 sensitive. Names that match other registered names in a case 961 insensitive manner SHOULD NOT be accepted." 963 o Applied editorial suggestions. 965 -01 967 o Added the "cty" (content type) header parameter for declaring type 968 information about the secured content, as opposed to the "typ" 969 (type) header parameter, which declares type information about 970 this object. This significantly simplified nested JWTs. 972 o Moved description of how to determine whether a header is for a 973 JWS or a JWE from the JWT spec to the JWE spec. 975 o Changed registration requirements from RFC Required to 976 Specification Required with Expert Review. 978 o Added Registration Template sections for defined registries. 980 o Added Registry Contents sections to populate registry values. 982 o Added "Collision Resistant Namespace" to the terminology section. 984 o Numerous editorial improvements. 986 -00 988 o Created the initial IETF draft based upon 989 draft-jones-json-web-token-10 with no normative changes. 991 Authors' Addresses 993 Michael B. Jones 994 Microsoft 996 Email: mbj@microsoft.com 997 URI: http://self-issued.info/ 999 John Bradley 1000 Ping Identity 1002 Email: ve7jtb@ve7jtb.com 1004 Nat Sakimura 1005 Nomura Research Institute 1007 Email: n-sakimura@nri.co.jp