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