-
Notifications
You must be signed in to change notification settings - Fork 0
/
draft-sengul-ace-mqtt-tls-profile-00.html
911 lines (857 loc) · 64.1 KB
/
draft-sengul-ace-mqtt-tls-profile-00.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head profile="http://www.w3.org/2006/03/hcard http://dublincore.org/documents/2008/08/04/dc-html/">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>MQTT-TLS profile of ACE </title>
<style type="text/css" title="Xml2Rfc (sans serif)">
/*<![CDATA[*/
a {
text-decoration: none;
}
/* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
a.info {
/* This is the key. */
position: relative;
z-index: 24;
text-decoration: none;
}
a.info:hover {
z-index: 25;
color: #FFF; background-color: #900;
}
a.info span { display: none; }
a.info:hover span.info {
/* The span will display just on :hover state. */
display: block;
position: absolute;
font-size: smaller;
top: 2em; left: -5em; width: 15em;
padding: 2px; border: 1px solid #333;
color: #900; background-color: #EEE;
text-align: left;
}
a.smpl {
color: black;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
address {
margin-top: 1em;
margin-left: 2em;
font-style: normal;
}
body {
color: black;
font-family: verdana, helvetica, arial, sans-serif;
font-size: 10pt;
max-width: 55em;
}
cite {
font-style: normal;
}
dd {
margin-right: 2em;
}
dl {
margin-left: 2em;
}
ul.empty {
list-style-type: none;
}
ul.empty li {
margin-top: .5em;
}
dl p {
margin-left: 0em;
}
dt {
margin-top: .5em;
}
h1 {
font-size: 14pt;
line-height: 21pt;
page-break-after: avoid;
}
h1.np {
page-break-before: always;
}
h1 a {
color: #333333;
}
h2 {
font-size: 12pt;
line-height: 15pt;
page-break-after: avoid;
}
h3, h4, h5, h6 {
font-size: 10pt;
page-break-after: avoid;
}
h2 a, h3 a, h4 a, h5 a, h6 a {
color: black;
}
img {
margin-left: 3em;
}
li {
margin-left: 2em;
margin-right: 2em;
}
ol {
margin-left: 2em;
margin-right: 2em;
}
ol p {
margin-left: 0em;
}
p {
margin-left: 2em;
margin-right: 2em;
}
pre {
margin-left: 3em;
background-color: lightyellow;
padding: .25em;
}
pre.text2 {
border-style: dotted;
border-width: 1px;
background-color: #f0f0f0;
width: 69em;
}
pre.inline {
background-color: white;
padding: 0em;
}
pre.text {
border-style: dotted;
border-width: 1px;
background-color: #f8f8f8;
width: 69em;
}
pre.drawing {
border-style: solid;
border-width: 1px;
background-color: #f8f8f8;
padding: 2em;
}
table {
margin-left: 2em;
}
table.tt {
vertical-align: top;
}
table.full {
border-style: outset;
border-width: 1px;
}
table.headers {
border-style: outset;
border-width: 1px;
}
table.tt td {
vertical-align: top;
}
table.full td {
border-style: inset;
border-width: 1px;
}
table.tt th {
vertical-align: top;
}
table.full th {
border-style: inset;
border-width: 1px;
}
table.headers th {
border-style: none none inset none;
border-width: 1px;
}
table.left {
margin-right: auto;
}
table.right {
margin-left: auto;
}
table.center {
margin-left: auto;
margin-right: auto;
}
caption {
caption-side: bottom;
font-weight: bold;
font-size: 9pt;
margin-top: .5em;
}
table.header {
border-spacing: 1px;
width: 95%;
font-size: 10pt;
color: white;
}
td.top {
vertical-align: top;
}
td.topnowrap {
vertical-align: top;
white-space: nowrap;
}
table.header td {
background-color: gray;
width: 50%;
}
table.header a {
color: white;
}
td.reference {
vertical-align: top;
white-space: nowrap;
padding-right: 1em;
}
thead {
display:table-header-group;
}
ul.toc, ul.toc ul {
list-style: none;
margin-left: 1.5em;
margin-right: 0em;
padding-left: 0em;
}
ul.toc li {
line-height: 150%;
font-weight: bold;
font-size: 10pt;
margin-left: 0em;
margin-right: 0em;
}
ul.toc li li {
line-height: normal;
font-weight: normal;
font-size: 9pt;
margin-left: 0em;
margin-right: 0em;
}
li.excluded {
font-size: 0pt;
}
ul p {
margin-left: 0em;
}
.comment {
background-color: yellow;
}
.center {
text-align: center;
}
.error {
color: red;
font-style: italic;
font-weight: bold;
}
.figure {
font-weight: bold;
text-align: center;
font-size: 9pt;
}
.filename {
color: #333333;
font-weight: bold;
font-size: 12pt;
line-height: 21pt;
text-align: center;
}
.fn {
font-weight: bold;
}
.hidden {
display: none;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.title {
color: #990000;
font-size: 18pt;
line-height: 18pt;
font-weight: bold;
text-align: center;
margin-top: 36pt;
}
.vcardline {
display: block;
}
.warning {
font-size: 14pt;
background-color: yellow;
}
@media print {
.noprint {
display: none;
}
a {
color: black;
text-decoration: none;
}
table.header {
width: 90%;
}
td.header {
width: 50%;
color: black;
background-color: white;
vertical-align: top;
font-size: 12pt;
}
ul.toc a::after {
content: leader('.') target-counter(attr(href), page);
}
ul.ind li li a {
content: target-counter(attr(href), page);
}
.print2col {
column-count: 2;
-moz-column-count: 2;
column-fill: auto;
}
}
@page {
@top-left {
content: "Internet-Draft";
}
@top-right {
content: "December 2010";
}
@top-center {
content: "Abbreviated Title";
}
@bottom-left {
content: "Doe";
}
@bottom-center {
content: "Expires June 2011";
}
@bottom-right {
content: "[Page " counter(page) "]";
}
}
@page:first {
@top-left {
content: normal;
}
@top-right {
content: normal;
}
@top-center {
content: normal;
}
}
/*]]>*/
</style>
<link href="#rfc.toc" rel="Contents"/>
<link href="#rfc.section.1" rel="Chapter" title="1 Introduction"/>
<link href="#rfc.section.1.1" rel="Chapter" title="1.1 Requirements Language"/>
<link href="#rfc.section.1.2" rel="Chapter" title="1.2 ACE-Related Terminology"/>
<link href="#rfc.section.1.3" rel="Chapter" title="1.3 MQTT-Related Terminology"/>
<link href="#rfc.section.2" rel="Chapter" title="2 Basic Protocol Interactions"/>
<link href="#rfc.section.2.1" rel="Chapter" title="2.1 Authorizing Connection Establishment"/>
<link href="#rfc.section.2.1.1" rel="Chapter" title="2.1.1 Client Authorization Server (CAS) and Authorization Server (AS) Interaction"/>
<link href="#rfc.section.2.1.2" rel="Chapter" title="2.1.2 Client connection request to the broker"/>
<link href="#rfc.section.2.1.3" rel="Chapter" title="2.1.3 Token validation"/>
<link href="#rfc.section.2.1.4" rel="Chapter" title="2.1.4 The broker's response to client connection request"/>
<link href="#rfc.section.2.2" rel="Chapter" title="2.2 Authorizing PUBLISH messages"/>
<link href="#rfc.section.2.2.1" rel="Chapter" title="2.2.1 PUBLISH messages from the publisher client to the broker"/>
<link href="#rfc.section.2.2.2" rel="Chapter" title="2.2.2 PUBLISH messages from the broker to the subscriber clients"/>
<link href="#rfc.section.2.3" rel="Chapter" title="2.3 Authorizing SUBSCRIBE messages"/>
<link href="#rfc.section.2.4" rel="Chapter" title="2.4 Token expiration"/>
<link href="#rfc.section.2.5" rel="Chapter" title="2.5 Handling disconnections and retained messages"/>
<link href="#rfc.section.3" rel="Chapter" title="3 Improved Protocol Interactions with MQTT v5"/>
<link href="#rfc.section.3.1" rel="Chapter" title="3.1 Token Transport via Authentication Exchange (AUTH)"/>
<link href="#rfc.section.3.2" rel="Chapter" title="3.2 Authorization Errors and Client Re-authentication"/>
<link href="#rfc.section.4" rel="Chapter" title="4 IANA Considerations"/>
<link href="#rfc.section.5" rel="Chapter" title="5 Security Considerations"/>
<link href="#rfc.section.6" rel="Chapter" title="6 Privacy Considerations"/>
<link href="#rfc.references" rel="Chapter" title="7 References"/>
<link href="#rfc.references.1" rel="Chapter" title="7.1 Normative References"/>
<link href="#rfc.references.2" rel="Chapter" title="7.2 Informative References"/>
<link href="#rfc.appendix.A" rel="Chapter" title="A Checklist for profile requirements"/>
<link href="#rfc.appendix.B" rel="Chapter" title="B The authorization information endpoint"/>
<link href="#rfc.appendix.C" rel="Chapter" title="C Document Updates"/>
<link href="#rfc.acknowledgements" rel="Chapter"/>
<link href="#rfc.authors" rel="Chapter"/>
<meta name="generator" content="xml2rfc version 2.5.2 - http://tools.ietf.org/tools/xml2rfc" />
<link rel="schema.dct" href="http://purl.org/dc/terms/" />
<meta name="dct.creator" content="Sengul, C., Kirby, A., and P. Fremantle" />
<meta name="dct.identifier" content="urn:ietf:id:draft-sengul-ace-mqtt-tls-profile-00" />
<meta name="dct.issued" scheme="ISO8601" content="2017-10-13" />
<meta name="dct.abstract" content="This document specifies a profile for the ACE (Authentication and Authorization for Constrained Environments) to enable authorization in an MQTT-based publish-subscribe messaging system. Proof-of-possession keys, bound to OAuth2.0 access tokens, are used to authenticate and authorize publishing and subscribing clients. The protocol relies on TLS for confidentiality and server authentication. " />
<meta name="description" content="This document specifies a profile for the ACE (Authentication and Authorization for Constrained Environments) to enable authorization in an MQTT-based publish-subscribe messaging system. Proof-of-possession keys, bound to OAuth2.0 access tokens, are used to authenticate and authorize publishing and subscribing clients. The protocol relies on TLS for confidentiality and server authentication. " />
</head>
<body>
<table class="header">
<tbody>
<tr>
<td class="left">ACE Working Group</td>
<td class="right">C. Sengul</td>
</tr>
<tr>
<td class="left">Internet-Draft</td>
<td class="right">A. Kirby</td>
</tr>
<tr>
<td class="left">Intended status: Standards Track</td>
<td class="right">Nominet</td>
</tr>
<tr>
<td class="left">Expires: April 16, 2018</td>
<td class="right">P. Fremantle</td>
</tr>
<tr>
<td class="left"></td>
<td class="right">University of Portsmouth</td>
</tr>
<tr>
<td class="left"></td>
<td class="right">October 13, 2017</td>
</tr>
</tbody>
</table>
<p class="title">MQTT-TLS profile of ACE <br />
<span class="filename">draft-sengul-ace-mqtt-tls-profile-00</span></p>
<h1 id="rfc.abstract">
<a href="#rfc.abstract">Abstract</a>
</h1>
<p>This document specifies a profile for the ACE (Authentication and Authorization for Constrained Environments) to enable authorization in an MQTT-based publish-subscribe messaging system. Proof-of-possession keys, bound to OAuth2.0 access tokens, are used to authenticate and authorize publishing and subscribing clients. The protocol relies on TLS for confidentiality and server authentication. </p>
<h1 id="rfc.status">
<a href="#rfc.status">Status of This Memo</a>
</h1>
<p>This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.</p>
<p>Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.</p>
<p>Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."</p>
<p>This Internet-Draft will expire on April 16, 2018.</p>
<h1 id="rfc.copyrightnotice">
<a href="#rfc.copyrightnotice">Copyright Notice</a>
</h1>
<p>Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved.</p>
<p>This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.</p>
<hr class="noprint" />
<h1 class="np" id="rfc.toc"><a href="#rfc.toc">Table of Contents</a></h1>
<ul class="toc">
<li>1. <a href="#rfc.section.1">Introduction</a></li>
<ul><li>1.1. <a href="#rfc.section.1.1">Requirements Language</a></li>
<li>1.2. <a href="#rfc.section.1.2">ACE-Related Terminology</a></li>
<li>1.3. <a href="#rfc.section.1.3">MQTT-Related Terminology</a></li>
</ul><li>2. <a href="#rfc.section.2">Basic Protocol Interactions</a></li>
<ul><li>2.1. <a href="#rfc.section.2.1">Authorizing Connection Establishment</a></li>
<ul><li>2.1.1. <a href="#rfc.section.2.1.1">Client Authorization Server (CAS) and Authorization Server (AS) Interaction</a></li>
<li>2.1.2. <a href="#rfc.section.2.1.2">Client connection request to the broker</a></li>
<li>2.1.3. <a href="#rfc.section.2.1.3">Token validation</a></li>
<li>2.1.4. <a href="#rfc.section.2.1.4">The broker's response to client connection request</a></li>
</ul><li>2.2. <a href="#rfc.section.2.2">Authorizing PUBLISH messages</a></li>
<ul><li>2.2.1. <a href="#rfc.section.2.2.1">PUBLISH messages from the publisher client to the broker</a></li>
<li>2.2.2. <a href="#rfc.section.2.2.2">PUBLISH messages from the broker to the subscriber clients</a></li>
</ul><li>2.3. <a href="#rfc.section.2.3">Authorizing SUBSCRIBE messages</a></li>
<li>2.4. <a href="#rfc.section.2.4">Token expiration</a></li>
<li>2.5. <a href="#rfc.section.2.5">Handling disconnections and retained messages</a></li>
</ul><li>3. <a href="#rfc.section.3">Improved Protocol Interactions with MQTT v5</a></li>
<ul><li>3.1. <a href="#rfc.section.3.1">Token Transport via Authentication Exchange (AUTH)</a></li>
<li>3.2. <a href="#rfc.section.3.2">Authorization Errors and Client Re-authentication</a></li>
</ul><li>4. <a href="#rfc.section.4">IANA Considerations</a></li>
<li>5. <a href="#rfc.section.5">Security Considerations</a></li>
<li>6. <a href="#rfc.section.6">Privacy Considerations</a></li>
<li>7. <a href="#rfc.references">References</a></li>
<ul><li>7.1. <a href="#rfc.references.1">Normative References</a></li>
<li>7.2. <a href="#rfc.references.2">Informative References</a></li>
</ul><li>Appendix A. <a href="#rfc.appendix.A">Checklist for profile requirements</a></li>
<li>Appendix B. <a href="#rfc.appendix.B">The authorization information endpoint</a></li>
<li>Appendix C. <a href="#rfc.appendix.C">Document Updates</a></li>
<li><a href="#rfc.acknowledgements">Acknowledgements</a></li>
<li><a href="#rfc.authors">Authors' Addresses</a></li>
</ul>
<h1 id="rfc.section.1"><a href="#rfc.section.1">1.</a> Introduction</h1>
<p id="rfc.section.1.p.1">This document specifies a profile for the ACE framework <a href="#I-D.ietf-ace-oauth-authz">[I-D.ietf-ace-oauth-authz]</a>. In this profile, clients and a resource server use MQTT to communicate. The protocol relies on TLS for communication security between entities. The basic protocol interactions follow <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>. This document also describes improvements to the basic protocol operation with the new <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite> (e.g., improved authentication exchange and error reporting). Both versions are expected to be supported in practice, and therefore, covered in this document. </p>
<p id="rfc.section.1.p.2">MQTT is a publish-subscribe protocol and supports two types of client operation: publish and subscribe. Once connected, a client can publish to multiple topics, and subscribe to multiple topics; however, for the purpose of this document these actions are described separately. The MQTT broker is responsible for distributing messages published by the publishers to the appropriate subscribers. Each publish message contains a topic, which is used by the broker to filter the subscribers for the message. Subscribers must subscribe to the topics to receive the corresponding messages. </p>
<p id="rfc.section.1.p.3">In this document, message topics are treated as resources. Clients use an access token, bound to a key (the proof-of-possession key) to authorize with the MQTT broker their connection and publish/subscribe permissions to topics. In the context of this ACE profile, the MQTT broker acts as the resource server. In order to provide communication confidentiality and resource server authentication, TLS is used. </p>
<p id="rfc.section.1.p.4">Clients use client authorization servers <a href="#I-D.ietf-ace-actors">[I-D.ietf-ace-actors]</a> to obtain tokens from the authorization server. The communication protocol between the client authorization server and the authorization server is assumed to be HTTPS. Also, if the broker supports token introspection, it is assumed to use HTTPS to communicate with the authorization server. These interfaces MAY be implemented using other protocols e.g., CoAP or MQTT. This document makes the same assumptions as the Section 4 of <a href="#I-D.ietf-ace-oauth-authz">the ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite> in terms of client and RS registration with the AS and establishing of keying material. </p>
<p id="rfc.section.1.p.5">This document describes authorization of the following exchanges between publisher and subscriber clients, and the broker. </p>
<p/>
<ul>
<li>Connection establishment between the clients and the broker</li>
<li>Publish messages from the publishers to the broker, and from the broker to the subscribers</li>
<li>Subscribe messages from the subscribers to the broker</li>
</ul>
<p> </p>
<p id="rfc.section.1.p.7">In <a href="#basic-protocol">Section 2</a>, these exchanges are described based on the <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>. These exchanges are also supported by the new <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>. <a href="#MQTTv5">Section 3</a> describes how they may be improved by the new MQTT v5. </p>
<h1 id="rfc.section.1.1"><a href="#rfc.section.1.1">1.1.</a> Requirements Language</h1>
<p id="rfc.section.1.1.p.1">The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <a href="#RFC2119">RFC 2119</a> <cite title="NONE">[RFC2119]</cite>. </p>
<h1 id="rfc.section.1.2"><a href="#rfc.section.1.2">1.2.</a> ACE-Related Terminology</h1>
<p id="rfc.section.1.2.p.1">The terminology for entities in the architecture is defined in OAuth 2.0 <a href="#RFC6749">RFC 6749 </a> <cite title="NONE">[RFC6749]</cite> and <a href="#I-D.ietf-ace-actors">ACE actors</a> <cite title="NONE">[I-D.ietf-ace-actors]</cite>, such as "Client" (C), "Resource Server" (RS) and "Authorization Server" (AS). </p>
<p id="rfc.section.1.2.p.2">The term "endpoint" is used following its OAuth definition, to denote resources such as /token and /introspect at the AS. </p>
<p id="rfc.section.1.2.p.3">The term "Resource" is used to refer to an MQTT "topic", which is defined in Section 1.2. Hence, the "Resource Owner" is any entity that can authoritatively speak for the "topic". </p>
<p id="rfc.section.1.2.p.4">Certain security-related terms such as "authentication", "authorization", "confidentiality", "(data) integrity", "message authentication code", and "verify" are taken from <a href="#RFC4949">RFC 4949</a> <cite title="NONE">[RFC4949]</cite>. </p>
<h1 id="rfc.section.1.3"><a href="#rfc.section.1.3">1.3.</a> MQTT-Related Terminology</h1>
<p id="rfc.section.1.3.p.1">The document describes message exchanges as MQTT protocol interactions. For additional information, please refer to the <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite> or the <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>. </p>
<p/>
<dl>
<dt>Topic name</dt>
<dd style="margin-left: 8"><br/> The label attached to an application message, which is matched to a subscription. </dd>
<dt>Topic filter</dt>
<dd style="margin-left: 8"><br/> An expression that indicates interest in one or more topic names. Topic filters may include wildcards. </dd>
<dt>Subscription</dt>
<dd style="margin-left: 8"><br/> A subscription comprises of a Topic filter and a maximum quality of service (QoS). </dd>
<dt>Application Message</dt>
<dd style="margin-left: 8"><br/> The data carried by the MQTT protocol. The data has an associated QoS level and a Topic name. </dd>
</dl>
<p> </p>
<p id="rfc.section.1.3.p.3">MQTT sends various control messages across a network connection. The following is not an exhaustive list and the control packets that are not relevant for authorization are not explained. These include, for instance, the PUBREL and PUBCOMP packets used in the 4-step handshake required for the QoS level 2. </p>
<dl>
<dt>CONNECT</dt>
<dd style="margin-left: 8"><br/> Client request to connect to the broker. After a network connection is established, this is the first packet sent by a client. </dd>
<dt>CONNACK</dt>
<dd style="margin-left: 8"><br/> The broker connection acknowledgment. The first packet sent from the broker to a client is a CONNACK packet. CONNACK packets contain return codes indicating either a success or an error state to a client. </dd>
<dt>PUBLISH</dt>
<dd style="margin-left: 8"><br/> Publish packet that can be sent from a client to the broker, or from the broker to a client. </dd>
<dt>PUBACK</dt>
<dd style="margin-left: 8"><br/> Response to PUBLISH packet with QoS level 1. PUBACK can be sent from the broker to a client or a client to the broker. </dd>
<dt>PUBREC</dt>
<dd style="margin-left: 8"><br/> Response to PUBLISH packet with QoS level 2. PUBREC can be sent from the broker to a client or a client to the broker. </dd>
<dt>SUBSCRIBE</dt>
<dd style="margin-left: 8"><br/> The client subscribe request. </dd>
<dt>SUBACK</dt>
<dd style="margin-left: 8"><br/> Subscribe acknowledgment. </dd>
</dl>
<p> </p>
<h1 id="rfc.section.2"><a href="#rfc.section.2">2.</a> <a href="#basic-protocol" id="basic-protocol">Basic Protocol Interactions</a></h1>
<p id="rfc.section.2.p.1">This section describes the following exchanges between publisher and subscriber clients, the broker, and the authorization server according to the <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>. These exchanges are compatible also with the new <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>. In addition, <a href="#MQTTv5">Section 3</a> describes how these exchanges may be improved with the MQTT v5. </p>
<p/>
<ul>
<li>Authorizing connection establishment between the clients and the broker</li>
<li>Authorizing publish messages from the publishers to the broker, and from the broker to the subscribers </li>
<li>Authorizing subscribe messages from the subscribers to the broker</li>
</ul>
<p> </p>
<p id="rfc.section.2.p.3">Message topics are treated as resources. The publisher and subscriber clients are assumed to have identified the topics of interest out-of-band (topic discovery is not a feature of the MQTT protocol). </p>
<p id="rfc.section.2.p.4">A connection request carries a token specifying the permissions that the client has (e.g., publish permission to a given topic). A resource owner can pre-configure policies at the AS that give clients publish or subscribe permissions to different topics. </p>
<h1 id="rfc.section.2.1"><a href="#rfc.section.2.1">2.1.</a> <a href="#token_acquisition" id="token_acquisition">Authorizing Connection Establishment</a></h1>
<p id="rfc.section.2.1.p.1">This section specifies how publishers and subscribers establish an authorized connection to an MQTT broker. The token request and response use the /token endpoint of the authorization server, as specified in Section 6 of the <a href="#I-D.ietf-ace-oauth-authz">ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite>. </p>
<p><a href="#basic_protocol_flow">Figure 1</a> shows the basic protocol flow during connection establishment. </p>
<div id="rfc.figure.1"/>
<div id="basic_protocol_flow"/>
<pre>
+----------------+
+---(A) Token request----| Client |
| | Authorization |
| +-(B) Access token-->| Server |
| | |________________|
| | |
| | (C) Client On-boarding
| | |
| | +---------v-----+
+--v-------------+ | Publisher or |
| | | Subscriber |
| Authorization | |_______________|
| Server | | ^
|________________| | |
| ^ (D)Connection (G)Connection
| | request + response
| | access token |
| | | |
| | +---v--------------+
| | | Broker |
| +(E)Introspection-| Resource Server |
| request | |
+-(F)Introspection---->|__________________|
response
</pre>
<p class="figure">Figure 1: Connection establishment</p>
<h1 id="rfc.section.2.1.1"><a href="#rfc.section.2.1.1">2.1.1.</a> Client Authorization Server (CAS) and Authorization Server (AS) Interaction</h1>
<p id="rfc.section.2.1.1.p.1">The first step in the protocol flow (Figure 1 (A)) is token acquisition by the client authorization server (CAS) from the AS. If a client has enough resources and can support HTTPS, or optionally the AS supports MQTTS, these steps can instead be carried out by a client directly. </p>
<p id="rfc.section.2.1.1.p.2">When requesting an access token from the AS, the CAS MAY include parameters in its request as defined in Section 6.1 of <a href="#I-D.ietf-ace-oauth-authz">the ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite>. The content type is set to "application/json". The profile name is 'mqtt_tls'. </p>
<p id="rfc.section.2.1.1.p.3">If the access token request has been successfully verified by the AS and the client is authorized to obtain a token for the indicated audience (e.g., topics) and scopes (e.g., publish/subscribe permissions), the AS issues an access token (Figure 1 (B)). The response includes the parameters described in Section 6.2 of <a href="#I-D.ietf-ace-oauth-authz">the ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite>. This includes a token, which is assumed to be PoP by default. Hence, a 'cnf' parameter with a symmetric or asymmetric PoP key is returned. The token may be a reference, or a CBOR or JWT web token. Note that the 'cnf' parameter in the web tokens are to be consumed by the resource server and not the client. For more information on Proof of Possession semantics in JWTs see <a href="#RFC7800">RFC 7800</a> <cite title="NONE">[RFC7800]</cite> and for CWTs, see <a href="#I-D.ietf-ace-cwt-proof-of-possession">Proof-of-Possession Key Semantics for CBOR Web Tokens (CWTs)</a> <cite title="NONE">[I-D.ietf-ace-cwt-proof-of-possession]</cite>. </p>
<p id="rfc.section.2.1.1.p.4">In the case of an error, the AS returns error responses for HTTP-based interactions as ASCII codes in JSON content, as defined in Section 5.2 of <a href="#RFC6749">RFC 6749</a> <cite title="NONE">[RFC6749]</cite>. </p>
<h1 id="rfc.section.2.1.2"><a href="#rfc.section.2.1.2">2.1.2.</a> <a href="#connect_v31" id="connect_v31">Client connection request to the broker</a></h1>
<p id="rfc.section.2.1.2.p.1">Client on-boarding (Figure 1 (C)) is out of the scope of this document. Once the client acquires the token, it can use it to request an MQTT connection to the broker over a TLS session with server authentication (Figure 1 (D)). This section describes the client transporting the token to the broker (RS) via the CONNECT control message after the TLS handshake. This is similar to an earlier proposal by Fremantle et al. <a href="#fremantle14">[fremantle14]</a>. An improvement to this is presented in <a href="#MQTTv5">Section 3</a> for the <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>. Alternatively, the token may be used for the TLS session establishment as described in the <a href="#I-D.gerdes-ace-dtls-authorize">DTLS profile for ACE</a> <cite title="NONE">[I-D.gerdes-ace-dtls-authorize]</cite>. In this case, both the TLS PSK and RPK handshakes MAY be supported. This may additionally require that the client transports the token to the broker before the connection establishment. To this end, the broker MAY support /authz-info endpoint via the "authz-info" topic. Then, to transport the token, clients publish to "authz-info" topic unauthorized. The topic "authz-info" MUST be publish-only for clients (i.e., the clients are not allowed to subscribe to it). This option is described in more detail in <a href="#app-authzinfo">Appendix B</a>. </p>
<p id="rfc.section.2.1.2.p.2">When the client wishes to connect to the broker, it uses the CONNECT message of MQTT. <a href="#mqtt_connect_message">Figure 2</a> shows the structure of the MQTT CONNECT control message. </p>
<div id="rfc.figure.2"/>
<div id="mqtt_connect_message"/>
<pre>
0 8 16 24 32
+------------------------------------------------------+
|CPT=1 | Rsvd.|Remaining len.| Protocol name len. = 4 |
+------------------------------------------------------+
| 'M' 'Q' 'T' 'T' |
+------------------------------------------------------+
| Proto.level=4|Connect flags| Keep alive |
+------------------------------------------------------+
| Payload including User Name (='token') |
| Password length and data (=signature/MAC) |
| ... |
+------------------------------------------------------+
</pre>
<p class="figure">Figure 2: MQTT CONNECT control message. (CPT=Control Packet Type, Rsvd=Reserved, len.=length, Proto.=Protocol)</p>
<p id="rfc.section.2.1.2.p.3">To communicate the necessary connection parameters, the Client uses the appropriate flags of the CONNECT message. <a href="#mqtt_connect_flags">Figure 3</a> shows how the MQTT connect flags MUST be set to initiate a connection with the broker. </p>
<div id="rfc.figure.3"/>
<div id="mqtt_connect_flags"/>
<pre>
+-----------------------------------------------------------+
|User name|Pass.|Will retain|Will QoS|Will Flag|Clean| Rsvd.|
| flag |flag | | | | | |
+-----------------------------------------------------------+
| 1 | 1 | X | X X | X | 1 | 0 |
+-----------------------------------------------------------+
</pre>
<p class="figure">Figure 3: MQTT CONNECT flags. (Rsvd=Reserved)</p>
<p id="rfc.section.2.1.2.p.4">In order to ensure that the client and the broker discard any previous session and start a new session, the Clean Session Flag MUST be set to 1. </p>
<p id="rfc.section.2.1.2.p.5">The Will flag indicates that a Will message needs to be sent when a client disconnection occurs. The situations in which the Will message is published include disconnections due to I/O or network failures, and the server closing the networking connection due to a protocol error. The client may set the Will flag as desired (marked as 'X' in <a href="#mqtt_connect_flags">Figure 3</a>). If the Will flag is set to 1 and the broker accepts the connection request, the broker must store the Will message, and publish it when the network connection is closed according to Will QoS and Will retain parameters, and MQTT Will management rules. <a href="#disconnections">Section 2.5</a> explains how the broker deals with the retained messages in further detail. </p>
<p id="rfc.section.2.1.2.p.6">Finally, Username and Password flags MUST be set to 1 to ensure that the Payload of the CONNECT message includes both Username and Password fields. </p>
<p id="rfc.section.2.1.2.p.7">The CONNECT message defaults to ACE for authentication and authorization. For the basic operation described in this section, the Username field MUST be set to the token. The Password field MUST be set to the keyed message digest (MAC) or signature. The client MAY apply the PoP key either to the token or the entire request by computing a keyed message digest (for symmetric key) or a digital signature (for asymmetric key). (The Username field is a UTF-8 encoded string, which is prefixed with a two-byte length field and can have any length in the range of 0 and 65535. Similarly, the password field contains 0 to 65535 bytes of binary data, prefixed by a two-byte length field.) </p>
<h1 id="rfc.section.2.1.3"><a href="#rfc.section.2.1.3">2.1.3.</a> <a href="#token_validation" id="token_validation">Token validation</a></h1>
<p id="rfc.section.2.1.3.p.1">RS MUST verify the validity of the token. This validation MAY be done locally (e.g., in the case of a self-contained token) or the RS MAY send an introspection request to the AS. If introspection is used, this section follows similar steps to those described in Sections 7.2 and 7.3 of <a href="#I-D.ietf-ace-oauth-authz">the ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite>. The communication between AS and RS MAY be HTTPS, but it, in every case, MUST be confidential, mutually authenticated and integrity protected. </p>
<p id="rfc.section.2.1.3.p.2">The broker MUST check if the token is active either using 'expires_in' parameter of the token or 'active' parameter of the introspection response. </p>
<p id="rfc.section.2.1.3.p.3">The access token is constructed by the AS such that RS can associate the access token with the client key. This document assumes that the Access Token is a PoP token as described in <a href="#I-D.ietf-ace-oauth-authz">[I-D.ietf-ace-oauth-authz]</a>. Therefore, the necessary information is contained in the 'cnf' claim of the access token and may use either public or shared key approaches. The client uses the signature or the MAC in the password field to prove the possession of the key. Depending on the chosen implementation, the resource server validates the signature or the MAC over the token or the contents of the packet, authenticating the client. </p>
<p id="rfc.section.2.1.3.p.4">The broker uses the scope field in the token (or in the introspection result) to determine the publish and subscribe permissions for the client. If the Will flag is set, then the broker MUST check that the token allows the publication of the Will message too. </p>
<p id="rfc.section.2.1.3.p.5">The broker MAY cache the introspection result because it will need to decide whether to accept subsequent PUBLISH and SUBSCRIBE messages and these messages, which are sent after a connection is set-up, do not contain tokens. If the introspection result is not cached, then the RS needs to introspect the saved token for each request. </p>
<p id="rfc.section.2.1.3.p.6">Note: Scope strings MAY follow an application specific convention. One option is to encode the permission and the topics it applies into the scope string e.g., 'publish_topic1' or 'subscribe_topic2'. A second option is to simply use the keywords 'publish' or 'subscribe' as scope strings and use the 'aud' field to define the topic. Another option is to use topic names as scope strings and use the 'aud' field to define whether the 'publish' or 'subscribe' permission applies to these scopes. The choice is left to the implementer and depends on how the following trade-off is expected to be handled: token simplicity versus the number of tokens the broker is expected to handle per client. </p>
<h1 id="rfc.section.2.1.4"><a href="#rfc.section.2.1.4">2.1.4.</a> The broker's response to client connection request</h1>
<p id="rfc.section.2.1.4.p.1">Based on the validation result (obtained either via local inspection or using the /introspection interface of the AS), the broker MUST send a CONNACK message to the client. </p>
<p id="rfc.section.2.1.4.p.2">The broker responses may follow either the <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite> or the <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, depending on which version(s) the broker supports. </p>
<p id="rfc.section.2.1.4.p.3">In <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>, it is not possible to support AS discovery via sending a tokenless CONNECT message to the broker. This is because a CONNACK packet does not include a means to provide additional information to the client. Therefore, AS discovery needs to take place out-of-band. This is remedied in the <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite> and a solution is described in <a href="#MQTTv5">Section 3</a>. </p>
<p id="rfc.section.2.1.4.p.4">If the RS accepts the connection, it MUST store the token. </p>
<h1 id="rfc.section.2.2"><a href="#rfc.section.2.2">2.2.</a> Authorizing PUBLISH messages</h1>
<h1 id="rfc.section.2.2.1"><a href="#rfc.section.2.2.1">2.2.1.</a> PUBLISH messages from the publisher client to the broker</h1>
<p id="rfc.section.2.2.1.p.1">On receiving the PUBLISH message, the broker MUST use the type of message (i.e., PUBLISH) and the topic name in the message header to compare against the cached token or its introspection result (depending on the implementation, different fields of the token or the introspection result may be checked, see the Note in <a href="#token_validation">Section 2.1.3</a>). </p>
<p id="rfc.section.2.2.1.p.2">If the client is allowed to publish to the topic, the RS must publish the message to all valid subscribers of the topic. The broker may also return an acknowledgment message if the QoS level is greater than or equal to 1. </p>
<p id="rfc.section.2.2.1.p.3">In case of a failure, it is not possible to return an error in <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>. The return of acknowledgement messages only indicates success. In the case of an authorization error, the broker SHOULD disconnect the client. Otherwise, it MUST ignore the PUBLISH message. Also, DISCONNECT messages are only sent from a client to the broker. So, server disconnection needs to take place below the application layer. However, in <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, it is possible to indicate failure and provide a reason code. <a href="#MQTTv5">Section 3</a> describes in more detail how PUBLISH authorization errors are handled. </p>
<h1 id="rfc.section.2.2.2"><a href="#rfc.section.2.2.2">2.2.2.</a> PUBLISH messages from the broker to the subscriber clients</h1>
<p id="rfc.section.2.2.2.p.1">To forward PUBLISH messages to the subscribing clients, the broker identifies all the subscribers that have matching valid topic subscriptions (i.e., the tokens are valid and token scopes allow a subscription to the particular topic name). The broker sends a PUBLISH message with the topic name and the topic message to all the valid subscribers. </p>
<p id="rfc.section.2.2.2.p.2">In MQTT, after connection establishment, there is no way to inform a client that an authorization error has occurred for previously subscribed topics, e.g., token expiry. In the case of an authorization error, the broker has two options: (1) stop forwarding PUBLISH messages to the unauthorized client or (2) disconnect the client. In the <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>, the MQTT DISCONNECT messages are only sent from a client to the broker. Therefore, the server disconnection needs to take place below the application layer. In <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, server-side DISCONNECT messages are possible, and are described in <a href="#MQTTv5">Section 3</a>. </p>
<h1 id="rfc.section.2.3"><a href="#rfc.section.2.3">2.3.</a> Authorizing SUBSCRIBE messages</h1>
<p id="rfc.section.2.3.p.1">In MQTT, a SUBSCRIBE message is sent from a client to the broker to create one or more subscriptions to one or more topics. The SUBSCRIBE message may contain multiple topic filters. The topic filters may include wildcard characters. </p>
<p id="rfc.section.2.3.p.2">On receiving the SUBSCRIBE message, the broker MUST use the type of message (i.e., SUBSCRIBE) and the topic filter in the message header to compare against the stored token or introspection result (depending on the implementation, different fields of the token or introspection result may be checked, see the Note in <a href="#token_validation">Section 2.1.3</a>). </p>
<p id="rfc.section.2.3.p.3">As a response to the SUBSCRIBE message, the broker issues a SUBACK message. For each topic filter, the SUBACK packet includes a return code matching the QoS level for the corresponding topic filter. In the case of failure, the return code, in MQTT v3.1, must be 0x80 indicating 'Failure'. In MQTT v5, the appropriate return code is 0x87, indicating that the client is 'Not authorized'. Note that, in both MQTT versions, a reason code is returned for each topic filter. Therefore, the client may receive success codes for a subset of its topic filters, while being unauthorized for the rest. </p>
<h1 id="rfc.section.2.4"><a href="#rfc.section.2.4">2.4.</a> Token expiration</h1>
<p id="rfc.section.2.4.p.1">The broker checks for token expiration whenever a CONNECT, PUBLISH or SUBSCRIBE message is received or sent. The validation is done either by checking the 'exp' claim of a CWT/JWT or via performing an introspection request with the Authorization server as described in Section 8.2 of <a href="#I-D.ietf-ace-oauth-authz">the ACE framework</a> <cite title="NONE">[I-D.ietf-ace-oauth-authz]</cite>. In the basic operation, token expirations MAY lead to disconnecting the associated client. However, in <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, better error handling and re-authentication are possible. This is explained in more detail in <a href="#MQTTv5">Section 3</a>. </p>
<h1 id="rfc.section.2.5"><a href="#rfc.section.2.5">2.5.</a> <a href="#disconnections" id="disconnections">Handling disconnections and retained messages</a></h1>
<p id="rfc.section.2.5.p.1">According to <a href="#MQTT-OASIS-Standard">MQTT v3.1 - OASIS Standard</a> <cite title="NONE">[MQTT-OASIS-Standard]</cite>, only Client DISCONNECT messages are allowed. In <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, server-side DISCONNECT messages are possible, allowing to return '0x87 Not Authorized' return code to the client. </p>
<p id="rfc.section.2.5.p.2">In the case of a DISCONNECT, due to the Clean Session flag, the broker deletes all session state but MUST keep the retained messages. By setting a RETAIN flag in a PUBLISH message the publisher indicates to the broker that it should store the most recent message for the associated topic. Hence, the new subscribers can receive the last sent message from the publisher for that particular topic, without waiting for the next PUBLISH message. In the case of a disconnection, the broker MUST continue publishing the retained messages as long as the associated tokens are valid. </p>
<p id="rfc.section.2.5.p.3">In case of disconnections due to network errors, or server disconnection due to a protocol error (which includes authorization errors), the Will message must be sent if the client supplied a Will in the CONNECT request message. The token provided in the CONNECT request must cover the Will topic. The Will message MUST be published to the Will topic when the network connection is closed regardless of whether the corresponding token has expired. </p>
<h1 id="rfc.section.3"><a href="#rfc.section.3">3.</a> <a href="#MQTTv5" id="MQTTv5">Improved Protocol Interactions with MQTT v5</a></h1>
<p id="rfc.section.3.p.1">In the new <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, several new capabilities are introduced, which enables better integration with the ACE standards. For instance, the new enhanced authentication and re-authentication methods support a much wider range of authentication flows beyond username and password. With the MQTT v5, there is a clearly defined approach for using token-based approaches. Similarly, in MQTT v5, it is possible for a client to request a re-authentication. Finally, MQTT v5 generally improves error reporting, enabling better response to authorization failures during publishing and forwarding of messages to the subscribers. </p>
<h1 id="rfc.section.3.1"><a href="#rfc.section.3.1">3.1.</a> <a href="#token_transport_v5" id="token_transport_v5">Token Transport via Authentication Exchange (AUTH)</a></h1>
<p id="rfc.section.3.1.p.1">To initiate the authentication and authorization flow, as before, the CAS initiates the token request as in <a href="#token_acquisition">Section 2.1</a>. When the client wishes to connect to the RS (broker), it uses the CONNECT message of MQTT. <a href="#mqtt5_connect_message">Figure 4</a> shows the structure of the MQTT CONNECT control message used in MQTT v5. </p>
<div id="rfc.figure.4"/>
<div id="mqtt5_connect_message"/>
<pre>
0 8 16 24 32
+------------------------------------------------------+
|CPT=1 | Rsvd.|Remaining len.| Protocol name len. = 4 |
+------------------------------------------------------+
| 'M' 'Q' 'T' 'T' |
+------------------------------------------------------+
| Proto.level=5|Connect flags| Keep alive |
+------------------------------------------------------+
| Property length |
| Auth. Method (0x15) | 'ace_mqtt_tls' |
| Auth. Data (0x16) | empty or token |
| |
+------------------------------------------------------+
</pre>
<p class="figure">Figure 4: MQTT CONNECT control message. (CPT=Control Packet Type, Rsvd=Reserved, len.=length, Proto.=Protocol)</p>
<p id="rfc.section.3.1.p.2">To communicate the necessary connection parameters, the client uses the appropriate flags of the CONNECT message. To achieve a clean session (i.e., the session should start without an existing session), the new MQTT v5 session flags MUST be set appropriately. More specifically, the Clean Start Flag MUST be set to 1 and Session Expiry Interval MUST be set to 0. </p>
<p id="rfc.section.3.1.p.3">With the enhanced authentication capabilities, it is no more necessary to overload the username and password fields in the CONNECT message for ACE authentication. Nevertheless, the RS MUST support both methods for supporting the token: (1) Token transport via username and password and (2) using the new AUTH (Authentication Exchange) method. The token transport via username and password is as described in <a href="#connect_v31">Section 2.1.2</a>. The rest of this section describes the AUTH method. </p>
<p id="rfc.section.3.1.p.4">To use the AUTH method, the username flag MUST be set to 0 and the password flag MUST be set to 0. The client can set the Authentication Method as a property of a CONNECT packet by setting Auth Properties (with the property identifier 0x15). The client must MUST set the UTF-8 encoded string containing the name of the authentication method as 'ace_mqtt_tls'. If the RS does not support this profile, it sends a CONNACK with a Reason Code of '0x8C (Bad authentication method)' </p>
<p id="rfc.section.3.1.p.5">Authentication Method is followed with Authentication Data, which has a property identifier 0x16. Authentication data is binary data and is defined by the authentication method. The RS MAY support different implementations for transporting the authentication data. The first option is that Authentication data contains both the token and the keyed message digest (MAC) or signature as described in <a href="#connect_v31">Section 2.1.2</a>. In this case, the token validation proceeds as described in <a href="#token_validation">Section 2.1.3</a> and the the server responds with a CONNACK. The reason code of the CONNACK '0x00 (Success)' if the authentication is successful. In case of an invalid PoP token, the CONNACK reason code is '0x87 (Not Authorized)'. </p>
<p id="rfc.section.3.1.p.6">The second option that RS may accept is a challenge/response protocol. If the Authentication Data only includes the token, the RS MUST respond with an AUTH packet, with the Authenticate Reason Code set to '0x18 (Continue Authentication)'. This packet includes the Authentication Method, which MUST be set to 'ace_mqtt_tls' and Authentication Data. The Authentication Data MUST NOT be empty and contains a challenge for the client. The client responds to this with an AUTH packet, with a reason code '0x18 (Continue Authentication)'. Similarly, the client packet sets the Authentication Method to 'ace_mqtt_tls'. The Authentication Data in the client's response contains the signature or MAC computed over the RS's challenge. To this, the server responds with a CONNACK and a return code of '0x00 (Success)' if the authentication is successful. In case of an invalid PoP token, the CONNACK reason code is '0x87 (Not Authorized)'. </p>
<p id="rfc.section.3.1.p.7">Finally, this document allows the CONNECT message to have an empty Authentication Data field. This is the AS discovery option and the RS responds with a CONNACK reason code '0x87 (Not Authorized)' and includes a User Property set to the address of the AS. </p>
<h1 id="rfc.section.3.2"><a href="#rfc.section.3.2">3.2.</a> <a href="#improved_error_messaging" id="improved_error_messaging">Authorization Errors and Client Re-authentication</a></h1>
<p id="rfc.section.3.2.p.1">MQTT v5 allows better error reporting. To take advantage of this for PUBLISH messages, the QoS level should be set to greater than or equal to 1. This guarantees the RS to respond with either a PUBACK or PUBREC packet, with a reason code '0x87 (Not authorized)' in the case of an authorization error. Similarly, for the SUBSCRIBE case, the SUBACK packet will have a reason code set to '0x87 (Not authorized)' for the unauthorized topic(s). When RS is forwarding PUBLISH messages to the subscribed clients, it may discover that some of the subscribers are no more authorized due to expired tokens. In this case, the RS SHOULD send a DISCONNECT message with the reason code '0x87 (Not authorized)'. Note that the server-side DISCONNECT is a new feature of MQTT v5 (in MQTT v3.1 server needed to drop the connection). RS MUST stop forwarding messages to these unauthorized subscribers. </p>
<p id="rfc.section.3.2.p.2">In the case of a PUBACK with '0x87 (Not authorized)', the client can update its token using the Re-authentication feature of MQTT v5. Also, the clients can proactively update their tokens, without waiting for such a PUBACK. To re-authenticate, the client sends an AUTH packet with a reason code '0x19 (Re-authentication)'. The client MUST send the authentication method as 'ace_mqtt_tls' and transports the new token in the Authentication Data. The client and the RS go through the same steps for proof of possession validation described in the previous section. This flow ends with either re-authentication is complete or re-authentication fails. If the re-authentication fails, the server MUST send a DISCONNECT with the reason code '0x87 (Not Authorized)'. </p>
<h1 id="rfc.section.4"><a href="#rfc.section.4">4.</a> <a href="#IANA" id="IANA">IANA Considerations</a></h1>
<p id="rfc.section.4.p.1">This memo includes no request to IANA.</p>
<h1 id="rfc.section.5"><a href="#rfc.section.5">5.</a> <a href="#Security" id="Security">Security Considerations</a></h1>
<p id="rfc.section.5.p.1">The security considerations outlined in <a href="#I-D.ietf-ace-oauth-authz">[I-D.ietf-ace-oauth-authz]</a> apply to this work.</p>
<h1 id="rfc.section.6"><a href="#rfc.section.6">6.</a> <a href="#Privacy" id="Privacy">Privacy Considerations</a></h1>
<p id="rfc.section.6.p.1">The privacy considerations outlined in <a href="#I-D.ietf-ace-oauth-authz">[I-D.ietf-ace-oauth-authz]</a> apply to this work. Furthermore, the RS is a central trusted party and may forward potentially sensitive information between clients. </p>
<h1 id="rfc.references"><a href="#rfc.references">7.</a> References</h1>
<h1 id="rfc.references.1"><a href="#rfc.references.1">7.1.</a> Normative References</h1>
<table>
<tbody>
<tr>
<td class="reference">
<b id="I-D.gerdes-ace-dtls-authorize">[I-D.gerdes-ace-dtls-authorize]</b>
</td>
<td class="top"><a>Gerdes, S.</a>, <a>Bergmann, O.</a>, <a>Bormann, C.</a>, <a>Selander, G.</a> and <a>L. Seitz</a>, "<a href="http://tools.ietf.org/html/draft-gerdes-ace-dtls-authorize-01">Datagram Transport Layer Security (DTLS) Profile for Authentication and Authorization for Constrained Environments (ACE)</a>", Internet-Draft draft-gerdes-ace-dtls-authorize-01, March 2017.</td>
</tr>
<tr>
<td class="reference">
<b id="I-D.ietf-ace-oauth-authz">[I-D.ietf-ace-oauth-authz]</b>
</td>
<td class="top"><a>Seitz, L.</a>, <a>Selander, G.</a>, <a>Wahlstroem, E.</a>, <a>Erdtman, S.</a> and <a>H. Tschofenig</a>, "<a href="http://tools.ietf.org/html/draft-ietf-ace-oauth-authz-07">Authentication and Authorization for Constrained Environments (ACE)</a>", Internet-Draft draft-ietf-ace-oauth-authz-07, August 2017.</td>
</tr>
<tr>
<td class="reference">
<b id="MQTT-OASIS-Standard">[MQTT-OASIS-Standard]</b>
</td>
<td class="top"><a title="IBM">Banks, A.</a> and <a title="IBM">R. Gupta</a>, "<a href="http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html">OASIS Standard MQTT Version 3.1.1 Plus Errata 01</a>", 2015.</td>
</tr>
<tr>
<td class="reference">
<b id="MQTT-OASIS-Standard-v5">[MQTT-OASIS-Standard-v5]</b>
</td>
<td class="top"><a title="IBM">Banks, A.</a>, <a title="Microsoft">Briggs, E.</a>, <a title="IBM">Borgendale, K.</a> and <a title="IBM">R. Gupta</a>, "<a href="http://docs.oasis-open.org/mqtt/mqtt/v5.0/csprd01/mqtt-v5.0-csprd01.html">OASIS Public Review Draft 01 MQTT Version 5.0</a>", 2017.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC2119">[RFC2119]</b>
</td>
<td class="top"><a>Bradner, S.</a>, "<a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.</td>
</tr>
</tbody>
</table>
<h1 id="rfc.references.2"><a href="#rfc.references.2">7.2.</a> Informative References</h1>
<table>
<tbody>
<tr>
<td class="reference">
<b id="fremantle14">[fremantle14]</b>
</td>
<td class="top"><a>Fremantle, P.</a>, <a>Aziz, B.</a>, <a>Kopecky, J.</a> and <a>P. Scott</a>, "<a href="http://dx.doi.org/10.1109/SIoT.2014.8">Federated Identity and Access Management for the Internet of Things</a>", research International Workshop on Secure Internet of Things, September 2014.</td>
</tr>
<tr>
<td class="reference">
<b id="I-D.ietf-ace-actors">[I-D.ietf-ace-actors]</b>
</td>
<td class="top"><a>Gerdes, S.</a>, <a>Seitz, L.</a>, <a>Selander, G.</a> and <a>C. Bormann</a>, "<a href="http://tools.ietf.org/html/draft-ietf-ace-actors-05">An architecture for authorization in constrained environments</a>", Internet-Draft draft-ietf-ace-actors-05, March 2017.</td>
</tr>
<tr>
<td class="reference">
<b id="I-D.ietf-ace-cwt-proof-of-possession">[I-D.ietf-ace-cwt-proof-of-possession]</b>
</td>
<td class="top"><a>Jones, M.</a>, <a>Seitz, L.</a>, <a>Selander, G.</a>, <a>Wahlstroem, E.</a>, <a>Erdtman, S.</a> and <a>H. Tschofenig</a>, "<a href="http://tools.ietf.org/html/draft-ietf-ace-cwt-proof-of-possession-00">Proof-of-Possession Key Semantics for CBOR Web Tokens (CWTs)</a>", Internet-Draft draft-ietf-ace-cwt-proof-of-possession-00, September 2017.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC4949">[RFC4949]</b>
</td>
<td class="top"><a>Shirey, R.</a>, "<a href="http://tools.ietf.org/html/rfc4949">Internet Security Glossary, Version 2</a>", FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC6749">[RFC6749]</b>
</td>
<td class="top"><a>Hardt, D.</a>, "<a href="http://tools.ietf.org/html/rfc6749">The OAuth 2.0 Authorization Framework</a>", RFC 6749, DOI 10.17487/RFC6749, October 2012.</td>
</tr>
<tr>
<td class="reference">
<b id="RFC7800">[RFC7800]</b>
</td>
<td class="top"><a>Jones, M.</a>, <a>Bradley, J.</a> and <a>H. Tschofenig</a>, "<a href="http://tools.ietf.org/html/rfc7800">Proof-of-Possession Key Semantics for JSON Web Tokens (JWTs)</a>", RFC 7800, DOI 10.17487/RFC7800, April 2016.</td>
</tr>
</tbody>
</table>
<h1 id="rfc.appendix.A"><a href="#rfc.appendix.A">Appendix A.</a> <a href="#app-profile-requirements" id="app-profile-requirements">Checklist for profile requirements</a></h1>
<p/>
<ul>
<li>AS discovery: For the basic protocol using either MQTT v3.1 or MQTT v5, the clients/client authorization servers need to be configured out-of-band. RS does not provide any hints to help AS discovery. AS discovery is possible with the MQTT v5 extensions described in <a href="#MQTTv5">Section 3</a>. </li>
<li>Communication protocol between the client and RS: MQTT</li>
<li>Security protocol between the client and RS: TLS</li>
<li>Client and RS mutual authentication: RS provides a server certificate during TLS handshake. Client transports token and MAC via the MQTT CONNECT message. </li>
<li>Content format: For the HTTPS interactions with AS, "application/json". The MQTT payloads may be formatted JSON or CBOR. </li>
<li>PoP protocols: Either symmetric or asymmetric keys can be supported.</li>
<li>Unique profile identifier: mqtt_tls</li>
<li>Token introspection: RS uses HTTPS /introspect interface of AS.</li>
<li>Token request: CAS uses HTTPS /token interface of AS.</li>
<li>/authz-info endpoint: It MAY be supported using the method described in <a href="#app-authzinfo">Appendix B</a>, not protected. </li>
<li>Token transport: In MQTT CONNECT message or using the AUTH extensions for MQTT v5 described in <a href="#MQTTv5">Section 3</a>.</li>
</ul>
<p> </p>
<h1 id="rfc.appendix.B"><a href="#rfc.appendix.B">Appendix B.</a> <a href="#app-authzinfo" id="app-authzinfo">The authorization information endpoint</a></h1>
<p id="rfc.section.B.p.1">The main document described a method for transporting tokens inside MQTT CONNECT messages. In this section, we describe an alternative method to transport an access token. </p>
<p id="rfc.section.B.p.2">The method consists of the MQTT broker accepting PUBLISH messages to a public "authz-info" topic. A client using this method MUST first connect to the broker, and publish the access token using the "authz-info" topic. The broker must verify the validity of the token (i.e., through local validation or introspection). After publishing the token, the client disconnects from the broker and is expected to try reconnecting over TLS. </p>
<p id="rfc.section.B.p.3">In MQTT v3.1, after the client published to the "authz-info" topic, it is not possible for the broker to communicate the result of the token verification. In MQTT v5, the broker can return 'Not authorized' error to a PUBLISH request for QoS greater or equal to 1. In any case, any token authorization failure will affect the TLS handshake, which can prompt the client to obtain a valid token. </p>
<h1 id="rfc.appendix.C"><a href="#rfc.appendix.C">Appendix C.</a> <a href="#document_updates" id="document_updates">Document Updates</a></h1>
<p id="rfc.section.C.p.1">This new version updates the expired document (July 29, 2017) as follows: </p>
<ul>
<li>Adds <a href="#MQTTv5">Section 3</a> to describe improvements to the basic protocol operation with the new <a href="#MQTT-OASIS-Standard-v5">MQTT v5 - OASIS Specification Draft</a> <cite title="NONE">[MQTT-OASIS-Standard-v5]</cite>, including improved authentication exchange and error reporting.</li>
<li>Condenses background information specific to MQTT in <a href="#basic-protocol">Section 2</a>.</li>
<li>Clarifies token transport and token structure in <a href="#connect_v31">Section 2.1.2</a> and <a href="#token_validation">Section 2.1.3</a>.</li>
<li>Removes Appendix on error reporting as this is now handled with MQTT v5. </li>
</ul>
<p> </p>
<h1 id="rfc.acknowledgements">
<a href="#rfc.acknowledgements">Acknowledgements</a>
</h1>
<p id="rfc.section.D.p.1">The authors would like to thank Ludwig Seitz for his input on the authorization information endpoint, presented in the appendix. </p>
<h1 id="rfc.authors">
<a href="#rfc.authors">Authors' Addresses</a>
</h1>
<div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Cigdem Sengul</span>
<span class="n hidden">
<span class="family-name">Sengul</span>
</span>
</span>
<span class="org vcardline">Nominet</span>
<span class="adr">
<span class="vcardline">2 Kingdom Street</span>
<span class="vcardline">
<span class="locality">London</span>,
<span class="region"></span>
<span class="code">W2 6BD</span>
</span>
<span class="country-name vcardline">UK</span>
</span>
<span class="vcardline">EMail: <a href="mailto:Cigdem.Sengul@nominet.uk">Cigdem.Sengul@nominet.uk</a></span>
</address>
</div><div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Anthony Kirby</span>
<span class="n hidden">
<span class="family-name">Kirby</span>
</span>
</span>
<span class="org vcardline">Nominet</span>
<span class="adr">
<span class="vcardline">Minerva House, Edmund Halley Road</span>
<span class="vcardline">
<span class="locality">Oxford</span>,
<span class="region"></span>
<span class="code">OX4 4DQ</span>
</span>
<span class="country-name vcardline">UK</span>
</span>
<span class="vcardline">EMail: <a href="mailto:Anthony.Kirby@nominet.uk">Anthony.Kirby@nominet.uk</a></span>
</address>
</div><div class="avoidbreak">
<address class="vcard">
<span class="vcardline">
<span class="fn">Paul Fremantle</span>
<span class="n hidden">
<span class="family-name">Fremantle</span>
</span>
</span>
<span class="org vcardline">University of Portsmouth</span>
<span class="adr">
<span class="vcardline">School of Computing, Buckingham House</span>
<span class="vcardline">
<span class="locality">Portsmouth</span>,
<span class="region"></span>
<span class="code">PO1 3HE</span>
</span>
<span class="country-name vcardline">UK</span>
</span>
<span class="vcardline">EMail: <a href="mailto:paul.fremantle@port.ac.uk">paul.fremantle@port.ac.uk</a></span>
</address>
</div>
</body>
</html>