idnits 2.17.1 draft-jones-json-web-token-08.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 date (March 12, 2012) is 4429 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) == Unused Reference: 'RFC2045' is defined on line 765, but no explicit reference was found in the text -- 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 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: 2 errors (**), 0 flaws (~~), 2 warnings (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group M. Jones 3 Internet-Draft Microsoft 4 Intended status: Standards Track D. Balfanz 5 Expires: September 13, 2012 Google 6 J. Bradley 7 independent 8 Y. Goland 9 Microsoft 10 J. Panzer 11 Google 12 N. Sakimura 13 Nomura Research Institute 14 P. Tarjan 15 Facebook 16 March 12, 2012 18 JSON Web Token (JWT) 19 draft-jones-json-web-token-08 21 Abstract 23 JSON Web Token (JWT) is a means of representing claims to be 24 transferred between two parties. The claims in a JWT are encoded as 25 a JSON object that is digitally signed or HMACed using JSON Web 26 Signature (JWS) and/or encrypted using JSON Web Encryption (JWE). 28 The suggested pronunciation of JWT is the same as the English word 29 "jot". 31 Requirements Language 33 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 34 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 35 document are to be interpreted as described in RFC 2119 [RFC2119]. 37 Status of this Memo 39 This Internet-Draft is submitted in full conformance with the 40 provisions of BCP 78 and BCP 79. 42 Internet-Drafts are working documents of the Internet Engineering 43 Task Force (IETF). Note that other groups may also distribute 44 working documents as Internet-Drafts. The list of current Internet- 45 Drafts is at http://datatracker.ietf.org/drafts/current/. 47 Internet-Drafts are draft documents valid for a maximum of six months 48 and may be updated, replaced, or obsoleted by other documents at any 49 time. It is inappropriate to use Internet-Drafts as reference 50 material or to cite them other than as "work in progress." 52 This Internet-Draft will expire on September 13, 2012. 54 Copyright Notice 56 Copyright (c) 2012 IETF Trust and the persons identified as the 57 document authors. All rights reserved. 59 This document is subject to BCP 78 and the IETF Trust's Legal 60 Provisions Relating to IETF Documents 61 (http://trustee.ietf.org/license-info) in effect on the date of 62 publication of this document. Please review these documents 63 carefully, as they describe your rights and restrictions with respect 64 to this document. Code Components extracted from this document must 65 include Simplified BSD License text as described in Section 4.e of 66 the Trust Legal Provisions and are provided without warranty as 67 described in the Simplified BSD License. 69 Table of Contents 71 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 72 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 73 3. JSON Web Token (JWT) Overview . . . . . . . . . . . . . . . . 5 74 3.1. Example JWT . . . . . . . . . . . . . . . . . . . . . . . 5 75 4. JWT Claims . . . . . . . . . . . . . . . . . . . . . . . . . . 6 76 4.1. Reserved Claim Names . . . . . . . . . . . . . . . . . . . 7 77 4.2. Public Claim Names . . . . . . . . . . . . . . . . . . . . 9 78 4.3. Private Claim Names . . . . . . . . . . . . . . . . . . . 9 79 5. JWT Header . . . . . . . . . . . . . . . . . . . . . . . . . . 10 80 6. Plaintext JWTs . . . . . . . . . . . . . . . . . . . . . . . . 11 81 6.1. Example Plaintext JWT . . . . . . . . . . . . . . . . . . 11 82 7. Rules for Creating and Validating a JWT . . . . . . . . . . . 12 83 8. Cryptographic Algorithms . . . . . . . . . . . . . . . . . . . 14 84 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 85 9.1. JSON Web Token Claims Registry . . . . . . . . . . . . . . 15 86 9.2. application/jwt MIME Media Type Registration . . . . . . . 15 87 10. Security Considerations . . . . . . . . . . . . . . . . . . . 16 88 10.1. Unicode Comparison Security Issues . . . . . . . . . . . . 17 89 11. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 17 90 12. References . . . . . . . . . . . . . . . . . . . . . . . . . . 18 91 12.1. Normative References . . . . . . . . . . . . . . . . . . . 18 92 12.2. Informative References . . . . . . . . . . . . . . . . . . 19 93 Appendix A. Relationship of JWTs to SAML Tokens . . . . . . . . . 20 94 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) . . 20 95 Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 20 96 Appendix D. Document History . . . . . . . . . . . . . . . . . . 21 97 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 23 99 1. Introduction 101 JSON Web Token (JWT) is a compact token format intended for space 102 constrained environments such as HTTP Authorization headers and URI 103 query parameters. JWTs encode claims to be transmitted as a JSON 104 object (as defined in RFC 4627 [RFC4627]) that is base64url encoded 105 and digitally signed or HMACed and/or encrypted. Signing and HMACing 106 is performed using JSON Web Signature (JWS) [JWS]. Encryption is 107 performed using JSON Web Encryption (JWE) [JWE]. 109 The suggested pronunciation of JWT is the same as the English word 110 "jot". 112 2. Terminology 114 JSON Web Token (JWT) A string consisting of multiple parts, the 115 first being the Encoded JWT Header, plus additional parts 116 depending upon the contents of the header, with the parts being 117 separated by period ('.') characters, and each part containing 118 base64url encoded content. 120 JWT Header A string representing a JSON object that describes the 121 cryptographic operations applied to the JWT. When the JWT is 122 digitally signed or HMACed, the JWT Header is a JWS Header. When 123 the JWT is encrypted, the JWT Header is a JWE Header. 125 Header Parameter Names The names of the members within the JWT 126 Header. 128 Header Parameter Values The values of the members within the JWT 129 Header. 131 JWT Claims Set A string representing a JSON object that contains the 132 claims conveyed by the JWT. When the JWT is digitally signed or 133 HMACed, the bytes of the UTF-8 representation of the JWT Claims 134 Set are base64url encoded to create the Encoded JWS Payload. When 135 the JWT is encrypted, the bytes of the UTF-8 representation of the 136 JWT Claims Set are used as the JWE Plaintext. 138 Claim Names The names of the members of the JSON object represented 139 by the JWT Claims Set. 141 Claim Values The values of the members of the JSON object 142 represented by the JWT Claims Set. 144 Encoded JWT Header Base64url encoding of the bytes of the UTF-8 RFC 145 3629 [RFC3629] representation of the JWT Header. 147 Base64url Encoding For the purposes of this specification, this term 148 always refers to the URL- and filename-safe Base64 encoding 149 described in RFC 4648 [RFC4648], Section 5, with the (non URL- 150 safe) '=' padding characters omitted, as permitted by Section 3.2. 151 (See Appendix C of [JWS] for notes on implementing base64url 152 encoding without padding.) 154 3. JSON Web Token (JWT) Overview 156 JWTs represent a set of claims as a JSON object that is base64url 157 encoded and digitally signed or HMACed and/or encrypted. The JWT 158 Claims Set represents this JSON object. As per RFC 4627 [RFC4627] 159 Section 2.2, the JSON object consists of zero or more name/value 160 pairs (or members), where the names are strings and the values are 161 arbitrary JSON values. These members are the claims represented by 162 the JWT. 164 The member names within the JWT Claims Set are referred to as Claim 165 Names. The corresponding values are referred to as Claim Values. 167 The bytes of the UTF-8 representation of the JWT Claims Set are 168 digitally signed or HMACed in the manner described in JSON Web 169 Signature (JWS) [JWS] and/or encrypted in the manner described in 170 JSON Web Encryption (JWE) [JWE]. 172 The contents of the JWT Header describe the cryptographic operations 173 applied to the JWT Claims Set. If the JWT Header is a JWS Header, the 174 claims are digitally signed or HMACed. If the JWT Header is a JWE 175 Header, the claims are encrypted. 177 A JWT is represented as a JWS or JWE. The number of parts is 178 dependent upon the representation of the resulting JWS or JWE. 180 3.1. Example JWT 182 The following example JWT Header declares that the encoded object is 183 a JSON Web Token (JWT) and the JWT is HMACed using the HMAC SHA-256 184 algorithm: 185 {"typ":"JWT", 186 "alg":"HS256"} 188 Base64url encoding the bytes of the UTF-8 representation of the JWT 189 Header yields this Encoded JWS Header value, which is used as the 190 Encoded JWT Header: 192 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 194 The following is an example of a JWT Claims Set: 195 {"iss":"joe", 196 "exp":1300819380, 197 "http://example.com/is_root":true} 199 Base64url encoding the bytes of the UTF-8 representation of the JSON 200 Claims Set yields this Encoded JWS Payload (with line breaks for 201 display purposes only): 202 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly 203 9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 205 Signing the Encoded JWS Header and Encoded JWS Payload with the HMAC 206 SHA-256 algorithm and base64url encoding the signature in the manner 207 specified in [JWS], yields this Encoded JWS Signature: 208 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 210 Concatenating these parts in this order with period characters 211 between the parts yields this complete JWT (with line breaks for 212 display purposes only): 213 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 214 . 215 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 216 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 217 . 218 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 220 This computation is illustrated in more detail in [JWS], Appendix 221 A.1. 223 4. JWT Claims 225 The JWT Claims Set represents a JSON object whose members are the 226 claims conveyed by the JWT. The Claim Names within this object MUST 227 be unique. Note however, that the set of claims that a JWT must 228 contain to be considered valid is context-dependent and is outside 229 the scope of this specification. When used in a security-related 230 context, implementations MUST understand and support all of the 231 claims present; otherwise, the JWT MUST be rejected for processing. 233 There are three classes of JWT Claim Names: Reserved Claim Names, 234 Public Claim Names, and Private Claim Names. 236 4.1. Reserved Claim Names 238 The following claim names are reserved. None of the claims defined 239 in the table below are intended to be mandatory, but rather, provide 240 a starting point for a set of useful, interoperable claims. All the 241 names are short because a core goal of JWTs is for the tokens to be 242 compact. 244 +-------+--------+-------------+------------------------------------+ 245 | Claim | JSON | Claim | Claim Semantics | 246 | Name | Value | Syntax | | 247 | | Type | | | 248 +-------+--------+-------------+------------------------------------+ 249 | exp | number | IntDate | The "exp" (expiration time) claim | 250 | | | | identifies the expiration time on | 251 | | | | or after which the token MUST NOT | 252 | | | | be accepted for processing. The | 253 | | | | processing of the "exp" claim | 254 | | | | requires that the current | 255 | | | | date/time MUST be before the | 256 | | | | expiration date/time listed in the | 257 | | | | "exp" claim. Implementers MAY | 258 | | | | provide for some small leeway, | 259 | | | | usually no more than a few | 260 | | | | minutes, to account for clock | 261 | | | | skew. This claim is OPTIONAL. | 262 | nbf | number | IntDate | The "nbf" (not before) claim | 263 | | | | identifies the time before which | 264 | | | | the token MUST NOT be accepted for | 265 | | | | processing. The processing of the | 266 | | | | "nbf" claim requires that the | 267 | | | | current date/time MUST be after or | 268 | | | | equal to the not-before date/time | 269 | | | | listed in the "nbf" claim. | 270 | | | | Implementers MAY provide for some | 271 | | | | small leeway, usually no more than | 272 | | | | a few minutes, to account for | 273 | | | | clock skew. This claim is | 274 | | | | OPTIONAL. | 275 | iat | number | IntDate | The "iat" (issued at) claim | 276 | | | | identifies the time at which the | 277 | | | | JWT was issued. This claim can be | 278 | | | | used to determine the age of the | 279 | | | | token. This claim is OPTIONAL. | 280 | iss | string | StringOrURI | The "iss" (issuer) claim | 281 | | | | identifies the principal that | 282 | | | | issued the JWT. The processing of | 283 | | | | this claim is generally | 284 | | | | application specific. The "iss" | 285 | | | | value is case sensitive. This | 286 | | | | claim is OPTIONAL. | 287 | aud | string | StringOrURI | The "aud" (audience) claim | 288 | | | | identifies the audience that the | 289 | | | | JWT is intended for. The | 290 | | | | principal intended to process the | 291 | | | | JWT MUST be identified with the | 292 | | | | value of the audience claim. If | 293 | | | | the principal processing the claim | 294 | | | | does not identify itself with the | 295 | | | | identifier in the "aud" claim | 296 | | | | value then the JWT MUST be | 297 | | | | rejected. The interpretation of | 298 | | | | the audience value is generally | 299 | | | | application specific. The "aud" | 300 | | | | value is case sensitive. This | 301 | | | | claim is OPTIONAL. | 302 | prn | string | StringOrURI | The "prn" (principal) claim | 303 | | | | identifies the subject of the JWT. | 304 | | | | The processing of this claim is | 305 | | | | generally application specific. | 306 | | | | The "prn" value is case sensitive. | 307 | | | | This claim is OPTIONAL. | 308 | jti | string | String | The "jti" (JWT ID) claim provides | 309 | | | | a unique identifier for the JWT. | 310 | | | | The identifier value MUST be | 311 | | | | assigned in a manner that ensures | 312 | | | | that there is a negligible | 313 | | | | probability that the same value | 314 | | | | will be accidentally assigned to a | 315 | | | | different data object. The "jti" | 316 | | | | claim can be used to prevent the | 317 | | | | JWT from being replayed. The | 318 | | | | "jti" value is case sensitive. | 319 | | | | This claim is OPTIONAL. | 320 | typ | string | String | The "typ" (type) claim is used to | 321 | | | | declare a type for the contents of | 322 | | | | this JWT Claims Set. The "typ" | 323 | | | | value is case sensitive. This | 324 | | | | claim is OPTIONAL. | 325 +-------+--------+-------------+------------------------------------+ 327 Table 1: Reserved Claim Definitions 329 Additional reserved claim names MAY be defined via the IANA JSON Web 330 Token Claims registry, as per Section 9. The syntax values used 331 above are defined as follows: 333 +-------------+-----------------------------------------------------+ 334 | Syntax Name | Syntax Definition | 335 +-------------+-----------------------------------------------------+ 336 | IntDate | The number of seconds from 1970-01-01T0:0:0Z as | 337 | | measured in UTC until the desired date/time. See | 338 | | RFC 3339 [RFC3339] for details regarding date/times | 339 | | in general and UTC in particular. | 340 | String | Any string value MAY be used. | 341 | StringOrURI | Any string value MAY be used but a value containing | 342 | | a ":" character MUST be a URI as defined in RFC | 343 | | 3986 [RFC3986]. | 344 +-------------+-----------------------------------------------------+ 346 Table 2: Claim Syntax Definitions 348 4.2. Public Claim Names 350 Claim names can be defined at will by those using JWTs. However, in 351 order to prevent collisions, any new claim name SHOULD either be 352 defined in the IANA JSON Web Token Claims registry or be defined as a 353 URI that contains a collision resistant namespace. Examples of 354 collision resistant namespaces include: 356 o Domain Names, 358 o Object Identifiers (OIDs) as defined in the ITU-T X.660 and X.670 359 Recommendation series, or 361 o Universally Unique IDentifier (UUID) as defined in RFC 4122 362 [RFC4122]. 364 In each case, the definer of the name or value needs to take 365 reasonable precautions to make sure they are in control of the part 366 of the namespace they use to define the claim name. 368 4.3. Private Claim Names 370 A producer and consumer of a JWT may agree to any claim name that is 371 not a Reserved Name Section 4.1 or a Public Name Section 4.2. Unlike 372 Public Names, these private names are subject to collision and should 373 be used with caution. 375 5. JWT Header 377 The members of the JSON object represented by the JWT Header describe 378 the cryptographic operations applied to the JWT and optionally, 379 additional properties of the JWT. The member names within the JWT 380 Header are referred to as Header Parameter Names. These names MUST 381 be unique. The corresponding values are referred to as Header 382 Parameter Values. 384 Implementations MUST understand the entire contents of the header; 385 otherwise, the JWT MUST be rejected for processing. 387 There are two ways of distinguishing whether the JWT is a JWS or JWE. 388 The first is by examining the "alg" (algorithm) header value. If the 389 value represents a signature algorithm, the JWT is a JWS; if it 390 represents an encryption algorithm, the JWT is a JWE. A second 391 method is determining whether an "enc" (encryption method) member 392 exists. If the "enc" member exists, the JWT is a JWE; otherwise, the 393 JWT is a JWS. Both methods will yield the same result. 395 JWS Header Parameters are defined by [JWS]. JWE Header Parameters 396 are defined by [JWE]. This specification further specifies the use 397 of the following header parameters in both the cases where the JWT is 398 a JWS and where it is a JWE. 400 +----------+--------+-----------+-----------------------------------+ 401 | Header | JSON | Header | Header Parameter Semantics | 402 | Paramete | Value | Parameter | | 403 | rName | Type | Syntax | | 404 +----------+--------+-----------+-----------------------------------+ 405 | typ | string | String | The "typ" (type) header parameter | 406 | | | | is used to declare structural | 407 | | | | information about the JWT. In | 408 | | | | the normal case where nested | 409 | | | | signing or encryption operations | 410 | | | | are not employed, the use of this | 411 | | | | header parameter is OPTIONAL, and | 412 | | | | if present, it is RECOMMENDED | 413 | | | | that its value be either "JWT" or | 414 | | | | "http://openid.net/specs/jwt/1.0" | 415 | | | | .In the case that nested signing | 416 | | | | or encryption steps are employed | 417 | | | | ,the use of this header parameter | 418 | | | | is REQUIRED; in this case, the | 419 | | | | value MUST either be "JWS", to | 420 | | | | indicate that a nested signed JW | 421 | | | | Tis carried in this JWT or "JWE", | 422 | | | | to indicate that a nested | 423 | | | | encrypted JWT is carried in this | 424 | | | | JWT. | 425 +----------+--------+-----------+-----------------------------------+ 427 Table 3: Reserved Header Parameter Usage 429 6. Plaintext JWTs 431 To support use cases where the JWT content is secured by a means 432 other than a signature and/or encryption contained within the token 433 (such as a signature on a data structure containing the token), JWTs 434 MAY also be created without a signature or encryption. A plaintext 435 JWT is a JWS using the "none" JWS "alg" header parameter value 436 defined in JSON Web Algorithms (JWA) [JWA]; it is a signed JWT with 437 an empty JWS Signature value. 439 6.1. Example Plaintext JWT 441 The following example JWT Header declares that the encoded object is 442 a Plaintext JWT: 443 {"alg":"none"} 445 Base64url encoding the bytes of the UTF-8 representation of the JWT 446 Header yields this Encoded JWT Header: 448 eyJhbGciOiJub25lIn0 450 The following is an example of a JWT Claims Set: 451 {"iss":"joe", 452 "exp":1300819380, 453 "http://example.com/is_root":true} 455 Base64url encoding the bytes of the UTF-8 representation of the JSON 456 Claims Set yields this Encoded JWS Payload (with line breaks for 457 display purposes only): 458 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 459 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 461 The Encoded JWS Signature is the empty string. 463 Concatenating these parts in this order with period characters 464 between the parts yields this complete JWT (with line breaks for 465 display purposes only): 466 eyJhbGciOiJub25lIn0 467 . 468 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 469 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 470 . 472 7. Rules for Creating and Validating a JWT 474 To create a JWT, one MUST perform these steps. The order of the 475 steps is not significant in cases where there are no dependencies 476 between the inputs and outputs of the steps. 478 1. Create a JWT Claims Set containing the desired claims. Note that 479 white space is explicitly allowed in the representation and no 480 canonicalization is performed before encoding. 482 2. Let the Message be the bytes of the UTF-8 representation of the 483 JWT Claims Set. 485 3. Create a JWT Header containing the desired set of header 486 parameters. The JWT MUST conform to either the [JWS] or [JWE] 487 specifications. Note that white space is explicitly allowed in 488 the representation and no canonicalization is performed before 489 encoding. 491 4. Base64url encode the bytes of the UTF-8 representation of the JWT 492 Header. Let this be the Encoded JWT Header. 494 5. Depending upon whether the JWT is to be signed or encrypted, 495 there are two cases: 497 * If the JWT is to be signed, create a JWS using the JWT Header 498 as the JWS Header and the Message as the JWS Payload; all 499 steps specified in [JWS] for creating a JWS MUST be followed. 501 * Else, if the JWT is to be encrypted, create a JWE using the 502 JWT Header as the JWE Header and the Message as the JWE 503 Plaintext; all steps specified in [JWE] for creating a JWE 504 MUST be followed. 506 6. If a nested signing or encryption operation will be performed, 507 let the Message be the JWS or JWE, and return to Step 3, using a 508 "typ" value of either "JWS" or "JWE" respectively in the new JWT 509 Header created in that step. 511 7. Otherwise, let the resulting JWT be the JWS or JWE. 513 When validating a JWT the following steps MUST be taken. The order 514 of the steps is not significant in cases where there are no 515 dependencies between the inputs and outputs of the steps. If any of 516 the listed steps fails then the token MUST be rejected for 517 processing. 519 1. The JWT MUST contain at least one period character. 521 2. Let the Encoded JWT Header be the portion of the JWT before the 522 first period character. 524 3. The Encoded JWT Header MUST be successfully base64url decoded 525 following the restriction given in this specification that no 526 padding characters have been used. 528 4. The JWT Header MUST be completely valid JSON syntax conforming 529 to RFC 4627 [RFC4627]. 531 5. The JWT Header MUST be validated to only include parameters and 532 values whose syntax and semantics are both understood and 533 supported. 535 6. Determine whether the JWT is a JWS or a JWE by examining the 536 "alg" (algorithm) header value and optionally, the "enc" 537 (encryption method) header value, if present. 539 7. Depending upon whether the JWT is a JWS or JWE, there are two 540 cases: 542 * If the JWT is a JWS, all steps specified in [JWS] for 543 validating a JWS MUST be followed. Let the Message be the 544 result of base64url decoding the JWS Payload. 546 * Else, if the JWT is a JWE, all steps specified in [JWE] for 547 validating a JWE MUST be followed. Let the Message be the 548 JWE Plaintext. 550 8. If the JWT Header contains a "typ" value of either "JWS" or 551 "JWE", then the Message contains a JWT that was the subject of 552 nested signing or encryption operations, respectively. In this 553 case, return to Step 1, using the Message as the JWT. 555 9. Otherwise, let the JWT Claims Set be the Message. 557 10. The JWT Claims Set MUST be completely valid JSON syntax 558 conforming to RFC 4627 [RFC4627]. 560 11. When used in a security-related context, the JWT Claims Set MUST 561 be validated to only include claims whose syntax and semantics 562 are both understood and supported. 564 Processing a JWT inevitably requires comparing known strings to 565 values in the token. For example, in checking what the algorithm is, 566 the Unicode string encoding "alg" will be checked against the member 567 names in the JWT Header to see if there is a matching header 568 parameter name. A similar process occurs when determining if the 569 value of the "alg" header parameter represents a supported algorithm. 571 Comparisons between JSON strings and other Unicode strings MUST be 572 performed as specified below: 574 1. Remove any JSON applied escaping to produce an array of Unicode 575 code points. 577 2. Unicode Normalization [USA15] MUST NOT be applied at any point to 578 either the JSON string or to the string it is to be compared 579 against. 581 3. Comparisons between the two strings MUST be performed as a 582 Unicode code point to code point equality comparison. 584 8. Cryptographic Algorithms 586 JWTs use JSON Web Signature (JWS) [JWS] and JSON Web Encryption (JWE) 587 [JWE] to sign and/or encrypt the contents of the JWT. 589 Of the JWS signing algorithms, only HMAC SHA-256 and "none" MUST be 590 implemented by conforming JWT implementations. It is RECOMMENDED 591 that implementations also support the RSA SHA-256 and ECDSA P-256 592 SHA-256 algorithms. Support for other algorithms and key sizes is 593 OPTIONAL. 595 If an implementation provides encryption capabilities, of the JWE 596 encryption algorithms, only RSA-PKCS1-1.5 with 2048 bit keys, AES- 597 128-CBC, and AES-256-CBC MUST be implemented by conforming 598 implementations. It is RECOMMENDED that implementations also support 599 ECDH-ES with 256 bit keys, AES-128-GCM, and AES-256-GCM. Support for 600 other algorithms and key sizes is OPTIONAL. 602 9. IANA Considerations 604 9.1. JSON Web Token Claims Registry 606 This specification calls for: 608 o A new IANA registry entitled "JSON Web Token Claims" for reserved 609 claim names is defined in Section 4.1. Inclusion in the registry 610 is RFC Required in the RFC 5226 [RFC5226] sense for reserved JWT 611 claim names that are intended to be interoperable between 612 implementations. The registry will just record the reserved claim 613 name and a pointer to the RFC that defines it. This specification 614 defines inclusion of the claim names defined in Table 1. 616 9.2. application/jwt MIME Media Type Registration 618 This specification registers the "application/jwt" MIME Media Type. 620 Type name: 621 application 623 Subtype name: 624 jwt 626 Required parameters: 627 n/a 629 Optional parameters: 630 n/a 632 Encoding considerations: 633 n/a 635 Security considerations: 636 See the Security Considerations section of this document 638 Interoperability considerations: 639 n/a 641 Published specification: 642 [[ this document ]] 644 Applications that use this media type: 645 OpenID Connect, Mozilla Browser ID, Salesforce, Google, numerous 646 others 648 Additional information: 649 Magic number(s): n/a 650 File extension(s): n/a 651 Macintosh file type code(s): n/a 653 Person & email address to contact for further information: 654 Michael B. Jones 655 mbj@microsoft.com 657 Intended usage: 658 COMMON 660 Restrictions on usage: 661 none 663 Author: 664 Michael B. Jones 665 mbj@microsoft.com 667 Change controller: 668 Michael B. Jones 669 mbj@microsoft.com 671 10. Security Considerations 673 TBD: Lots of work to do here. We need to remember to look into any 674 issues relating to security and JSON parsing. One wonders just how 675 secure most JSON parsing libraries are. Were they ever hardened for 676 security scenarios? If not, what kind of holes does that open up? 677 Also, we need to walk through the JSON standard and see what kind of 678 issues we have especially around comparison of names. For instance, 679 comparisons of claim names and other parameters must occur after they 680 are unescaped. Need to also put in text about: Importance of keeping 681 secrets secret. Rotating keys. Strengths and weaknesses of the 682 different algorithms. 684 TBD: Need to put in text about why strict JSON validation is 685 necessary. Basically, that if malformed JSON is received then the 686 intent of the sender is impossible to reliably discern. One example 687 of malformed JSON that MUST be rejected is an object in which the 688 same member name occurs multiple times. While in non-security 689 contexts it's o.k. to be generous in what one accepts, in security 690 contexts this can lead to serious security holes. For example, 691 malformed JSON might indicate that someone has managed to find a 692 security hole in the issuer's code and is leveraging it to get the 693 issuer to issue "bad" tokens whose content the attacker can control. 695 TBD: Write about the need to secure the token content if a signature 696 is not contained in the JWT itself. 698 10.1. Unicode Comparison Security Issues 700 Claim names in JWTs are Unicode strings. For security reasons, the 701 representations of these names must be compared verbatim after 702 performing any escape processing (as per RFC 4627 [RFC4627], Section 703 2.5). 705 This means, for instance, that these JSON strings must compare as 706 being equal ("JWT", "\u004aWT"), whereas these must all compare as 707 being not equal to the first set or to each other ("jwt", "Jwt", 708 "JW\u0074"). 710 JSON strings MAY contain characters outside the Unicode Basic 711 Multilingual Plane. For instance, the G clef character (U+1D11E) may 712 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWT 713 implementations SHOULD ensure that characters outside the Basic 714 Multilingual Plane are preserved and compared correctly; 715 alternatively, if this is not possible due to these characters 716 exercising limitations present in the underlying JSON implementation, 717 then input containing them MUST be rejected. 719 11. Open Issues and Things To Be Done (TBD) 721 The following items remain to be done in this draft: 723 o EDITORIAL: Give each claim name and header parameter definition 724 its own section. This will let them appear in the index, will 725 give space for examples when needed, and will get rid of the way- 726 too-cramped tables. 728 o Add normative text that requires rejecting headers and Claim Sets 729 in which member names occur multiple times, as apparently this is 730 legal JSON. 732 o Provide an example of an encrypted JWT. 734 o Clarify the intended use of the "typ" Header Parameter across the 735 JWS, JWE, and JWT specifications. Decide whether a registry of 736 "typ" values is appropriate. 738 o EDITORIAL: Think about how to best describe the concept currently 739 described as "the bytes of the UTF-8 representation of". Possible 740 terms to use instead of "bytes of" include "byte sequence", "octet 741 series", and "octet sequence". Also consider whether we want to 742 add an overall clarifying statement somewhere in each spec 743 something like "every place we say 'the UTF-8 representation of 744 X', we mean 'the bytes of the UTF-8 representation of X'". That 745 would potentially allow us to omit the "the bytes of" part 746 everywhere else. 748 o Finish the Security Considerations section. 750 o Possibly write a companion specification that uses the JWS and JWE 751 JSON Serializations. 753 12. References 755 12.1. Normative References 757 [JWA] Jones, M., "JSON Web Algorithms (JWA)", March 2012. 759 [JWE] Jones, M., Rescorla, E., and J. Hildebrand, "JSON Web 760 Encryption (JWE)", March 2012. 762 [JWS] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 763 Signature (JWS)", March 2012. 765 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 766 Extensions (MIME) Part One: Format of Internet Message 767 Bodies", RFC 2045, November 1996. 769 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 770 Requirement Levels", BCP 14, RFC 2119, March 1997. 772 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the 773 Internet: Timestamps", RFC 3339, July 2002. 775 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 776 10646", STD 63, RFC 3629, November 2003. 778 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 779 Resource Identifier (URI): Generic Syntax", STD 66, 780 RFC 3986, January 2005. 782 [RFC4627] Crockford, D., "The application/json Media Type for 783 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 785 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 786 Encodings", RFC 4648, October 2006. 788 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 789 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 790 May 2008. 792 [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode 793 Normalization Forms", Unicode Standard Annex 15, 09 2009. 795 12.2. Informative References 797 [CanvasApp] 798 Facebook, "Canvas Applications", 2010. 800 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 801 September 2010. 803 [MagicSignatures] 804 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 805 Signatures", January 2011. 807 [OASIS.saml-core-2.0-os] 808 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 809 "Assertions and Protocol for the OASIS Security Assertion 810 Markup Language (SAML) V2.0", OASIS Standard saml-core- 811 2.0-os, March 2005. 813 [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup 814 Language) XML-Signature Syntax and Processing", RFC 3275, 815 March 2002. 817 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 818 Unique IDentifier (UUID) URN Namespace", RFC 4122, 819 July 2005. 821 [SWT] Hardt, D. and Y. Goland, "Simple Web Token (SWT)", 822 Version 0.9.5.1, November 2009. 824 [W3C.CR-xml11-20021015] 825 Cowan, J., "Extensible Markup Language (XML) 1.1", W3C 826 CR CR-xml11-20021015, October 2002. 828 Appendix A. Relationship of JWTs to SAML Tokens 830 SAML 2.0 [OASIS.saml-core-2.0-os] provides a standard for creating 831 tokens with much greater expressivity and more security options than 832 supported by JWTs. However, the cost of this flexibility and 833 expressiveness is both size and complexity. In addition, SAML's use 834 of XML [W3C.CR-xml11-20021015] and XML DSIG [RFC3275] only 835 contributes to the size of SAML tokens. 837 JWTs are intended to provide a simple token format that is small 838 enough to fit into HTTP headers and query arguments in URIs. It does 839 this by supporting a much simpler token model than SAML and using the 840 JSON [RFC4627] object encoding syntax. It also supports securing 841 tokens using Hash-based Message Authentication Codes (HMACs) and 842 digital signatures using a smaller (and less flexible) format than 843 XML DSIG. 845 Therefore, while JWTs can do some of the things SAML tokens do, JWTs 846 are not intended as a full replacement for SAML tokens, but rather as 847 a compromise token format to be used when space is at a premium. 849 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) 851 Both JWTs and Simple Web Tokens SWT [SWT], at their core, enable sets 852 of claims to be communicated between applications. For SWTs, both 853 the claim names and claim values are strings. For JWTs, while claim 854 names are strings, claim values can be any JSON type. Both token 855 types offer cryptographic protection of their content: SWTs with HMAC 856 SHA-256 and JWTs with a choice of algorithms, including HMAC SHA-256, 857 RSA SHA-256, and ECDSA P-256 SHA-256. 859 Appendix C. Acknowledgements 861 The authors acknowledge that the design of JWTs was intentionally 862 influenced by the design and simplicity of Simple Web Tokens [SWT] 863 and ideas for JSON tokens that Dick Hardt discussed within the OpenID 864 community. 866 Solutions for signing JSON content were previously explored by Magic 867 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 868 Applications [CanvasApp], all of which influenced this draft. 870 Appendix D. Document History 872 -08 874 o Removed language that required that a JWT must have three parts. 875 Now the number of parts is explicitly dependent upon the 876 representation of the underlying JWS or JWE. 878 o Moved the "alg":"none" definition to the JWS spec. 880 o Registered the "application/jwt" MIME Media Type. 882 o Clarified that the order of the creation and validation steps is 883 not significant in cases where there are no dependencies between 884 the inputs and outputs of the steps. 886 o Corrected the Magic Signatures and Simple Web Token (SWT) 887 references. 889 -07 891 o Defined the "prn" (principal) claim to identify the subject of the 892 JWT. 894 o Defined the "jti" (JWT ID) claim to enable replay protection. 896 o Use the term "JWT Claims Set" rather than "JWT Claims Object" 897 since this is actually a string representing a JSON object and not 898 the JSON object itself. 900 o Moved "MUST" requirements from the Overview to later in the spec. 902 o Respect line length restrictions in examples. 904 o Applied other editorial improvements. 906 -06 908 o Reference and use content from [JWS] and [JWE], rather than 909 repeating it here. 911 o Simplified terminology to better match JWE, where the terms "JWT 912 Header" and "Encoded JWT Header" are now used, for instance, 913 rather than the previous terms "Decoded JWT Header Segment" and 914 "JWT Header Segment". Also changed to "Plaintext JWT" from 915 "Unsigned JWT". 917 o Describe how to perform nested encryption and signing operations. 919 o Changed "integer" to "number", since that is the correct JSON 920 type. 922 o Changed StringAndURI to StringOrURI. 924 -05 926 o Added the "nbf" (not before) claim and clarified the meaning of 927 the "iat" (issued at) claim. 929 -04 931 o Correct typo found by John Bradley: "the JWT Claim Segment is the 932 empty string" -> "the JWT Crypto Segment is the empty string". 934 -03 936 o Added "http://openid.net/specs/jwt/1.0" as a token type identifier 937 URI for JWTs. 939 o Added "iat" (issued at) claim. 941 o Changed RSA SHA-256 from MUST be supported to RECOMMENDED that it 942 be supported. Rationale: Several people have objected to the 943 requirement for implementing RSA SHA-256, some because they will 944 only be using HMACs and symmetric keys, and others because they 945 only want to use ECDSA when using asymmetric keys, either for 946 security or key length reasons, or both. 948 o Defined "alg" value "none" to represent unsigned JWTs. 950 -02 952 o Split signature specification out into separate 953 draft-jones-json-web-signature-00. This split introduced no 954 semantic changes. 956 o The JWT Compact Serialization is now the only token serialization 957 format specified in this draft. The JWT JSON Serialization can 958 continue to be defined in a companion specification. 960 -01 962 o Draft incorporating consensus decisions reached at IIW. 964 -00 965 o Public draft published before November 2010 IIW based upon the 966 JSON token convergence proposal incorporating input from several 967 implementers of related specifications. 969 Authors' Addresses 971 Michael B. Jones 972 Microsoft 974 Email: mbj@microsoft.com 975 URI: http://self-issued.info/ 977 Dirk Balfanz 978 Google 980 Email: balfanz@google.com 982 John Bradley 983 independent 985 Email: ve7jtb@ve7jtb.com 987 Yaron Y. Goland 988 Microsoft 990 Email: yarong@microsoft.com 992 John Panzer 993 Google 995 Email: jpanzer@google.com 997 Nat Sakimura 998 Nomura Research Institute 1000 Email: n-sakimura@nri.co.jp 1001 Paul Tarjan 1002 Facebook 1004 Email: pt@fb.com