idnits 2.17.1 draft-jones-json-web-token-06.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 : ---------------------------------------------------------------------------- ** There are 4 instances of too long lines in the document, the longest one being 22 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 30, 2011) is 4555 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) -- 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: 3 errors (**), 0 flaws (~~), 1 warning (==), 3 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: May 2, 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 October 30, 2011 18 JSON Web Token (JWT) 19 draft-jones-json-web-token-06 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 using JSON Web Signature (JWS) 26 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 May 2, 2012. 54 Copyright Notice 56 Copyright (c) 2011 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 . . . . . . . . . . . . . . . . . . . . . . . . . . 9 80 6. Plaintext JWTs . . . . . . . . . . . . . . . . . . . . . . . . 10 81 6.1. Example Plaintext JWT . . . . . . . . . . . . . . . . . . 11 82 7. Rules for Creating and Validating a JWT . . . . . . . . . . . 11 83 8. Cryptographic Algorithms . . . . . . . . . . . . . . . . . . . 14 84 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 85 10. Security Considerations . . . . . . . . . . . . . . . . . . . 15 86 10.1. Unicode Comparison Security Issues . . . . . . . . . . . . 15 87 11. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 16 88 12. References . . . . . . . . . . . . . . . . . . . . . . . . . . 16 89 12.1. Normative References . . . . . . . . . . . . . . . . . . . 16 90 12.2. Informative References . . . . . . . . . . . . . . . . . . 17 91 Appendix A. Relationship of JWTs to SAML Tokens . . . . . . . . . 18 92 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) . . 18 93 Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 18 94 Appendix D. Document History . . . . . . . . . . . . . . . . . . 19 95 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 20 97 1. Introduction 99 JSON Web Token (JWT) is a compact token format intended for space 100 constrained environments such as HTTP Authorization headers and URI 101 query parameters. JWTs encode claims to be transmitted as a JSON 102 object (as defined in RFC 4627 [RFC4627]) that is base64url encoded 103 and digitally signed and/or encrypted. Signing is accomplished using 104 JSON Web Signature (JWS) [JWS]. Encryption is accomplished using 105 JSON Web Encryption (JWE) [JWE]. 107 The suggested pronunciation of JWT is the same as the English word 108 "jot". 110 2. Terminology 112 JSON Web Token (JWT) A string consisting of three parts: the JWT 113 Header, the JWT Second Part, and the JWT Third Part, in that 114 order, with the parts being separated by period ('.') characters, 115 and each part containing base64url encoded content. 117 JWT Header A string containing a JSON object that describes the 118 cryptographic operations applied to the JWT. When the JWT is 119 signed, the JWT Header is the JWS Header. When the JWT is 120 encrypted, the JWT Header is the JWE Header. 122 JWT Second Part When the JWT is signed, the JWT Second Part is the 123 Encoded JWS Payload. When the JWT is encrypted, the JWT Second 124 Part is the Encoded JWE Encrypted Key. 126 JWT Third Part When the JWT is signed, the JWT Third Part is the 127 Encoded JWS Signature. When the JWT is encrypted, the JWT Third 128 Part is the Encoded JWE Ciphertext. 130 JWT Claims Object A JSON object that represents the claims contained 131 in the JWT. When the JWT is signed, the bytes of the UTF-8 132 representation of the JWT Claims Object are base64url encoded to 133 create the Encoded JWS Payload. When the JWT is encrypted, the 134 bytes of the UTF-8 representation of the JWT Claims Object are 135 used as the JWE Plaintext. 137 Claim Names The names of the members of the JWT Claims Object. 139 Claim Values The values of the members of the JWT Claims Object. 141 Encoded JWT Header Base64url encoding of the bytes of the UTF-8 RFC 142 3629 [RFC3629] representation of the JWT Header. 144 Base64url Encoding For the purposes of this specification, this term 145 always refers to the URL- and filename-safe Base64 encoding 146 described in RFC 4648 [RFC4648], Section 5, with the (non URL- 147 safe) '=' padding characters omitted, as permitted by Section 3.2. 148 (See Appendix C of [JWS] for notes on implementing base64url 149 encoding without padding.) 151 3. JSON Web Token (JWT) Overview 153 JWTs represent a set of claims as a JSON object that is base64url 154 encoded and digitally signed and/or encrypted. This object is the 155 JWT Claims Object. As per RFC 4627 [RFC4627] Section 2.2, the JSON 156 object consists of zero or more name/value pairs (or members), where 157 the names are strings and the values are arbitrary JSON values. 158 These members are the claims represented by the JWT. 160 The member names within the JWT Claims Object are referred to as 161 Claim Names. These names MUST be unique. The corresponding values 162 are referred to as Claim Values. 164 The bytes of the UTF-8 representation of the JWT Claims Object are 165 signed in the manner described in JSON Web Signature (JWS) [JWS] 166 and/or encrypted in the manner described in JSON Web Encryption (JWE) 167 [JWE]. 169 The contents of the JWT Header describe the cryptographic operations 170 applied to the JWT Claims Object. If the JWT Header is a JWS Header, 171 the claims are signed. If the JWT Header is a JWE Header, the claims 172 are encrypted. 174 A JWT is represented as the concatenation of the Encoded JWT Header, 175 the JWT Second Part, and the JWT Third Part, in that order, with the 176 parts being separated by period ('.') characters. When signed, the 177 three parts of the JWT are the three parts of a JWS used to represent 178 the JWT. When encrypted, the three parts of the JWT are the three 179 parts of a JWE used to represent the JWT. 181 3.1. Example JWT 183 The following example JWT Header declares that the encoded object is 184 a JSON Web Token (JWT) and the JWT is signed using the HMAC SHA-256 185 algorithm: 186 {"typ":"JWT", 187 "alg":"HS256"} 189 Base64url encoding the bytes of the UTF-8 representation of the JWT 190 Header yields this Encoded JWS Header value, which is used as the 191 Encoded JWT Header: 192 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 194 The following is an example of a JWT Claims Object: 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 Object yields this Encoded JWS Payload, which is used as the 201 JWT Second Part: 202 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 204 Signing the Encoded JWS Header and Encoded JWS Payload with the HMAC 205 SHA-256 algorithm and base64url encoding the signature in the manner 206 specified in [JWS], yields this Encoded JWS Signature, which is used 207 as the JWT Third Part: 208 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 210 Concatenating these parts in the order Header.Second.Third with 211 period characters between the parts yields this complete JWT (with 212 line breaks for display purposes only): 213 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 214 . 215 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 216 . 217 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 219 This computation is illustrated in more detail in [JWS], Appendix 220 A.1. 222 4. JWT Claims 224 A JWT contains a set of claims represented as a base64url encoded 225 JSON object. Note however, that the set of claims a JWT must contain 226 to be considered valid is context-dependent and is outside the scope 227 of this specification. When used in a security-related context, 228 implementations MUST understand and support all of the claims 229 present; otherwise, the JWT MUST be rejected for processing. 231 There are three classes of JWT Claim Names: Reserved Claim Names, 232 Public Claim Names, and Private Claim Names. 234 4.1. Reserved Claim Names 236 The following claim names are reserved. None of the claims defined 237 in the table below are intended to be mandatory, but rather, provide 238 a starting point for a set of useful, interoperable claims. All the 239 names are short because a core goal of JWTs is for the tokens to be 240 compact. 242 +-------+--------+-------------+------------------------------------+ 243 | Claim | JSON | Claim | Claim Semantics | 244 | Name | Value | Syntax | | 245 | | Type | | | 246 +-------+--------+-------------+------------------------------------+ 247 | exp | number | IntDate | The "exp" (expiration time) claim | 248 | | | | identifies the expiration time on | 249 | | | | or after which the token MUST NOT | 250 | | | | be accepted for processing. The | 251 | | | | processing of the "exp" claim | 252 | | | | requires that the current | 253 | | | | date/time MUST be before the | 254 | | | | expiration date/time listed in the | 255 | | | | "exp" claim. Implementers MAY | 256 | | | | provide for some small leeway, | 257 | | | | usually no more than a few | 258 | | | | minutes, to account for clock | 259 | | | | skew. This claim is OPTIONAL. | 260 | nbf | number | IntDate | The "nbf" (not before) claim | 261 | | | | identifies the time before which | 262 | | | | the token MUST NOT be accepted for | 263 | | | | processing. The processing of the | 264 | | | | "nbf" claim requires that the | 265 | | | | current date/time MUST be after or | 266 | | | | equal to the not-before date/time | 267 | | | | listed in the "nbf" claim. | 268 | | | | Implementers MAY provide for some | 269 | | | | small leeway, usually no more than | 270 | | | | a few minutes, to account for | 271 | | | | clock skew. This claim is | 272 | | | | OPTIONAL. | 273 | iat | number | IntDate | The "iat" (issued at) claim | 274 | | | | identifies the time at which the | 275 | | | | JWT was issued. This claim can be | 276 | | | | used to determine the age of the | 277 | | | | token. This claim is OPTIONAL. | 278 | iss | string | StringOrURI | The "iss" (issuer) claim | 279 | | | | identifies the principal that | 280 | | | | issued the JWT. The processing of | 281 | | | | this claim is generally | 282 | | | | application specific. The "iss" | 283 | | | | value is case sensitive. This | 284 | | | | claim is OPTIONAL. | 285 | aud | string | StringOrURI | The "aud" (audience) claim | 286 | | | | identifies the audience that the | 287 | | | | JWT is intended for. The | 288 | | | | principal intended to process the | 289 | | | | JWT MUST be identified by the | 290 | | | | value of the audience claim. If | 291 | | | | the principal processing the claim | 292 | | | | does not identify itself with the | 293 | | | | identifier in the "aud" claim | 294 | | | | value then the JWT MUST be | 295 | | | | rejected. The interpretation of | 296 | | | | the contents of the audience value | 297 | | | | is generally application specific. | 298 | | | | The "aud" value is case sensitive. | 299 | | | | This claim is OPTIONAL. | 300 | typ | string | String | The "typ" (type) claim is used to | 301 | | | | declare a type for the contents of | 302 | | | | this JWT Claims Object. The "typ" | 303 | | | | value is case sensitive. This | 304 | | | | claim is OPTIONAL. | 305 +-------+--------+-------------+------------------------------------+ 307 Table 1: Reserved Claim Definitions 309 Additional reserved claim names MAY be defined via the IANA JSON Web 310 Token Claims registry, as per Section 9. The syntax values used 311 above are defined as follows: 313 +-------------+-----------------------------------------------------+ 314 | Syntax Name | Syntax Definition | 315 +-------------+-----------------------------------------------------+ 316 | IntDate | The number of seconds from 1970-01-01T0:0:0Z as | 317 | | measured in UTC until the desired date/time. See | 318 | | RFC 3339 [RFC3339] for details regarding date/times | 319 | | in general and UTC in particular. | 320 | String | Any string value MAY be used. | 321 | StringOrURI | Any string value MAY be used but a value containing | 322 | | a ":" character MUST be a URI as defined in RFC | 323 | | 3986 [RFC3986]. | 324 +-------------+-----------------------------------------------------+ 325 Table 2: Claim Syntax Definitions 327 4.2. Public Claim Names 329 Claim names can be defined at will by those using JWTs. However, in 330 order to prevent collisions, any new claim name SHOULD either be 331 defined in the IANA JSON Web Token Claims registry or be defined as a 332 URI that contains a collision resistant namespace. Examples of 333 collision resistant namespaces include: 335 o Domain Names, 337 o Object Identifiers (OIDs) as defined in the ITU-T X 660 and X 670 338 Recommendation series or 340 o Universally Unique IDentifier (UUID) as defined in RFC 4122 341 [RFC4122]. 343 In each case, the definer of the name or value MUST take reasonable 344 precautions to make sure they are in control of the part of the 345 namespace they use to define the claim name. 347 4.3. Private Claim Names 349 A producer and consumer of a JWT may agree to any claim name that is 350 not a Reserved Name Section 4.1 or a Public Name Section 4.2. Unlike 351 Public Names, these private names are subject to collision and should 352 be used with caution. 354 5. JWT Header 356 The members of the JSON object represented by the JWT Header describe 357 the cryptographic operations applied to the JWT and optionally, 358 additional properties of the JWT. 360 There are two ways of distinguishing whether the JWT is a JWS or JWE. 361 The first is by examining the "alg" (algorithm) header value. If the 362 value represents a signature algorithm, the JWT is a JWS; if it 363 represents an encryption algorithm, the JWT is a JWE. A second 364 method is determining whether an "enc" (encryption method) member 365 exists. If the "enc" member exists, the JWT is a JWE; otherwise, the 366 JWT is a JWS. Both methods will yield the same result. 368 Implementations MUST understand the entire contents of the header; 369 otherwise, the JWT MUST be rejected for processing. 371 JWS Header Parameters are defined by [JWS]. JWE Header Parameters 372 are defined by [JWE]. This specification further specifies the use 373 of the following header parameters in both the cases where the JWT is 374 a JWS and where it is a JWE. 376 +----------+--------+-----------+-----------------------------------+ 377 | Header | JSON | Header | Header Parameter Semantics | 378 | Paramete | Value | Parameter | | 379 | rName | Type | Syntax | | 380 +----------+--------+-----------+-----------------------------------+ 381 | typ | string | String | The "typ" (type) header parameter | 382 | | | | is used to declare structural | 383 | | | | information about the JWT. In | 384 | | | | the normal case where nested | 385 | | | | signing or encryption operations | 386 | | | | are not employed, the use of this | 387 | | | | header parameter is OPTIONAL, and | 388 | | | | if present, it is RECOMMENDED | 389 | | | | that its value be either "JWT" or | 390 | | | | "http://openid.net/specs/jwt/1.0" | 391 | | | | .In the case that nested signing | 392 | | | | or encryption steps are employed | 393 | | | | ,the use of this header parameter | 394 | | | | is REQUIRED; in this case, the | 395 | | | | value MUST either be "JWS", to | 396 | | | | indicate that a nested signed JW | 397 | | | | Tis carried in this JWT or "JWE", | 398 | | | | to indicate that a nested | 399 | | | | encrypted JWT is carried in this | 400 | | | | JWT. | 401 +----------+--------+-----------+-----------------------------------+ 403 Table 3: Reserved Header Parameter Usage 405 6. Plaintext JWTs 407 To support use cases where the JWT content is secured by a means 408 other than a signature and/or encryption contained within the token 409 (such as a signature on a data structure containing the token), JWTs 410 MAY also be created without a signature or encryption. Plaintext 411 JWTs MUST use the "alg" value "none", and are formatted identically 412 to a signed JWT with an empty signature. This means that the 413 base64url encoding of the bytes representing the UTF-8 encoding of 414 the JWT Claims Object is the JWT Second Part, and the empty string is 415 the JWT Third Part. 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 Object: 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 Object yields this Encoded JWS Payload, which is used as the 434 JWT Second Part: 435 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 437 The JWT Third Part is the empty string. 439 Concatenating these parts in the order Header.Second.Third with 440 period characters between the parts yields this complete JWT (with 441 line breaks for display purposes only): 442 eyJhbGciOiJub25lIn0 443 . 444 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 445 . 447 7. Rules for Creating and Validating a JWT 449 To create a JWT, one MUST follow these steps: 451 1. Create a JWT Claims Object containing the desired claims. Note 452 that white space is explicitly allowed in the representation and 453 no canonicalization is performed before encoding. 455 2. Let the Message be the bytes of the UTF-8 representation of the 456 JWT Claims Object. 458 3. Create a JWT Header containing the desired set of header 459 parameters. If the JWT is to be signed or encrypted, they MUST 460 conform to either the [JWS] or [JWE] specifications, 461 respectively. Else, if the JWT is to be plaintext, the "alg" 462 value "none" MUST be used. Note that white space is explicitly 463 allowed in the representation and no canonicalization is 464 performed before encoding. 466 4. Base64url encode the bytes of the UTF-8 representation of the JWT 467 Header. Let this be the Encoded JWT Header. 469 5. Depending upon whether the JWT is to be signed, encrypted, or 470 plaintext, there are three cases: 472 * If the JWT is to be signed, create a JWS using the JWT Header 473 as the JWS Header and the Message as the JWS Payload; all 474 steps specified in [JWS] for creating a JWS MUST be followed. 475 Let the JWT Second Part be the Encoded JWS Payload and let the 476 JWT Third Part be the Encoded JWS Signature. 478 * If the JWT is to be encrypted, create a JWE using the JWT 479 Header as the JWE Header and the Message as the JWE Plaintext; 480 all steps specified in [JWE] for creating a JWE MUST be 481 followed. Let the JWT Second Part be the Encoded JWE 482 Encrypted Key and let the JWT Third Part be the Encoded JWS 483 Ciphertext. 485 * Else, if the JWT is to be plaintext, let the JWT Second Part 486 be the base64url encoding of the Message and let the JWT Third 487 Part be the empty string. 489 6. Concatenate the Encoded JWT Header, the JWT Second Part, and the 490 JWT Third Part in that order, separating each by period ('.') 491 characters. 493 7. If a nested signing or encryption operation will be performed, 494 let the Message be this concatenation, and return to Step 3, 495 using a "typ" value of either "JWS" or "JWE" respectively in the 496 new JWT Header created in that step. 498 8. Otherwise, let the resulting JWT be this concatenation. 500 When validating a JWT the following steps MUST be taken. If any of 501 the listed steps fails then the token MUST be rejected for 502 processing. 504 1. The JWT MUST contain exactly two period characters. 506 2. The JWT MUST be split on the two period characters resulting in 507 three strings. The first string is the Encoded JWT Header; the 508 second is the JWT Second Part; the third is the JWT Third Part. 510 3. The Encoded JWT Header MUST be successfully base64url decoded 511 following the restriction given in this specification that no 512 padding characters have been used. 514 4. The JWT Header MUST be completely valid JSON syntax conforming 515 to RFC 4627 [RFC4627]. 517 5. The JWT Header MUST be validated to only include parameters and 518 values whose syntax and semantics are both understood and 519 supported. 521 6. Determine whether the JWT is signed, encrypted, or plaintext by 522 examining the "alg" (algorithm) header value and optionally, the 523 "enc" (encryption method) header value, if present. 525 7. Depending upon whether the JWT signed, encrypted, or plaintext, 526 there are three cases: 528 * If the JWT is signed, all steps specified in [JWS] for 529 validating a JWS MUST be followed. Let the Message be the 530 result of base64url decoding the JWS Payload. 532 * If the JWT is encrypted, all steps specified in [JWE] for 533 validating a JWE MUST be followed. Let the Message be the 534 JWE Plaintext. 536 * Else, if the JWT is plaintext, let the Message be the result 537 of base64url decoding the JWE Second Part. The Third Part 538 MUST be verified to be the empty string. 540 8. If the JWT Header contains a "typ" value of either "JWS" or 541 "JWE", then the Message contains a JWT that was the subject of 542 nested signing or encryption operations, respectively. In this 543 case, return to Step 1, using the Message as the JWT. 545 9. Otherwise, let the JWT Claims object be the Message. 547 10. The JWT Claims Object MUST be completely valid JSON syntax 548 conforming to RFC 4627 [RFC4627]. 550 11. When used in a security-related context, the JWT Claims Object 551 MUST be validated to only include claims whose syntax and 552 semantics are both understood and supported. 554 Processing a JWT inevitably requires comparing known strings to 555 values in the token. For example, in checking what the algorithm is, 556 the Unicode string encoding "alg" will be checked against the member 557 names in the JWT Header to see if there is a matching header 558 parameter name. A similar process occurs when determining if the 559 value of the "alg" header parameter represents a supported algorithm. 561 Comparing Unicode strings, however, has significant security 562 implications, as per Section 10. 564 Comparisons between JSON strings and other Unicode strings MUST be 565 performed as specified below: 567 1. Remove any JSON applied escaping to produce an array of Unicode 568 code points. 570 2. Unicode Normalization [USA15] MUST NOT be applied at any point to 571 either the JSON string or to the string it is to be compared 572 against. 574 3. Comparisons between the two strings MUST be performed as a 575 Unicode code point to code point equality comparison. 577 8. Cryptographic Algorithms 579 JWTs use JSON Web Signature (JWS) [JWS] and JSON Web Encryption (JWE) 580 [JWE] to sign and/or encrypt the contents of the JWT. 582 Of the JWS signing algorithms, only HMAC SHA-256 MUST be implemented 583 by conforming JWT implementations. It is RECOMMENDED that 584 implementations also support the RSA SHA-256 and ECDSA P-256 SHA-256 585 algorithms. Support for other algorithms and key sizes is OPTIONAL. 587 If an implementation provides encryption capabilities, of the JWE 588 encryption algorithms, only RSA-PKCS1-1.5 with 2048 bit keys, AES- 589 128-CBC, and AES-256-CBC MUST be implemented by conforming 590 implementations. It is RECOMMENDED that implementations also support 591 ECDH-ES with 256 bit keys, AES-128-GCM, and AES-256-GCM. Support for 592 other algorithms and key sizes is OPTIONAL. 594 9. IANA Considerations 596 This specification calls for: 598 o A new IANA registry entitled "JSON Web Token Claims" for reserved 599 claim names is defined in Section 4.1. Inclusion in the registry 600 is RFC Required in the RFC 5226 [RFC5226] sense for reserved JWT 601 claim names that are intended to be interoperable between 602 implementations. The registry will just record the reserved claim 603 name and a pointer to the RFC that defines it. This specification 604 defines inclusion of the claim names defined in Table 1. 606 10. Security Considerations 608 TBD: Lots of work to do here. We need to remember to look into any 609 issues relating to security and JSON parsing. One wonders just how 610 secure most JSON parsing libraries are. Were they ever hardened for 611 security scenarios? If not, what kind of holes does that open up? 612 Also, we need to walk through the JSON standard and see what kind of 613 issues we have especially around comparison of names. For instance, 614 comparisons of claim names and other parameters must occur after they 615 are unescaped. Need to also put in text about: Importance of keeping 616 secrets secret. Rotating keys. Strengths and weaknesses of the 617 different algorithms. 619 TBD: Need to put in text about why strict JSON validation is 620 necessary. Basically, that if malformed JSON is received then the 621 intent of the sender is impossible to reliably discern. One example 622 of malformed JSON that MUST be rejected is an object in which the 623 same member name occurs multiple times. While in non-security 624 contexts it's o.k. to be generous in what one accepts, in security 625 contexts this can lead to serious security holes. For example, 626 malformed JSON might indicate that someone has managed to find a 627 security hole in the issuer's code and is leveraging it to get the 628 issuer to issue "bad" tokens whose content the attacker can control. 630 TBD: Write about the need to secure the token content if a signature 631 is not contained in the JWT itself. 633 10.1. Unicode Comparison Security Issues 635 Claim names in JWTs are Unicode strings. For security reasons, the 636 representations of these names must be compared verbatim after 637 performing any escape processing (as per RFC 4627 [RFC4627], Section 638 2.5). 640 This means, for instance, that these JSON strings must compare as 641 being equal ("JWT", "\u004aWT"), whereas these must all compare as 642 being not equal to the first set or to each other ("jwt", "Jwt", 643 "JW\u0074"). 645 JSON strings MAY contain characters outside the Unicode Basic 646 Multilingual Plane. For instance, the G clef character (U+1D11E) may 647 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWT 648 implementations SHOULD ensure that characters outside the Basic 649 Multilingual Plane are preserved and compared correctly; 650 alternatively, if this is not possible due to these characters 651 exercising limitations present in the underlying JSON implementation, 652 then input containing them MUST be rejected. 654 11. Open Issues and Things To Be Done (TBD) 656 The following items remain to be done in this draft: 658 o Provide an example of an encrypted JWT. 660 o Clarify the optional ability to provide type information for JWTs 661 and/or their parts. Specifically, clarify whether we need to 662 specify the "typ" Claim Name in addition to the Header Parameter, 663 whether it conveys syntax or semantics, and indeed, whether this 664 is the right approach. Also clarify the relationship between 665 these type values and MIME [RFC2045] types. 667 o Think about how to best describe the concept currently described 668 as "the bytes of the UTF-8 representation of". Possible terms to 669 use instead of "bytes of" include "byte sequence", "octet series", 670 and "octet sequence". Also consider whether we want to add an 671 overall clarifying statement somewhere in each spec something like 672 "every place we say 'the UTF-8 representation of X', we mean 'the 673 bytes of the UTF-8 representation of X'". That would potentially 674 allow us to omit the "the bytes of" part everywhere else. 676 o Consider whether a media type should be proposed, such as 677 "application/jwt". 679 o Finish the Security Considerations section. 681 o Possibly write a companion specification that contains the former 682 JWT JSON Serialization. 684 12. References 686 12.1. Normative References 688 [JWS] Jones, M., Balfanz, D., Bradley, J., Goland, Y., Panzer, 689 J., Sakimura, N., and P. Tarjan, "JSON Web Signature 690 (JWS)", October 2011. 692 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 693 Extensions (MIME) Part One: Format of Internet Message 694 Bodies", RFC 2045, November 1996. 696 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 697 Requirement Levels", BCP 14, RFC 2119, March 1997. 699 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the 700 Internet: Timestamps", RFC 3339, July 2002. 702 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 703 10646", STD 63, RFC 3629, November 2003. 705 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 706 Resource Identifier (URI): Generic Syntax", STD 66, 707 RFC 3986, January 2005. 709 [RFC4627] Crockford, D., "The application/json Media Type for 710 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 712 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 713 Encodings", RFC 4648, October 2006. 715 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 716 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 717 May 2008. 719 [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode 720 Normalization Forms", Unicode Standard Annex 15, 09 2009. 722 12.2. Informative References 724 [CanvasApp] 725 Facebook, "Canvas Applications", 2010. 727 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 728 September 2010. 730 [JWE] Jones, M., Rescorla, E., and J. Hildebrand, "JSON Web 731 Encryption (JWE)", October 2011. 733 [MagicSignatures] 734 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 735 Signatures", August 2010. 737 [OASIS.saml-core-2.0-os] 738 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 739 "Assertions and Protocol for the OASIS Security Assertion 740 Markup Language (SAML) V2.0", OASIS Standard saml-core- 741 2.0-os, March 2005. 743 [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup 744 Language) XML-Signature Syntax and Processing", RFC 3275, 745 March 2002. 747 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 748 Unique IDentifier (UUID) URN Namespace", RFC 4122, 749 July 2005. 751 [SWT] Hardt, D. and Y. Goland, "Simple Web Token (SWT)", 752 Version 0.9.5.1, November 2009. 754 [W3C.CR-xml11-20021015] 755 Cowan, J., "Extensible Markup Language (XML) 1.1", W3C 756 CR CR-xml11-20021015, October 2002. 758 Appendix A. Relationship of JWTs to SAML Tokens 760 SAML 2.0 [OASIS.saml-core-2.0-os] provides a standard for creating 761 tokens with much greater expressivity and more security options than 762 supported by JWTs. However, the cost of this flexibility and 763 expressiveness is both size and complexity. In addition, SAML's use 764 of XML [W3C.CR-xml11-20021015] and XML DSIG [RFC3275] only 765 contributes to the size of SAML tokens. 767 JWTs are intended to provide a simple token format that is small 768 enough to fit into HTTP headers and query arguments in URIs. It does 769 this by supporting a much simpler token model than SAML and using the 770 JSON [RFC4627] object encoding syntax. It also supports securing 771 tokens using Hash-based Message Authentication Codes (HMACs) and 772 digital signatures using a smaller (and less flexible) format than 773 XML DSIG. 775 Therefore, while JWTs can do some of the things SAML tokens do, JWTs 776 are not intended as a full replacement for SAML tokens, but rather as 777 a compromise token format to be used when space is at a premium. 779 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) 781 Both JWTs and Simple Web Tokens SWT [SWT], at their core, enable sets 782 of claims to be communicated between applications. For SWTs, both 783 the claim names and claim values are strings. For JWTs, while claim 784 names are strings, claim values can be any JSON type. Both token 785 types offer cryptographic protection of their content: SWTs with HMAC 786 SHA-256 and JWTs with a choice of algorithms, including HMAC SHA-256, 787 RSA SHA-256, and ECDSA P-256 SHA-256. 789 Appendix C. Acknowledgements 791 The authors acknowledge that the design of JWTs was intentionally 792 influenced by the design and simplicity of Simple Web Tokens [SWT] 793 and ideas for JSON tokens that Dick Hardt discussed within the OpenID 794 community. 796 Solutions for signing JSON content were previously explored by Magic 797 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 798 Applications [CanvasApp], all of which influenced this draft. 800 Appendix D. Document History 802 -06 804 o Reference and use content from [JWS] and [JWE], rather than 805 repeating it here. 807 o Simplified terminology to better match JWE, where the terms "JWT 808 Header" and "Encoded JWT Header" are now used, for instance, 809 rather than the previous terms "Decoded JWT Header Segment" and 810 "JWT Header Segment". Also changed to "Plaintext JWT" from 811 "Unsigned JWT". 813 o Describe how to perform nested encryption and signing operations. 815 o Changed "integer" to "number", since that is the correct JSON 816 type. 818 o Changed StringAndURI to StringOrURI. 820 -05 822 o Added the "nbf" (not before) claim and clarified the meaning of 823 the "iat" (issued at) claim. 825 -04 827 o Correct typo found by John Bradley: "the JWT Claim Segment is the 828 empty string" -> "the JWT Crypto Segment is the empty string". 830 -03 832 o Added "http://openid.net/specs/jwt/1.0" as a token type identifier 833 URI for JWTs. 835 o Added "iat" (issued at) claim. 837 o Changed RSA SHA-256 from MUST be supported to RECOMMENDED that it 838 be supported. Rationale: Several people have objected to the 839 requirement for implementing RSA SHA-256, some because they will 840 only be using HMACs and symmetric keys, and others because they 841 only want to use ECDSA when using asymmetric keys, either for 842 security or key length reasons, or both. 844 o Defined "alg" value "none" to represent unsigned JWTs. 846 -02 848 o Split signature specification out into separate 849 draft-jones-json-web-signature-00. This split introduced no 850 semantic changes. 852 o The JWT Compact Serialization is now the only token serialization 853 format specified in this draft. The JWT JSON Serialization can 854 continue to be defined in a companion specification. 856 -01 858 o Draft incorporating consensus decisions reached at IIW. 860 -00 862 o Public draft published before November 2010 IIW based upon the 863 JSON token convergence proposal incorporating input from several 864 implementers of related specifications. 866 Authors' Addresses 868 Michael B. Jones 869 Microsoft 871 Email: mbj@microsoft.com 872 URI: http://self-issued.info/ 874 Dirk Balfanz 875 Google 877 Email: balfanz@google.com 879 John Bradley 880 independent 882 Email: ve7jtb@ve7jtb.com 883 Yaron Y. Goland 884 Microsoft 886 Email: yarong@microsoft.com 888 John Panzer 889 Google 891 Email: jpanzer@google.com 893 Nat Sakimura 894 Nomura Research Institute 896 Email: n-sakimura@nri.co.jp 898 Paul Tarjan 899 Facebook 901 Email: pt@fb.com