idnits 2.17.1 draft-jones-json-web-token-07.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 (December 13, 2011) is 4518 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: 2 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: June 15, 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 December 13, 2011 18 JSON Web Token (JWT) 19 draft-jones-json-web-token-07 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 June 15, 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 . . . . . . . . . . . . . . . . . . . . . . . 6 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 . . . . . . . . . . . . . . . . . . . 10 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 . . . . . . . . . . . . . . . . . . . 15 84 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 85 10. Security Considerations . . . . . . . . . . . . . . . . . . . 15 86 10.1. Unicode Comparison Security Issues . . . . . . . . . . . . 16 87 11. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 16 88 12. References . . . . . . . . . . . . . . . . . . . . . . . . . . 17 89 12.1. Normative References . . . . . . . . . . . . . . . . . . . 17 90 12.2. Informative References . . . . . . . . . . . . . . . . . . 18 91 Appendix A. Relationship of JWTs to SAML Tokens . . . . . . . . . 19 92 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) . . 19 93 Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 19 94 Appendix D. Document History . . . . . . . . . . . . . . . . . . 20 95 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 21 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 Encoded 113 JWT 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 representing 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 Header Parameter Names The names of the members within the JWT 123 Header. 125 Header Parameter Values The values of the members within the JWT 126 Header. 128 JWT Second Part When the JWT is signed, the JWT Second Part is the 129 Encoded JWS Payload. When the JWT is encrypted, the JWT Second 130 Part is the Encoded JWE Encrypted Key. 132 JWT Third Part When the JWT is signed, the JWT Third Part is the 133 Encoded JWS Signature. When the JWT is encrypted, the JWT Third 134 Part is the Encoded JWE Ciphertext. 136 JWT Claims Set A string representing a JSON object that contains the 137 claims conveyed by the JWT. When the JWT is signed, the bytes of 138 the UTF-8 representation of the JWT Claims Set are base64url 139 encoded to create the Encoded JWS Payload. When the JWT is 140 encrypted, the bytes of the UTF-8 representation of the JWT Claims 141 Set are used as the JWE Plaintext. 143 Claim Names The names of the members of the JSON object represented 144 by the JWT Claims Set. 146 Claim Values The values of the members of the JSON object 147 represented by the JWT Claims Set. 149 Encoded JWT Header Base64url encoding of the bytes of the UTF-8 RFC 150 3629 [RFC3629] representation of the JWT Header. 152 Base64url Encoding For the purposes of this specification, this term 153 always refers to the URL- and filename-safe Base64 encoding 154 described in RFC 4648 [RFC4648], Section 5, with the (non URL- 155 safe) '=' padding characters omitted, as permitted by Section 3.2. 156 (See Appendix C of [JWS] for notes on implementing base64url 157 encoding without padding.) 159 3. JSON Web Token (JWT) Overview 161 JWTs represent a set of claims as a JSON object that is base64url 162 encoded and digitally signed and/or encrypted. The JWT Claims Set 163 represents this JSON object. As per RFC 4627 [RFC4627] Section 2.2, 164 the JSON object consists of zero or more name/value pairs (or 165 members), where the names are strings and the values are arbitrary 166 JSON values. These members are the claims represented by the JWT. 168 The member names within the JWT Claims Set are referred to as Claim 169 Names. The corresponding values are referred to as Claim Values. 171 The bytes of the UTF-8 representation of the JWT Claims Set are 172 signed in the manner described in JSON Web Signature (JWS) [JWS] 173 and/or encrypted in the manner described in JSON Web Encryption (JWE) 174 [JWE]. 176 The contents of the JWT Header describe the cryptographic operations 177 applied to the JWT Claims Set. If the JWT Header is a JWS Header, the 178 claims are signed. If the JWT Header is a JWE Header, the claims are 179 encrypted. 181 A JWT is represented as the concatenation of the Encoded JWT Header, 182 the JWT Second Part, and the JWT Third Part, in that order, with the 183 parts being separated by period ('.') characters. When signed, the 184 three parts of the JWT are the three parts of a JWS used to represent 185 the JWT. When encrypted, the three parts of the JWT are the three 186 parts of a JWE used to represent the JWT. 188 3.1. Example JWT 190 The following example JWT Header declares that the encoded object is 191 a JSON Web Token (JWT) and the JWT is signed using the HMAC SHA-256 192 algorithm: 193 {"typ":"JWT", 194 "alg":"HS256"} 196 Base64url encoding the bytes of the UTF-8 representation of the JWT 197 Header yields this Encoded JWS Header value, which is used as the 198 Encoded JWT Header: 199 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 201 The following is an example of a JWT Claims Set: 202 {"iss":"joe", 203 "exp":1300819380, 204 "http://example.com/is_root":true} 206 Base64url encoding the bytes of the UTF-8 representation of the JSON 207 Claims Set yields this Encoded JWS Payload, which is used as the JWT 208 Second Part (with line breaks for display purposes only): 209 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly 210 9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ 212 Signing the Encoded JWS Header and Encoded JWS Payload with the HMAC 213 SHA-256 algorithm and base64url encoding the signature in the manner 214 specified in [JWS], yields this Encoded JWS Signature, which is used 215 as the JWT Third Part: 216 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 218 Concatenating these parts in the order Header.Second.Third with 219 period characters between the parts yields this complete JWT (with 220 line breaks for display purposes only): 221 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 222 . 223 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 224 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 225 . 226 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 228 This computation is illustrated in more detail in [JWS], Appendix 229 A.1. 231 4. JWT Claims 233 The JWT Claims Set represents a JSON object whose members are the 234 claims conveyed by the JWT. The Claim Names within this object MUST 235 be unique. Note however, that the set of claims that a JWT must 236 contain to be considered valid is context-dependent and is outside 237 the scope of this specification. When used in a security-related 238 context, implementations MUST understand and support all of the 239 claims present; otherwise, the JWT MUST be rejected for processing. 241 There are three classes of JWT Claim Names: Reserved Claim Names, 242 Public Claim Names, and Private Claim Names. 244 4.1. Reserved Claim Names 246 The following claim names are reserved. None of the claims defined 247 in the table below are intended to be mandatory, but rather, provide 248 a starting point for a set of useful, interoperable claims. All the 249 names are short because a core goal of JWTs is for the tokens to be 250 compact. 252 +-------+--------+-------------+------------------------------------+ 253 | Claim | JSON | Claim | Claim Semantics | 254 | Name | Value | Syntax | | 255 | | Type | | | 256 +-------+--------+-------------+------------------------------------+ 257 | exp | number | IntDate | The "exp" (expiration time) claim | 258 | | | | identifies the expiration time on | 259 | | | | or after which the token MUST NOT | 260 | | | | be accepted for processing. The | 261 | | | | processing of the "exp" claim | 262 | | | | requires that the current | 263 | | | | date/time MUST be before the | 264 | | | | expiration date/time listed in the | 265 | | | | "exp" claim. Implementers MAY | 266 | | | | provide for some small leeway, | 267 | | | | usually no more than a few | 268 | | | | minutes, to account for clock | 269 | | | | skew. This claim is OPTIONAL. | 270 | nbf | number | IntDate | The "nbf" (not before) claim | 271 | | | | identifies the time before which | 272 | | | | the token MUST NOT be accepted for | 273 | | | | processing. The processing of the | 274 | | | | "nbf" claim requires that the | 275 | | | | current date/time MUST be after or | 276 | | | | equal to the not-before date/time | 277 | | | | listed in the "nbf" claim. | 278 | | | | Implementers MAY provide for some | 279 | | | | small leeway, usually no more than | 280 | | | | a few minutes, to account for | 281 | | | | clock skew. This claim is | 282 | | | | OPTIONAL. | 283 | iat | number | IntDate | The "iat" (issued at) claim | 284 | | | | identifies the time at which the | 285 | | | | JWT was issued. This claim can be | 286 | | | | used to determine the age of the | 287 | | | | token. This claim is OPTIONAL. | 288 | iss | string | StringOrURI | The "iss" (issuer) claim | 289 | | | | identifies the principal that | 290 | | | | issued the JWT. The processing of | 291 | | | | this claim is generally | 292 | | | | application specific. The "iss" | 293 | | | | value is case sensitive. This | 294 | | | | claim is OPTIONAL. | 295 | aud | string | StringOrURI | The "aud" (audience) claim | 296 | | | | identifies the audience that the | 297 | | | | JWT is intended for. The | 298 | | | | principal intended to process the | 299 | | | | JWT MUST be identified with the | 300 | | | | value of the audience claim. If | 301 | | | | the principal processing the claim | 302 | | | | does not identify itself with the | 303 | | | | identifier in the "aud" claim | 304 | | | | value then the JWT MUST be | 305 | | | | rejected. The interpretation of | 306 | | | | the audience value is generally | 307 | | | | application specific. The "aud" | 308 | | | | value is case sensitive. This | 309 | | | | claim is OPTIONAL. | 310 | prn | string | StringOrURI | The "prn" (principal) claim | 311 | | | | identifies the subject of the JWT. | 312 | | | | The processing of this claim is | 313 | | | | generally application specific. | 314 | | | | The "prn" value is case sensitive. | 315 | | | | This claim is OPTIONAL. | 316 | jti | string | String | The "jti" (JWT ID) claim provides | 317 | | | | a unique identifier for the JWT. | 318 | | | | The identifier value MUST be | 319 | | | | assigned in a manner that ensures | 320 | | | | that there is a negligible | 321 | | | | probability that the same value | 322 | | | | will be accidentally assigned to a | 323 | | | | different data object. The "jti" | 324 | | | | claim can be used to prevent the | 325 | | | | JWT from being replayed. The | 326 | | | | "jti" value is case sensitive. | 327 | | | | This claim is OPTIONAL. | 328 | typ | string | String | The "typ" (type) claim is used to | 329 | | | | declare a type for the contents of | 330 | | | | this JWT Claims Set. The "typ" | 331 | | | | value is case sensitive. This | 332 | | | | claim is OPTIONAL. | 333 +-------+--------+-------------+------------------------------------+ 335 Table 1: Reserved Claim Definitions 337 Additional reserved claim names MAY be defined via the IANA JSON Web 338 Token Claims registry, as per Section 9. The syntax values used 339 above are defined as follows: 341 +-------------+-----------------------------------------------------+ 342 | Syntax Name | Syntax Definition | 343 +-------------+-----------------------------------------------------+ 344 | IntDate | The number of seconds from 1970-01-01T0:0:0Z as | 345 | | measured in UTC until the desired date/time. See | 346 | | RFC 3339 [RFC3339] for details regarding date/times | 347 | | in general and UTC in particular. | 348 | String | Any string value MAY be used. | 349 | StringOrURI | Any string value MAY be used but a value containing | 350 | | a ":" character MUST be a URI as defined in RFC | 351 | | 3986 [RFC3986]. | 352 +-------------+-----------------------------------------------------+ 354 Table 2: Claim Syntax Definitions 356 4.2. Public Claim Names 358 Claim names can be defined at will by those using JWTs. However, in 359 order to prevent collisions, any new claim name SHOULD either be 360 defined in the IANA JSON Web Token Claims registry or be defined as a 361 URI that contains a collision resistant namespace. Examples of 362 collision resistant namespaces include: 364 o Domain Names, 366 o Object Identifiers (OIDs) as defined in the ITU-T X.660 and X.670 367 Recommendation series, or 369 o Universally Unique IDentifier (UUID) as defined in RFC 4122 370 [RFC4122]. 372 In each case, the definer of the name or value needs to take 373 reasonable precautions to make sure they are in control of the part 374 of the namespace they use to define the claim name. 376 4.3. Private Claim Names 378 A producer and consumer of a JWT may agree to any claim name that is 379 not a Reserved Name Section 4.1 or a Public Name Section 4.2. Unlike 380 Public Names, these private names are subject to collision and should 381 be used with caution. 383 5. JWT Header 385 The members of the JSON object represented by the JWT Header describe 386 the cryptographic operations applied to the JWT and optionally, 387 additional properties of the JWT. The member names within the JWT 388 Header are referred to as Header Parameter Names. These names MUST 389 be unique. The corresponding values are referred to as Header 390 Parameter Values. 392 Implementations MUST understand the entire contents of the header; 393 otherwise, the JWT MUST be rejected for processing. 395 There are two ways of distinguishing whether the JWT is a JWS or JWE. 396 The first is by examining the "alg" (algorithm) header value. If the 397 value represents a signature algorithm, the JWT is a JWS; if it 398 represents an encryption algorithm, the JWT is a JWE. A second 399 method is determining whether an "enc" (encryption method) member 400 exists. If the "enc" member exists, the JWT is a JWE; otherwise, the 401 JWT is a JWS. Both methods will yield the same result. 403 JWS Header Parameters are defined by [JWS]. JWE Header Parameters 404 are defined by [JWE]. This specification further specifies the use 405 of the following header parameters in both the cases where the JWT is 406 a JWS and where it is a JWE. 408 +----------+--------+-----------+-----------------------------------+ 409 | Header | JSON | Header | Header Parameter Semantics | 410 | Paramete | Value | Parameter | | 411 | rName | Type | Syntax | | 412 +----------+--------+-----------+-----------------------------------+ 413 | typ | string | String | The "typ" (type) header parameter | 414 | | | | is used to declare structural | 415 | | | | information about the JWT. In | 416 | | | | the normal case where nested | 417 | | | | signing or encryption operations | 418 | | | | are not employed, the use of this | 419 | | | | header parameter is OPTIONAL, and | 420 | | | | if present, it is RECOMMENDED | 421 | | | | that its value be either "JWT" or | 422 | | | | "http://openid.net/specs/jwt/1.0" | 423 | | | | .In the case that nested signing | 424 | | | | or encryption steps are employed | 425 | | | | ,the use of this header parameter | 426 | | | | is REQUIRED; in this case, the | 427 | | | | value MUST either be "JWS", to | 428 | | | | indicate that a nested signed JW | 429 | | | | Tis carried in this JWT or "JWE", | 430 | | | | to indicate that a nested | 431 | | | | encrypted JWT is carried in this | 432 | | | | JWT. | 433 +----------+--------+-----------+-----------------------------------+ 435 Table 3: Reserved Header Parameter Usage 437 6. Plaintext JWTs 439 To support use cases where the JWT content is secured by a means 440 other than a signature and/or encryption contained within the token 441 (such as a signature on a data structure containing the token), JWTs 442 MAY also be created without a signature or encryption. Plaintext 443 JWTs MUST use the "alg" value "none", and are formatted identically 444 to a signed JWT with an empty signature. This means that the 445 base64url encoding of the bytes representing the UTF-8 encoding of 446 the JWT Claims Set is the JWT Second Part, and the empty string is 447 the JWT Third Part. 449 6.1. Example Plaintext JWT 451 The following example JWT Header declares that the encoded object is 452 a Plaintext JWT: 453 {"alg":"none"} 454 Base64url encoding the bytes of the UTF-8 representation of the JWT 455 Header yields this Encoded JWT Header: 456 eyJhbGciOiJub25lIn0 458 The following is an example of a JWT Claims Set: 459 {"iss":"joe", 460 "exp":1300819380, 461 "http://example.com/is_root":true} 463 Base64url encoding the bytes of the UTF-8 representation of the JSON 464 Claims Set yields this Encoded JWS Payload, which is used as the JWT 465 Second Part (with line breaks for display purposes only): 466 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 467 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 469 The JWT Third Part is the empty string. 471 Concatenating these parts in the order Header.Second.Third with 472 period characters between the parts yields this complete JWT (with 473 line breaks for display purposes only): 474 eyJhbGciOiJub25lIn0 475 . 476 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 477 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 478 . 480 7. Rules for Creating and Validating a JWT 482 To create a JWT, one MUST perform these steps: 484 1. Create a JWT Claims Set containing the desired claims. Note that 485 white space is explicitly allowed in the representation and no 486 canonicalization is performed before encoding. 488 2. Let the Message be the bytes of the UTF-8 representation of the 489 JWT Claims Set. 491 3. Create a JWT Header containing the desired set of header 492 parameters. If the JWT is to be signed or encrypted, they MUST 493 conform to either the [JWS] or [JWE] specifications, 494 respectively. Else, if the JWT is to be plaintext, the "alg" 495 value "none" MUST be used. Note that white space is explicitly 496 allowed in the representation and no canonicalization is 497 performed before encoding. 499 4. Base64url encode the bytes of the UTF-8 representation of the JWT 500 Header. Let this be the Encoded JWT Header. 502 5. Depending upon whether the JWT is to be signed, encrypted, or 503 plaintext, there are three cases: 505 * If the JWT is to be signed, create a JWS using the JWT Header 506 as the JWS Header and the Message as the JWS Payload; all 507 steps specified in [JWS] for creating a JWS MUST be followed. 508 Let the JWT Second Part be the Encoded JWS Payload and let the 509 JWT Third Part be the Encoded JWS Signature. 511 * If the JWT is to be encrypted, create a JWE using the JWT 512 Header as the JWE Header and the Message as the JWE Plaintext; 513 all steps specified in [JWE] for creating a JWE MUST be 514 followed. Let the JWT Second Part be the Encoded JWE 515 Encrypted Key and let the JWT Third Part be the Encoded JWS 516 Ciphertext. 518 * Else, if the JWT is to be plaintext, let the JWT Second Part 519 be the base64url encoding of the Message and let the JWT Third 520 Part be the empty string. 522 6. Concatenate the Encoded JWT Header, the JWT Second Part, and the 523 JWT Third Part in that order, separating each by period ('.') 524 characters. 526 7. If a nested signing or encryption operation will be performed, 527 let the Message be this concatenation, and return to Step 3, 528 using a "typ" value of either "JWS" or "JWE" respectively in the 529 new JWT Header created in that step. 531 8. Otherwise, let the resulting JWT be this concatenation. 533 When validating a JWT the following steps MUST be taken. If any of 534 the listed steps fails then the token MUST be rejected for 535 processing. 537 1. The JWT MUST contain exactly two period characters. 539 2. The JWT MUST be split on the two period characters resulting in 540 three strings. The first string is the Encoded JWT Header; the 541 second is the JWT Second Part; the third is the JWT Third Part. 543 3. The Encoded JWT Header MUST be successfully base64url decoded 544 following the restriction given in this specification that no 545 padding characters have been used. 547 4. The JWT Header MUST be completely valid JSON syntax conforming 548 to RFC 4627 [RFC4627]. 550 5. The JWT Header MUST be validated to only include parameters and 551 values whose syntax and semantics are both understood and 552 supported. 554 6. Determine whether the JWT is signed, encrypted, or plaintext by 555 examining the "alg" (algorithm) header value and optionally, the 556 "enc" (encryption method) header value, if present. 558 7. Depending upon whether the JWT signed, encrypted, or plaintext, 559 there are three cases: 561 * If the JWT is signed, all steps specified in [JWS] for 562 validating a JWS MUST be followed. Let the Message be the 563 result of base64url decoding the JWS Payload. 565 * If the JWT is encrypted, all steps specified in [JWE] for 566 validating a JWE MUST be followed. Let the Message be the 567 JWE Plaintext. 569 * Else, if the JWT is plaintext, let the Message be the result 570 of base64url decoding the JWE Second Part. The Third Part 571 MUST be verified to be the empty string. 573 8. If the JWT Header contains a "typ" value of either "JWS" or 574 "JWE", then the Message contains a JWT that was the subject of 575 nested signing or encryption operations, respectively. In this 576 case, return to Step 1, using the Message as the JWT. 578 9. Otherwise, let the JWT Claims Set be the Message. 580 10. The JWT Claims Set MUST be completely valid JSON syntax 581 conforming to RFC 4627 [RFC4627]. 583 11. When used in a security-related context, the JWT Claims Set MUST 584 be validated to only include claims whose syntax and semantics 585 are both understood and supported. 587 Processing a JWT inevitably requires comparing known strings to 588 values in the token. For example, in checking what the algorithm is, 589 the Unicode string encoding "alg" will be checked against the member 590 names in the JWT Header to see if there is a matching header 591 parameter name. A similar process occurs when determining if the 592 value of the "alg" header parameter represents a supported algorithm. 594 Comparisons between JSON strings and other Unicode strings MUST be 595 performed as specified below: 597 1. Remove any JSON applied escaping to produce an array of Unicode 598 code points. 600 2. Unicode Normalization [USA15] MUST NOT be applied at any point to 601 either the JSON string or to the string it is to be compared 602 against. 604 3. Comparisons between the two strings MUST be performed as a 605 Unicode code point to code point equality comparison. 607 8. Cryptographic Algorithms 609 JWTs use JSON Web Signature (JWS) [JWS] and JSON Web Encryption (JWE) 610 [JWE] to sign and/or encrypt the contents of the JWT. 612 Of the JWS signing algorithms, only HMAC SHA-256 MUST be implemented 613 by conforming JWT implementations. It is RECOMMENDED that 614 implementations also support the RSA SHA-256 and ECDSA P-256 SHA-256 615 algorithms. Support for other algorithms and key sizes is OPTIONAL. 617 If an implementation provides encryption capabilities, of the JWE 618 encryption algorithms, only RSA-PKCS1-1.5 with 2048 bit keys, AES- 619 128-CBC, and AES-256-CBC MUST be implemented by conforming 620 implementations. It is RECOMMENDED that implementations also support 621 ECDH-ES with 256 bit keys, AES-128-GCM, and AES-256-GCM. Support for 622 other algorithms and key sizes is OPTIONAL. 624 9. IANA Considerations 626 This specification calls for: 628 o A new IANA registry entitled "JSON Web Token Claims" for reserved 629 claim names is defined in Section 4.1. Inclusion in the registry 630 is RFC Required in the RFC 5226 [RFC5226] sense for reserved JWT 631 claim names that are intended to be interoperable between 632 implementations. The registry will just record the reserved claim 633 name and a pointer to the RFC that defines it. This specification 634 defines inclusion of the claim names defined in Table 1. 636 10. Security Considerations 638 TBD: Lots of work to do here. We need to remember to look into any 639 issues relating to security and JSON parsing. One wonders just how 640 secure most JSON parsing libraries are. Were they ever hardened for 641 security scenarios? If not, what kind of holes does that open up? 642 Also, we need to walk through the JSON standard and see what kind of 643 issues we have especially around comparison of names. For instance, 644 comparisons of claim names and other parameters must occur after they 645 are unescaped. Need to also put in text about: Importance of keeping 646 secrets secret. Rotating keys. Strengths and weaknesses of the 647 different algorithms. 649 TBD: Need to put in text about why strict JSON validation is 650 necessary. Basically, that if malformed JSON is received then the 651 intent of the sender is impossible to reliably discern. One example 652 of malformed JSON that MUST be rejected is an object in which the 653 same member name occurs multiple times. While in non-security 654 contexts it's o.k. to be generous in what one accepts, in security 655 contexts this can lead to serious security holes. For example, 656 malformed JSON might indicate that someone has managed to find a 657 security hole in the issuer's code and is leveraging it to get the 658 issuer to issue "bad" tokens whose content the attacker can control. 660 TBD: Write about the need to secure the token content if a signature 661 is not contained in the JWT itself. 663 10.1. Unicode Comparison Security Issues 665 Claim names in JWTs are Unicode strings. For security reasons, the 666 representations of these names must be compared verbatim after 667 performing any escape processing (as per RFC 4627 [RFC4627], Section 668 2.5). 670 This means, for instance, that these JSON strings must compare as 671 being equal ("JWT", "\u004aWT"), whereas these must all compare as 672 being not equal to the first set or to each other ("jwt", "Jwt", 673 "JW\u0074"). 675 JSON strings MAY contain characters outside the Unicode Basic 676 Multilingual Plane. For instance, the G clef character (U+1D11E) may 677 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWT 678 implementations SHOULD ensure that characters outside the Basic 679 Multilingual Plane are preserved and compared correctly; 680 alternatively, if this is not possible due to these characters 681 exercising limitations present in the underlying JSON implementation, 682 then input containing them MUST be rejected. 684 11. Open Issues and Things To Be Done (TBD) 686 The following items remain to be done in this draft: 688 o Provide an example of an encrypted JWT. 690 o Clarify the optional ability to provide type information for JWTs 691 and/or their parts. Specifically, clarify whether we need to 692 specify the "typ" Claim Name in addition to the Header Parameter, 693 whether it conveys syntax or semantics, and indeed, whether this 694 is the right approach. Also clarify the relationship between 695 these type values and MIME [RFC2045] types (if any). 697 o Think about how to best describe the concept currently described 698 as "the bytes of the UTF-8 representation of". Possible terms to 699 use instead of "bytes of" include "byte sequence", "octet series", 700 and "octet sequence". Also consider whether we want to add an 701 overall clarifying statement somewhere in each spec something like 702 "every place we say 'the UTF-8 representation of X', we mean 'the 703 bytes of the UTF-8 representation of X'". That would potentially 704 allow us to omit the "the bytes of" part everywhere else. 706 o Consider whether a media type should be proposed, such as 707 "application/jwt". 709 o Finish the Security Considerations section. 711 o Possibly write a companion specification that contains the former 712 JWT JSON Serialization. 714 12. References 716 12.1. Normative References 718 [JWS] Jones, M., Balfanz, D., Bradley, J., Goland, Y., Panzer, 719 J., Sakimura, N., and P. Tarjan, "JSON Web Signature 720 (JWS)", December 2011. 722 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 723 Extensions (MIME) Part One: Format of Internet Message 724 Bodies", RFC 2045, November 1996. 726 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 727 Requirement Levels", BCP 14, RFC 2119, March 1997. 729 [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the 730 Internet: Timestamps", RFC 3339, July 2002. 732 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 733 10646", STD 63, RFC 3629, November 2003. 735 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 736 Resource Identifier (URI): Generic Syntax", STD 66, 737 RFC 3986, January 2005. 739 [RFC4627] Crockford, D., "The application/json Media Type for 740 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 742 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 743 Encodings", RFC 4648, October 2006. 745 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 746 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 747 May 2008. 749 [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode 750 Normalization Forms", Unicode Standard Annex 15, 09 2009. 752 12.2. Informative References 754 [CanvasApp] 755 Facebook, "Canvas Applications", 2010. 757 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 758 September 2010. 760 [JWE] Jones, M., Rescorla, E., and J. Hildebrand, "JSON Web 761 Encryption (JWE)", December 2011. 763 [MagicSignatures] 764 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 765 Signatures", August 2010. 767 [OASIS.saml-core-2.0-os] 768 Cantor, S., Kemp, J., Philpott, R., and E. Maler, 769 "Assertions and Protocol for the OASIS Security Assertion 770 Markup Language (SAML) V2.0", OASIS Standard saml-core- 771 2.0-os, March 2005. 773 [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup 774 Language) XML-Signature Syntax and Processing", RFC 3275, 775 March 2002. 777 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 778 Unique IDentifier (UUID) URN Namespace", RFC 4122, 779 July 2005. 781 [SWT] Hardt, D. and Y. Goland, "Simple Web Token (SWT)", 782 Version 0.9.5.1, November 2009. 784 [W3C.CR-xml11-20021015] 785 Cowan, J., "Extensible Markup Language (XML) 1.1", W3C 786 CR CR-xml11-20021015, October 2002. 788 Appendix A. Relationship of JWTs to SAML Tokens 790 SAML 2.0 [OASIS.saml-core-2.0-os] provides a standard for creating 791 tokens with much greater expressivity and more security options than 792 supported by JWTs. However, the cost of this flexibility and 793 expressiveness is both size and complexity. In addition, SAML's use 794 of XML [W3C.CR-xml11-20021015] and XML DSIG [RFC3275] only 795 contributes to the size of SAML tokens. 797 JWTs are intended to provide a simple token format that is small 798 enough to fit into HTTP headers and query arguments in URIs. It does 799 this by supporting a much simpler token model than SAML and using the 800 JSON [RFC4627] object encoding syntax. It also supports securing 801 tokens using Hash-based Message Authentication Codes (HMACs) and 802 digital signatures using a smaller (and less flexible) format than 803 XML DSIG. 805 Therefore, while JWTs can do some of the things SAML tokens do, JWTs 806 are not intended as a full replacement for SAML tokens, but rather as 807 a compromise token format to be used when space is at a premium. 809 Appendix B. Relationship of JWTs to Simple Web Tokens (SWTs) 811 Both JWTs and Simple Web Tokens SWT [SWT], at their core, enable sets 812 of claims to be communicated between applications. For SWTs, both 813 the claim names and claim values are strings. For JWTs, while claim 814 names are strings, claim values can be any JSON type. Both token 815 types offer cryptographic protection of their content: SWTs with HMAC 816 SHA-256 and JWTs with a choice of algorithms, including HMAC SHA-256, 817 RSA SHA-256, and ECDSA P-256 SHA-256. 819 Appendix C. Acknowledgements 821 The authors acknowledge that the design of JWTs was intentionally 822 influenced by the design and simplicity of Simple Web Tokens [SWT] 823 and ideas for JSON tokens that Dick Hardt discussed within the OpenID 824 community. 826 Solutions for signing JSON content were previously explored by Magic 827 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 828 Applications [CanvasApp], all of which influenced this draft. 830 Appendix D. Document History 832 -07 834 o Defined the "prn" (principal) claim to identify the subject of the 835 JWT. 837 o Defined the "jti" (JWT ID) claim to enable replay protection. 839 o Use the term "JWT Claims Set" rather than "JWT Claims Object" 840 since this is actually a string representing a JSON object and not 841 the JSON object itself. 843 o Moved "MUST" requirements from the Overview to later in the spec. 845 o Respect line length restrictions in examples. 847 o Applied other editorial improvements. 849 -06 851 o Reference and use content from [JWS] and [JWE], rather than 852 repeating it here. 854 o Simplified terminology to better match JWE, where the terms "JWT 855 Header" and "Encoded JWT Header" are now used, for instance, 856 rather than the previous terms "Decoded JWT Header Segment" and 857 "JWT Header Segment". Also changed to "Plaintext JWT" from 858 "Unsigned JWT". 860 o Describe how to perform nested encryption and signing operations. 862 o Changed "integer" to "number", since that is the correct JSON 863 type. 865 o Changed StringAndURI to StringOrURI. 867 -05 869 o Added the "nbf" (not before) claim and clarified the meaning of 870 the "iat" (issued at) claim. 872 -04 874 o Correct typo found by John Bradley: "the JWT Claim Segment is the 875 empty string" -> "the JWT Crypto Segment is the empty string". 877 -03 878 o Added "http://openid.net/specs/jwt/1.0" as a token type identifier 879 URI for JWTs. 881 o Added "iat" (issued at) claim. 883 o Changed RSA SHA-256 from MUST be supported to RECOMMENDED that it 884 be supported. Rationale: Several people have objected to the 885 requirement for implementing RSA SHA-256, some because they will 886 only be using HMACs and symmetric keys, and others because they 887 only want to use ECDSA when using asymmetric keys, either for 888 security or key length reasons, or both. 890 o Defined "alg" value "none" to represent unsigned JWTs. 892 -02 894 o Split signature specification out into separate 895 draft-jones-json-web-signature-00. This split introduced no 896 semantic changes. 898 o The JWT Compact Serialization is now the only token serialization 899 format specified in this draft. The JWT JSON Serialization can 900 continue to be defined in a companion specification. 902 -01 904 o Draft incorporating consensus decisions reached at IIW. 906 -00 908 o Public draft published before November 2010 IIW based upon the 909 JSON token convergence proposal incorporating input from several 910 implementers of related specifications. 912 Authors' Addresses 914 Michael B. Jones 915 Microsoft 917 Email: mbj@microsoft.com 918 URI: http://self-issued.info/ 919 Dirk Balfanz 920 Google 922 Email: balfanz@google.com 924 John Bradley 925 independent 927 Email: ve7jtb@ve7jtb.com 929 Yaron Y. Goland 930 Microsoft 932 Email: yarong@microsoft.com 934 John Panzer 935 Google 937 Email: jpanzer@google.com 939 Nat Sakimura 940 Nomura Research Institute 942 Email: n-sakimura@nri.co.jp 944 Paul Tarjan 945 Facebook 947 Email: pt@fb.com