-
Notifications
You must be signed in to change notification settings - Fork 2
/
rfc7519.xml
1978 lines (1822 loc) · 68.6 KB
/
rfc7519.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>
<?rfc rfcedstyle="yes"?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" number="7519" submissionType="IETF" consensus="yes">
<front>
<title>JSON Web Token (JWT)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>[email protected]</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<author fullname="John Bradley" initials="J." surname="Bradley">
<organization abbrev="Ping Identity">Ping Identity</organization>
<address>
<email>[email protected]</email>
<uri>http://www.thread-safe.com/</uri>
</address>
</author>
<author fullname="Nat Sakimura" initials="N." surname="Sakimura">
<organization abbrev="NRI">Nomura Research Institute</organization>
<address>
<email>[email protected]</email>
<uri>http://nat.sakimura.org/</uri>
</address>
</author>
<date month="May" year="2015"/>
<area>Security</area>
<workgroup>OAuth Working Group</workgroup>
<keyword>Assertion</keyword>
<keyword>Claim</keyword>
<keyword>Security Token</keyword>
<keyword>JavaScript Object Notation</keyword>
<keyword>JSON</keyword>
<keyword>JSON Web Token</keyword>
<keyword>JWT</keyword>
<keyword>JSON Object Signing and Encryption</keyword>
<keyword>JOSE</keyword>
<keyword>JSON Web Signature</keyword>
<keyword>JWS</keyword>
<keyword>JSON Web Encryption</keyword>
<keyword>JWE</keyword>
<keyword>JSON Web Key</keyword>
<keyword>JWK</keyword>
<keyword>JSON Web Algorithms</keyword>
<keyword>JWA</keyword>
<abstract>
<t>
JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be
transferred between two parties. The claims in a JWT are
encoded as a JSON object that is
used as the payload of a JSON Web Signature (JWS) structure
or as the plaintext of a JSON Web Encryption (JWE) structure,
enabling the claims to be digitally signed or
integrity protected with a Message Authentication Code (MAC)
and/or encrypted.
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="Introduction">
<t>
JSON Web Token (JWT) is a compact claims representation format intended for
space constrained environments such as HTTP Authorization headers
and URI query parameters.
JWTs encode claims to be transmitted as a
JSON <xref target="RFC7159"/> object that is
used as the payload of a JSON Web Signature (JWS) <xref target="JWS"/> structure
or as the plaintext of a JSON Web Encryption (JWE) <xref target="JWE"/> structure,
enabling the claims to be digitally signed or
integrity protected with a Message Authentication Code (MAC)
and/or encrypted.
JWTs are always represented using the JWS Compact Serialization
or the JWE Compact Serialization.
</t>
<t>
The suggested pronunciation of JWT is the same as the English
word "jot".
</t>
<section title="Notational Conventions" anchor="NotationalConventions">
<t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY",
and "OPTIONAL" in this document are to be interpreted as
described in
"Key words for use in RFCs to Indicate Requirement Levels" <xref target='RFC2119' />.
The interpretation should only be applied when the terms appear in all capital letters.
</t>
</section>
</section>
<section title="Terminology" anchor="Terminology">
<t>
The terms
"JSON Web Signature (JWS)",
"Base64url Encoding",
"Header Parameter",
"JOSE Header",
"JWS Compact Serialization",
"JWS Payload",
"JWS Signature",
and "Unsecured JWS" are defined by
the JWS specification <xref target="JWS"/>.
</t>
<t>
The terms
"JSON Web Encryption (JWE)",
"Content Encryption Key (CEK)",
"JWE Compact Serialization",
"JWE Encrypted Key",
and "JWE Initialization Vector"
are defined by
the JWE specification <xref target="JWE"/>.
</t>
<t>
The terms
"Ciphertext",
"Digital Signature",
"Message Authentication Code (MAC)",
and "Plaintext" are defined by
the <xref target="RFC4949">"Internet Security Glossary, Version 2"</xref>.
</t>
<t>
These terms are defined by this specification:
</t>
<t>
<list style="hanging">
<t hangText="JSON Web Token (JWT)">
<vspace/>
A string representing a set of claims as a JSON object that is
encoded in a JWS or JWE,
enabling the claims to be digitally signed or MACed and/or encrypted.
</t>
<t hangText="JWT Claims Set">
<vspace/>
A JSON object that
contains the claims conveyed by the JWT.
</t>
<t hangText="Claim">
<vspace/>
A piece of information asserted about a subject.
A claim is represented as a name/value pair
consisting of a Claim Name and a Claim Value.
</t>
<t hangText="Claim Name">
<vspace/>
The name portion of a claim representation.
A Claim Name is always a string.
</t>
<t hangText="Claim Value">
<vspace/>
The value portion of a claim representation.
A Claim Value can be any JSON value.
</t>
<t hangText="Nested JWT">
<vspace/>
A JWT in which nested signing and/or encryption are employed.
In Nested JWTs, a JWT is used as the payload or plaintext value
of an enclosing JWS or JWE structure, respectively.
</t>
<t hangText="Unsecured JWT">
<vspace/>
A JWT whose claims are not integrity protected or encrypted.
</t>
<t hangText="Collision-Resistant Name">
<vspace/>
A name in a namespace that enables names to be allocated in a manner
such that they are highly unlikely to collide with other names.
Examples of collision-resistant namespaces include:
Domain Names,
Object Identifiers (OIDs) as defined in the ITU-T X.660
and X.670 Recommendation series, and
Universally Unique IDentifiers (UUIDs)
<xref target="RFC4122"/>.
When using an administratively delegated namespace,
the definer of a name needs to take
reasonable precautions to ensure they are in control of
the portion of the namespace they use to define the name.
</t>
<t hangText="StringOrURI">
<vspace/>
A JSON string value, with the additional requirement that
while arbitrary string values MAY be used, any value
containing a ":" character MUST be a URI
<xref target="RFC3986"/>.
StringOrURI values are compared as case-sensitive strings
with no transformations or canonicalizations applied.
</t>
<t hangText="NumericDate">
<vspace/>
A JSON numeric value representing the number of seconds
from 1970-01-01T00:00:00Z UTC until the specified UTC date/time,
ignoring leap seconds.
This is equivalent to the
<xref target="POSIX.1">IEEE Std 1003.1, 2013 Edition</xref>
definition "Seconds Since the Epoch",
in which each day is accounted for by exactly 86400 seconds,
other than that non-integer values can be represented.
See <xref target="RFC3339">RFC 3339</xref> for details
regarding date/times in general and UTC in particular.
</t>
</list>
</t>
</section>
<section title="JSON Web Token (JWT) Overview" anchor="Overview">
<t>
JWTs represent a set of claims as a JSON object that is
encoded in a JWS and/or JWE structure.
This JSON object is the JWT Claims Set.
As per Section 4 of <xref target="RFC7159">RFC 7159</xref>,
the JSON object consists of zero or more
name/value pairs (or members), where the names are strings and
the values are arbitrary JSON values.
These members are the claims represented by the JWT.
This JSON object MAY contain whitespace and/or line breaks
before or after any JSON values or structural characters,
in accordance with Section 2 of <xref target="RFC7159">RFC 7159</xref>.
</t>
<t>
The member names within the JWT Claims Set are
referred to as Claim Names. The
corresponding values are referred to as Claim Values.
</t>
<t>
The contents of the JOSE Header describe the cryptographic
operations applied to the JWT Claims Set.
If the JOSE Header is for a JWS, the JWT is represented as a JWS
and the claims are digitally signed or MACed,
with the JWT Claims Set being the JWS Payload.
If the JOSE Header is for a JWE, the JWT is represented as a JWE
and the claims are encrypted,
with the JWT Claims Set being the plaintext encrypted by the JWE.
A JWT may be enclosed in another JWE or JWS structure
to create a Nested JWT,
enabling nested signing and encryption to be performed.
</t>
<t>
A JWT is represented as a sequence of URL-safe parts
separated by period ('.') characters.
Each part contains a base64url-encoded value.
The number of parts in the JWT is dependent upon
the representation of the resulting
JWS using the JWS Compact Serialization or
JWE using the JWE Compact Serialization.
</t>
<section title="Example JWT" anchor="ExampleJWT">
<t>
The following example JOSE Header declares that the
encoded object is a JWT, and the JWT is
a JWS that is MACed using the HMAC SHA-256 algorithm:
</t>
<figure><artwork><![CDATA[
{"typ":"JWT",
"alg":"HS256"}
]]></artwork></figure>
<t>
To remove potential ambiguities in the representation of the JSON object above,
the octet sequence for the actual UTF-8 representation used in this example
for the JOSE Header above
is also included below.
(Note that ambiguities can arise due to
differing platform representations of line breaks (CRLF versus LF),
differing spacing at the beginning and ends of lines,
whether the last line has a terminating line break or not,
and other causes.
In the representation used in this example,
the first line has no leading or trailing spaces,
a CRLF line break (13, 10) occurs between the first and second lines,
the second line has one leading space (32) and no trailing spaces,
and the last line does not have a terminating line break.)
The octets representing the UTF-8 representation
of the JOSE Header in this example
(using JSON array notation) are:
</t>
<t>
[123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125]
</t>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JOSE Header yields this encoded JOSE Header value:
</t>
<figure><artwork><![CDATA[
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
]]></artwork></figure>
<t>
The following is an example of a JWT Claims Set:
</t>
<figure><artwork><![CDATA[
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
]]></artwork></figure>
<t>
The following octet sequence, which is the UTF-8 representation
used in this example for the JWT Claims Set above, is the JWS Payload:
</t>
<t>
[123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 111, 116, 34, 58, 116, 114, 117, 101, 125]
</t>
<t>
Base64url encoding the JWS Payload yields this encoded JWS Payload
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly
9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ
]]></artwork></figure>
<t>
Computing the MAC of the encoded JOSE Header and encoded JWS Payload with
the HMAC SHA-256 algorithm and base64url encoding the
HMAC value in the
manner specified in <xref target="JWS" />
yields this encoded JWS Signature:
</t>
<figure><artwork><![CDATA[
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>
<t>
Concatenating these encoded parts in this order
with period ('.') characters between the
parts yields this complete JWT
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>
<t>
This computation is illustrated in more detail in
Appendix A.1 of <xref target="JWS" />.
See <xref target="EncryptedJWTExample"/> for an example of
an encrypted JWT.
</t>
</section>
</section>
<section title="JWT Claims" anchor="Claims">
<t>
The JWT Claims Set represents a JSON object whose members
are the claims conveyed by the JWT.
The Claim Names within a JWT Claims Set MUST be unique;
JWT parsers MUST either reject JWTs with duplicate Claim Names
or use a JSON parser that returns only the lexically last duplicate member name,
as specified in Section 15.12 ("The JSON Object") of
ECMAScript 5.1 <xref target="ECMAScript"/>.
</t>
<t>
The set of claims that a
JWT must contain to be considered valid is context dependent
and is outside the scope of this specification.
Specific applications of JWTs will require implementations
to understand and process some claims in particular ways.
However, in the absence of such requirements, all claims
that are not understood by implementations MUST be ignored.
</t>
<t>
There are three classes of JWT Claim Names:
Registered Claim Names, Public Claim Names, and Private Claim Names.
</t>
<section title="Registered Claim Names" anchor="RegisteredClaimName">
<t>
The following Claim Names are registered
in the IANA
"JSON Web Token Claims" registry
established by
<xref target="JWTClaimsReg"/>.
None of the claims
defined below are intended to be mandatory to use or implement in all cases, but
rather they provide a starting point for a set of useful,
interoperable claims.
Applications using JWTs should define which specific claims they use
and when they are required or optional.
All the names are short because a
core goal of JWTs is for the representation to be compact.
</t>
<section title='"iss" (Issuer) Claim' anchor="issDef">
<t>
The <spanx style="verb">iss</spanx> (issuer) claim
identifies the principal that issued the JWT. The
processing of this claim is generally application
specific.
The <spanx style="verb">iss</spanx> value is a case-sensitive string
containing a StringOrURI value.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"sub" (Subject) Claim' anchor="subDef">
<t>
The <spanx style="verb">sub</spanx> (subject) claim
identifies the principal that is the subject of the JWT.
The claims in a JWT are normally statements about the subject.
The subject value MUST either be scoped to be locally unique
in the context of the issuer or be globally unique.
The processing of this claim is generally application specific.
The <spanx style="verb">sub</spanx> value is a case-sensitive string
containing a StringOrURI value.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"aud" (Audience) Claim' anchor="audDef">
<t>
The <spanx style="verb">aud</spanx> (audience) claim
identifies the recipients that the JWT is intended for.
Each principal intended to process the JWT MUST identify itself
with a value in the audience claim. If the principal
processing the claim does not identify itself with a
value in the <spanx style="verb">aud</spanx> claim when this claim is present,
then the JWT MUST be rejected.
In the general case,
the <spanx style="verb">aud</spanx> value is an array of
case-sensitive strings, each containing a StringOrURI value.
In the special case when the JWT has one audience,
the <spanx style="verb">aud</spanx> value MAY be a single
case-sensitive string containing a StringOrURI value.
The interpretation of audience values is generally application specific.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"exp" (Expiration Time) Claim' anchor="expDef">
<t>
The <spanx style="verb">exp</spanx> (expiration time)
claim identifies the expiration time on or after which the
JWT MUST NOT be accepted for processing. The processing
of the <spanx style="verb">exp</spanx> claim requires that
the current date/time MUST be before the expiration
date/time listed in the <spanx style="verb">exp</spanx>
claim. Implementers MAY provide for some small leeway,
usually no more than a few minutes, to account for clock skew.
Its value MUST be a number containing a NumericDate value.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"nbf" (Not Before) Claim' anchor="nbfDef">
<t>
The <spanx style="verb">nbf</spanx> (not before) claim
identifies the time before which the JWT MUST NOT be
accepted for processing. The processing of the <spanx
style="verb">nbf</spanx> claim requires that the current
date/time MUST be after or equal to the not-before
date/time listed in the <spanx style="verb">nbf</spanx>
claim. Implementers MAY provide for some small leeway,
usually no more than a few minutes, to account for clock skew.
Its value MUST be a number containing a NumericDate value.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"iat" (Issued At) Claim' anchor="iatDef">
<t>
The <spanx style="verb">iat</spanx> (issued at) claim
identifies the time at which the JWT was issued. This
claim can be used to determine the age of the JWT.
Its value MUST be a number containing a NumericDate value.
Use of this claim is OPTIONAL.
</t>
</section>
<section title='"jti" (JWT ID) Claim' anchor="jtiDef">
<t>
The <spanx style="verb">jti</spanx> (JWT ID) claim
provides a unique identifier for the JWT. The identifier
value MUST be assigned in a manner that ensures that there
is a negligible probability that the same value will be
accidentally assigned to a different data object;
if the application uses multiple issuers, collisions MUST be prevented
among values produced by different issuers as well.
The <spanx style="verb">jti</spanx> claim can be used to
prevent the JWT from being replayed.
The <spanx style="verb">jti</spanx> value is a case-sensitive string.
Use of this claim is OPTIONAL.
</t>
</section>
</section>
<section title="Public Claim Names" anchor="PublicClaimName">
<t>
Claim Names can be defined at will by those using
JWTs. However, in order to prevent collisions, any new
Claim Name should either be registered in the IANA
"JSON Web Token Claims" registry
established by
<xref target="JWTClaimsReg" />
or be a Public Name:
a value that contains a Collision-Resistant Name.
In each case, the definer of the name
or value needs to take reasonable precautions to make sure they
are in control of the part of the namespace they use to
define the Claim Name.
</t>
</section>
<section title="Private Claim Names" anchor="PrivateClaimName">
<t>
A producer and consumer of a JWT MAY agree to use Claim Names
that are Private Names: names that are
not Registered Claim Names (<xref target="RegisteredClaimName"/>)
or Public Claim Names (<xref target="PublicClaimName"/>).
Unlike Public Claim Names, Private Claim Names are subject to collision and
should be used with caution.
</t>
</section>
</section>
<section title="JOSE Header" anchor="Header">
<t>
For a JWT object,
the members of the JSON object represented by the JOSE Header
describe the cryptographic operations applied to the JWT and
optionally, additional properties of the JWT.
Depending upon whether the JWT is a JWS or JWE,
the corresponding rules for the JOSE Header values apply.
</t>
<t>
This specification further specifies the use of the following
Header Parameters in both the cases where the JWT is a JWS and
where it is a JWE.
</t>
<section title='"typ" (Type) Header Parameter' anchor="typHdrDef">
<t>
The <spanx style="verb">typ</spanx> (type) Header Parameter
defined by <xref target="JWS" /> and <xref target="JWE" />
is used by JWT applications to declare the
media type <xref target="IANA.MediaTypes"/>
of this complete JWT.
This is intended for use by the JWT application when
values that are not JWTs could also be present in
an application data structure that can contain a JWT object;
the application can use this value to disambiguate among
the different kinds of objects that might be present.
It will typically not be used by applications when
it is already known that the object is a JWT.
This parameter is ignored by JWT implementations;
any processing of this parameter is performed by the JWT application.
If present, it is RECOMMENDED that its value be
<spanx style="verb">JWT</spanx>
to indicate that this object is a JWT.
While media type names are not case sensitive,
it is RECOMMENDED that <spanx style="verb">JWT</spanx>
always be spelled using uppercase characters
for compatibility with legacy implementations.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"cty" (Content Type) Header Parameter' anchor="ctyHdrDef">
<t>
The <spanx style="verb">cty</spanx> (content type) Header Parameter
defined by <xref target="JWS" /> and <xref target="JWE" />
is used by this specification
to convey structural information about the JWT.
</t>
<t>
In the normal case in which nested signing or encryption
operations are not employed, the use of this Header Parameter
is NOT RECOMMENDED.
In the case that nested signing or encryption is
employed, this Header Parameter MUST be present; in
this case, the value MUST be <spanx style="verb">JWT</spanx>, to indicate that
a Nested JWT is carried in this JWT.
While media type names are not case sensitive,
it is RECOMMENDED that <spanx style="verb">JWT</spanx>
always be spelled using uppercase characters
for compatibility with legacy implementations.
See <xref target="NestedJWTExample"/> for an example of a Nested JWT.
</t>
</section>
<section title="Replicating Claims as Header Parameters" anchor="ClaimsAsHeaders">
<t>
In some applications using encrypted JWTs, it is useful to
have an unencrypted representation of some claims.
This might be used, for instance, in application processing rules
to determine whether and how to process the JWT before
it is decrypted.
</t>
<t>
This specification allows claims present in the JWT Claims Set
to be replicated as Header Parameters in a JWT that is a JWE,
as needed by the application.
If such replicated claims are present, the application receiving them
SHOULD verify that their values are identical,
unless the application defines other specific processing rules for these claims.
It is the responsibility of the application to ensure that
only claims that are safe to be transmitted in an unencrypted manner
are replicated as Header Parameter values in the JWT.
</t>
<t>
<xref target="HdrContents"/> of this specification registers the
<spanx style="verb">iss</spanx> (issuer),
<spanx style="verb">sub</spanx> (subject), and
<spanx style="verb">aud</spanx> (audience)
Header Parameter names for the purpose of
providing unencrypted replicas of these claims in encrypted JWTs
for applications that need them.
Other specifications MAY similarly register other names
that are registered Claim Names as Header Parameter names, as needed.
</t>
</section>
</section>
<section title="Unsecured JWTs" anchor="UnsecuredJWT">
<t>
To support use cases in which the JWT content is secured by a
means other than a signature and/or encryption contained
within the JWT (such as a signature on a data structure
containing the JWT), JWTs MAY also be created without a
signature or encryption. An Unsecured JWT is a JWS using the
<spanx style="verb">alg</spanx> Header Parameter value
<spanx style="verb">none</spanx> and
with the empty string for its JWS Signature value,
as defined in the JWA specification <xref target="JWA"/>;
it is an Unsecured JWS with the JWT Claims Set as its JWS Payload.
</t>
<section title="Example Unsecured JWT" anchor="ExampleUnsecuredJWT">
<t>
The following example JOSE Header declares that the
encoded object is an Unsecured JWT:
</t>
<figure><artwork><![CDATA[
{"alg":"none"}
]]></artwork></figure>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JOSE Header yields this encoded JOSE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJub25lIn0
]]></artwork></figure>
<t>
The following is an example of a JWT Claims Set:
</t>
<figure><artwork><![CDATA[
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
]]></artwork></figure>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWT Claims Set yields this encoded JWS Payload
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
]]></artwork></figure>
<t>
The encoded JWS Signature is the empty string.
</t>
<t>
Concatenating these encoded parts in this order
with period ('.') characters between the
parts yields this complete JWT
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJub25lIn0
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
]]></artwork></figure>
</section>
</section>
<section title="Creating and Validating JWTs" anchor="JWTRules">
<section title="Creating a JWT" anchor="Creating">
<t>
To create a JWT, the following steps are performed.
The order of the steps is not significant in cases where
there are no dependencies between the inputs and outputs of the steps.
<list style="numbers">
<t>
Create a JWT Claims Set containing the desired claims.
Note that whitespace is explicitly allowed in the
representation and no canonicalization need be performed before
encoding.
</t>
<t>
Let the Message be the octets of the UTF-8 representation
of the JWT Claims Set.
</t>
<t>
Create a JOSE Header containing the desired set of Header Parameters.
The JWT
MUST conform to either the <xref target="JWS" /> or <xref
target="JWE" /> specification.
Note that whitespace
is explicitly allowed in the representation and no
canonicalization need be performed before encoding.
</t>
<t>
Depending upon whether the JWT is a JWS or JWE,
there are two cases:
<list style='symbols'>
<t>
If the JWT is a JWS, create a JWS using
the Message as the JWS Payload;
all steps specified in <xref target="JWS" />
for creating a JWS MUST be followed.
</t>
<t>
Else, if the JWT is a JWE, create a JWE using
the Message as the plaintext for the JWE;
all steps specified in <xref target="JWE" />
for creating a JWE MUST be followed.
</t>
</list>
</t>
<t>
If a nested signing or encryption operation will be
performed, let the Message be the JWS or JWE, and
return to Step 3, using a <spanx style="verb">cty</spanx> (content type)
value of <spanx style="verb">JWT</spanx>
in the new JOSE Header created in that step.
</t>
<t>
Otherwise, let the resulting JWT be the JWS or JWE.
</t>
</list>
</t>
</section>
<section title="Validating a JWT" anchor="Validating">
<t>
When validating a JWT, the following steps are performed.
The order of the steps is not significant in cases where
there are no dependencies between the inputs and outputs of the steps.
If any of the listed steps fail, then the JWT MUST be rejected
-- that is, treated by the application as an invalid input.
</t>
<t>
<list style="numbers">
<t>
Verify that the JWT contains at least one period ('.') character.
</t>
<t>
Let the Encoded JOSE Header be the portion of the JWT
before the first period ('.') character.
</t>
<t>
Base64url decode the Encoded JOSE Header
following the restriction that no line breaks, whitespace, or other additional characters have been used.
</t>
<t>
Verify that the resulting octet sequence
is a UTF-8-encoded representation of
a completely valid JSON object
conforming to <xref target="RFC7159">RFC 7159</xref>;
let the JOSE Header be this JSON object.
</t>
<t>
Verify that the resulting JOSE Header includes only
parameters and values whose syntax and semantics are both
understood and supported
or that are specified as being ignored when not understood.
</t>
<t>
Determine whether the JWT is a JWS or a JWE
using any of the methods described in
Section 9 of <xref target="JWE"/>.
</t>
<t>
Depending upon whether the JWT is a JWS or JWE,
there are two cases:
<list style='symbols'>
<t>
If the JWT is a JWS, follow the steps specified in
<xref target="JWS" /> for validating a JWS.
Let the Message be the result of base64url decoding
the JWS Payload.
</t>
<t>
Else, if the JWT is a JWE, follow the steps specified in
<xref target="JWE" /> for validating a JWE.
Let the Message be the resulting plaintext.
</t>
</list>
</t>
<t>
If the JOSE Header contains a <spanx style="verb">cty</spanx> (content type)
value of <spanx style="verb">JWT</spanx>,
then the Message is a JWT that was the subject of
nested signing or encryption operations. In
this case, return to Step 1, using the Message as the JWT.
</t>
<t>
Otherwise, base64url decode the Message
following the restriction that no line breaks, whitespace, or other additional characters have been used.
</t>
<t>
Verify that the resulting octet sequence
is a UTF-8-encoded representation of
a completely valid JSON object
conforming to <xref target="RFC7159">RFC 7159</xref>;
let the JWT Claims Set be this JSON object.
</t>
</list>
</t>
<t>
Finally, note that it is an application decision which algorithms
may be used in a given context.
Even if a JWT can be successfully validated,
unless the algorithms used in the JWT are acceptable
to the application, it SHOULD reject the JWT.
</t>
</section>
<section title="String Comparison Rules" anchor="StringComparison">
<t>
Processing a JWT inevitably requires comparing known strings
to members and values in JSON objects. For example, in checking what the
algorithm is, the Unicode <xref target="UNICODE"/> string encoding
<spanx style="verb">alg</spanx> will be
checked against the member names in the JOSE Header
to see if there is a matching Header Parameter name.
</t>
<t>
The JSON rules for doing member name comparison are described in
Section 8.3 of <xref target="RFC7159">RFC 7159</xref>.
Since the only string comparison operations that are performed are
equality and inequality, the same rules can be used for comparing
both member names and member values against known strings.
</t>
<t>
These comparison rules MUST be used for all JSON string comparisons
except in cases where the definition of the member explicitly calls out that
a different comparison rule is to be used for that member value.
In this specification, only the <spanx style="verb">typ</spanx> and
<spanx style="verb">cty</spanx> member values do not use these comparison rules.
</t>
<t>
Some applications may include case-insensitive information in
a case-sensitive value, such as including a DNS name as part of
the <spanx style="verb">iss</spanx> (issuer) claim value.
In those cases, the application may need to define a convention
for the canonical case to use for representing the case-insensitive portions,
such as lowercasing them, if more than one party might need to
produce the same value so that they can be compared.
(However, if all other parties consume whatever value the producing party
emitted verbatim without attempting to compare it to an independently produced
value, then the case used by the producer will not matter.)
</t>
</section>
</section>
<section title="Implementation Requirements" anchor="ImplementationRequirements">
<t>
This section defines which algorithms and features of this specification
are mandatory to implement.
Applications using this specification can impose additional requirements
upon implementations that they use.
For instance, one application might require support for encrypted JWTs and Nested JWTs,
while another might require support for signing JWTs with the
Elliptic Curve Digital Signature Algorithm (ECDSA) using the P-256 curve and the SHA-256 hash algorithm
(<spanx style="verb">ES256</spanx>).
</t>
<t>
Of the signature and MAC algorithms specified in
JSON Web Algorithms <xref target="JWA"/>, only
HMAC SHA-256
(<spanx style="verb">HS256</spanx>) and
<spanx style="verb">none</spanx>
MUST be implemented by conforming JWT implementations.
It is RECOMMENDED that implementations also support
RSASSA-PKCS1-v1_5 with the SHA-256 hash algorithm
(<spanx style="verb">RS256</spanx>) and
ECDSA using the P-256 curve and the SHA-256 hash algorithm
(<spanx style="verb">ES256</spanx>).
Support for other algorithms and key sizes is OPTIONAL.
</t>
<t>
Support for encrypted JWTs is OPTIONAL.
If an implementation provides encryption capabilities,
of the encryption algorithms specified in
<xref target="JWA"/>, only
RSAES-PKCS1-v1_5 with 2048-bit keys
(<spanx style="verb">RSA1_5</spanx>),
AES Key Wrap with 128- and 256-bit keys
(<spanx style="verb">A128KW</spanx> and <spanx style="verb">A256KW</spanx>), and
the composite authenticated encryption algorithm using AES-CBC and HMAC SHA-2
(<spanx style="verb">A128CBC-HS256</spanx> and <spanx style="verb">A256CBC-HS512</spanx>)
MUST be implemented by conforming implementations.
It is RECOMMENDED that implementations also support using
Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES)
to agree upon a key used to wrap the Content Encryption Key
(<spanx style="verb">ECDH-ES+A128KW</spanx> and <spanx style="verb">ECDH-ES+A256KW</spanx>)
and
AES in Galois/Counter Mode (GCM) with 128- and 256-bit keys
(<spanx style="verb">A128GCM</spanx> and <spanx style="verb">A256GCM</spanx>).
Support for other algorithms and key sizes is OPTIONAL.
</t>
<t>
Support for Nested JWTs is OPTIONAL.
</t>
</section>