summaryrefslogtreecommitdiff
path: root/qpid/doc/book/src/ACL.xml
blob: 123819b490dd2661e5253b884fe701081db4b3ff (plain)
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
<?xml version="1.0" encoding="utf-8"?>
<!--
 
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
   http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 
-->

<chapter xmlns:html="http://www.w3.org/1999/xhtml"><title>
      Apache Qpid : ACL
    </title><section role="h2" id="ACL-v2ACLfileformatforbrokers"><title>
            v2 ACL file format
            for brokers
          </title>
          <para>
            This new ACL implementation has been designed for implementation
            and interoperability on all Qpid brokers. It is currently
            supported in the following brokers:
          </para>

	  <table><title/><tgroup cols="2">
	  <thead>
              <row>
                <entry>
                  Broker
                </entry>
                <entry>
                  Version
                </entry>
              </row>
	  </thead>
            <tbody>
              <row>
                <entry>
                  C++
                </entry>
                <entry>
                  M4 onward
                </entry>
              </row>
              <row>
                <entry>
                  Java
                </entry>
                <entry>
                  M5 anticipated
                </entry>
              </row>
            </tbody>
          </tgroup></table>

	  <para>
            Contents
          </para>
            <itemizedlist>
              <listitem><para>
                <xref linkend="ACL-v2ACLfileformatforbrokers"/>
              </para></listitem>
              <listitem><para>
                <itemizedlist>
                  <listitem><para>
                    <xref linkend="ACL-Specification"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="ACL-Validation"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="ACL-Examplefile-3A"/>
                  </para></listitem>
                </itemizedlist>
              </para></listitem>
              <listitem><para>
                <xref linkend="ACL-DesignDocumentation"/>
              </para></listitem>
              <listitem><para>
                <itemizedlist>
                  <listitem><para>
                    <xref linkend="ACL-MappingofACLtrapstoactionandtype"/>
                  </para></listitem>
                </itemizedlist>
              </para></listitem>
              <listitem><para>
                <xref linkend="ACL-v2ACLUserGuide"/>
              </para></listitem>
              <listitem><para>
                <itemizedlist>
                  <listitem><para>
                    <xref linkend="ACL-WritingGood-2FFastACL"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="ACL-GettingACLtoLog"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="ACL-UserId-2FdomainsrunningwithCbroker"/>
                  </para></listitem>
                </itemizedlist>
              </para></listitem>
            </itemizedlist>
          <para>
            
          </para><section role="h3" id="ACL-Specification"><title>
            Specification
          </title>
          <para>
             Notes on file formats
          </para><itemizedlist>
            <listitem><para>A line starting with the character '#' will be considered a
            comment, and are ignored.
            </para></listitem>
            <listitem><para>Since the '#' char (and others that are commonly used for
            comments) are commonly found in routing keys and other AMQP
            literals, it is simpler (for now) to hold off on allowing
            trailing comments (ie comments in which everything following a
            '#' is considered a comment). This could be reviewed later once
            the rest of the format is finalized.
            </para></listitem>
            <listitem><para>Empty lines ("") and lines that contain only whitespace (any
            combination of ' ', '\f', '\n', '\r', '\t', '\v') are ignored.
            </para></listitem>
            <listitem><para>All tokens are case sensitive. "name1" != "Name1" and
            "create" != "CREATE".
            </para></listitem>
            <listitem><para>Group lists may be extended to the following line by
            terminating the line with the '\' character. However, this may
            only occur after the group name or any of the names following the
            group name. Empty extension lines (ie just a '\' character) are
            not permitted.
              
                <programlisting>
# Examples of extending group lists using a trailing '\' character

group group1 name1 name2 \
             name3 name4 \
             name5

group group2 \
             group1 \
             name6

# The following are illegal:

# '\' must be after group name
group \
      group3 name7 name8

# No empty extension lines
group group4 name9 \
                   \
             name10
</programlisting>
              
            </para></listitem>
            <listitem><para>Additional whitespace (ie more than one whitespace char)
            between and after tokens is ignored. However group and acl
            definitions must start with "group" or "acl" respectively and
            with no preceding whitespace.
            </para></listitem>
            <listitem><para>All acl rules are limited to a single line.
            </para></listitem>
            <listitem><para>Rules are interpreted from the top of the file down until the
            name match is obtained; at which point processing stops.
            </para></listitem>
            <listitem><para>The keyword "all" is reserved, and matches all individuals,
            groups and actions. It may be used in place of a group or
            individual name and/or an action - eg "acl allow all all", "acl
            deny all all" or "acl deny user1 all".
            </para></listitem>
            <listitem><para>The last line of the file (whether present or not) will be
            assumed to be "acl deny all all". If present in the file, any
            lines below this one are ignored.
            </para></listitem>
            <listitem><para>Names and group names may contain only a-z, A-Z, 0-9,
            '-','_'.
            </para></listitem>
            <listitem><para>Rules must be preceded by any group definitions they may use;
            any name not previously defined as a group will be assumed to be
            that of an individual.
            </para></listitem>
            <listitem><para>ACL rules must have the following tokens in order on a single
            line:
              <itemizedlist>
                <listitem><para>The string literal "acl";
                </para></listitem>
                <listitem><para>The permission;
                </para></listitem>
                <listitem><para>The name of a single group or individual or the keyword
                "all";
                </para></listitem>
                <listitem><para>The name of an action or the keyword "all";
                </para></listitem>
                <listitem><para>Optionally, a single object name or the keyword "all";
                </para></listitem>
                <listitem><para>If the object is present, then optionally one or more
                property name-value pair(s) (in the form property=value).
                </para></listitem>
              </itemizedlist>
            </para></listitem>
          </itemizedlist>
            <programlisting>
user = username[@domain[/realm]]
user-list = user1 user2 user3 ...
group-name-list = group1 group2 group3 ...

group &lt;group-name&gt; = [user-list] [group-name-list]


permission = [allow|allow-log|deny|deny-log]
action = [consume|publish|create|access|bind|unbind|delete|purge|update]
object = [virtualhost|queue|exchange|broker|link|route|method]
property = [name|durable|owner|routingkey|passive|autodelete|exclusive|type|alternate|queuename|schemapackage|schemaclass]

acl permission {&lt;group-name&gt;|&lt;user-name&gt;|"all"} {action|"all"} [object|"all"] [property=&lt;property-value&gt;]
</programlisting>
<!--h3--></section>
          <section role="h3" id="ACL-Validation"><title>
            Validation
          </title>
          <para>
            The new ACL file format needs to perform validation on the acl
            rules. The validation should be performed depending on the set
            value:
          </para><para>
            strict-acl-validation=none
            The default setting should be 'warn'
          </para><para>
            On validation of this acl the following checks would be expected:
          </para>
            <programlisting>
acl allow client publish routingkey=exampleQueue exchange=amq.direct
</programlisting>
          <orderedlist>
            <listitem><para>The If the user 'client' cannot be found, if the
            authentication mechanism cannot be queried then a 'user' value
            should be added to the file.
            </para></listitem>
            <listitem><para>There is an exchange called 'amq.direct'
            </para></listitem>
            <listitem><para>There is a queue bound to 'exampleQueue' on 'amq.direct'
            </para></listitem>
          </orderedlist><para>
            Each of these checks that fail will result in a log statement
            being generated.
          </para><para>
            In the case of a fatal logging the full file will be validated
            before the broker shuts down.
          </para>
<!--h3--></section>


	  <section role="h3" id="ACL-Examplefile-3A"><title>
            Example file:
          </title>
          
            <programlisting>

# Some groups
group admin ted@QPID martin@QPID
group user-consume martin@QPID ted@QPID
group group2 kim@QPID user-consume rob@QPID
group publisher group2 \
                tom@QPID andrew@QPID debbie@QPID

# Some rules
acl allow carlt@QPID create exchange name=carl.*
acl deny rob@QPID create queue
acl allow guest@QPID bind exchange name=amq.topic routingkey=stocks.ibm.#  owner=self
acl allow user-consume create queue name=tmp.*

acl allow publisher publish all durable=false
acl allow publisher create queue name=RequestQueue
acl allow consumer consume queue durable=true
acl allow fred@QPID create all
acl allow bob@QPID all queue
acl allow admin all
acl deny kim@QPID all
acl allow all consume queue owner=self
acl allow all bind exchange owner=self

# Last (default) rule
acl deny all all
</programlisting>

<!--h3--></section>
	  <!--h2--></section>

            
          <section role="h2" id="ACL-DesignDocumentation"><title>
            Design Documentation
          </title>
          <section role="h3" id="ACL-MappingofACLtrapstoactionandtype"><title>
            Mapping of ACL
            traps to action and type
          </title>
          <para>
            The C++ broker maps the ACL traps in the follow way for AMQP
            0-10:
            The Java broker currently only performs ACLs on the AMQP
            connection not on management functions:
          </para>

	  <table><title/><tgroup cols="5">
            <thead>
              <row>
                <entry>
                  Object
                </entry>
                <entry>
                  Action
                </entry>
                <entry>
                  Properties
                </entry>
                <entry>
                  Trap C++
                </entry>
                <entry>
                  Trap Java
                </entry>
              </row>
	    </thead>
	    <tbody>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Create
                </entry>
                <entry>
                  name type alternate passive durable
                </entry>
                <entry>
                  ExchangeHandlerImpl::declare
                </entry>
                <entry>
                  ExchangeDeclareHandler
                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Delete
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  ExchangeHandlerImpl::delete
                </entry>
                <entry>
                  ExchangeDeleteHandler
                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Access
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  ExchangeHandlerImpl::query
                </entry>
                <entry>

                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Bind
                </entry>
                <entry>
                  name routingkey queuename owner
                </entry>
                <entry>
                  ExchangeHandlerImpl::bind
                </entry>
                <entry>
                  QueueBindHandler
                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Unbind
                </entry>
                <entry>
                  name routingkey
                </entry>
                <entry>
                  ExchangeHandlerImpl::unbind
                </entry>
                <entry>
                  ExchangeUnbindHandler
                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Access
                </entry>
                <entry>
                  name queuename routingkey
                </entry>
                <entry>
                  ExchangeHandlerImpl::bound
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Exchange
                </entry>
                <entry>
                  Publish
                </entry>
                <entry>
                  name routingKey
                </entry>
                <entry>
                  SemanticState::route
                </entry>
                <entry>
                  BasicPublishMethodHandler
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Access
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  QueueHandlerImpl::query
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Create
                </entry>
                <entry>
                  name alternate passive durable exclusive autodelete
                </entry>
                <entry>
                  QueueHandlerImpl::declare
                </entry>
                <entry>
                  QueueDeclareHandler
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Purge
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  QueueHandlerImpl::purge
                </entry>
                <entry>
                  QueuePurgeHandler
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Purge
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  Management::Queue::purge
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Delete
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  QueueHandlerImpl::delete
                </entry>
                <entry>
                  QueueDeleteHandler
                </entry>
              </row>
              <row>
                <entry>
                  Queue
                </entry>
                <entry>
                  Consume
                </entry>
                <entry>
                  name (possibly add in future?)
                </entry>
                <entry>
                  MessageHandlerImpl::subscribe
                </entry>
                <entry>
                  BasicConsumeMethodHandler
                  BasicGetMethodHandler
                </entry>
              </row>
              <row>
                <entry>
                  &lt;Object&gt;
                </entry>
                <entry>
                  Update
                </entry>
                <entry>
                   
                </entry>
                <entry>
                  ManagementProperty::set
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  &lt;Object&gt;
                </entry>
                <entry>
                  Access
                </entry>
                <entry>
                   
                </entry>
                <entry>
                  ManagementProperty::read
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Link
                </entry>
                <entry>
                  Create
                </entry>
                <entry>
                   
                </entry>
                <entry>
                  Management::connect
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Route
                </entry>
                <entry>
                  Create
                </entry>
                <entry>
                   
                </entry>
                <entry>
                  Management:: -createFederationRoute-
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Route
                </entry>
                <entry>
                  Delete
                </entry>
                <entry>
                   
                </entry>
                <entry>
                  Management:: -deleteFederationRoute-
                </entry>
                <entry>
                  
                </entry>
              </row>
              <row>
                <entry>
                  Virtualhost
                </entry>
                <entry>
                  Access
                </entry>
                <entry>
                  name
                </entry>
                <entry>
                  TBD
                </entry>
                <entry>
                  ConnectionOpenMethodHandler
                </entry>
              </row>
            </tbody>
          </tgroup></table><para>
            Management actions that are not explicitly given a name property
            it will default the name property to management method name, if
            the action is 'W' Action will be 'Update', if 'R' Action will be
            'Access'.
          </para><para>
            for example, if the mgnt method 'joinCluster' was not mapped in
            schema it will be mapped in ACL file as follows
          </para>

	  <table><title/><tgroup cols="3">
            <thead>
              <row>
                <entry>
                  Object
                </entry>
                <entry>
                  Action
                </entry>
                <entry>
                  Property
                </entry>
              </row>
	    </thead>
	    <tbody>
              <row>
                <entry>
                  Broker
                </entry>
                <entry>
                  Update
                </entry>
                <entry>
                  name=joinCluster
                </entry>
              </row>
            </tbody>
          </tgroup></table>

	<!--h3--></section>
	<!--h2--></section>


	<section role="h2" id="ACL-v2ACLUserGuide"><title>
            v2 ACL User Guide
          </title>
          <section role="h3" id="ACL-WritingGood-2FFastACL"><title>
            Writing Good/Fast ACL
          </title>
          <para>
            The file gets read top down and rule get passed based on the
            first match. In the following example the first rule is a dead
            rule. I.e. the second rule is wider than the first rule. DON'T do
            this, it will force extra analysis, worst case if the parser does
            not kill the dead rule you might get a false deny.
          </para>
            <programlisting>
allow peter@QPID create queue name=tmp &lt;-- dead rule!!
allow peter@QPID create queue
deny all all
</programlisting>
          <para>
            By default files end with
          </para>
            <programlisting>
deny all all
</programlisting>
          <para>
            the mode of the ACL engine can be swapped to be allow based by
            putting the following at the end of the file
          </para>
            <programlisting>
allow all all
</programlisting>
          <para>
            Note that 'allow' based file will be a LOT faster for message
            transfer. This is because the AMQP specification does not allow
            for creating subscribes on publish, so the ACL is executed on
            every message transfer. Also, ACL's rules using less properties
            on publish will in general be faster.
          </para>
	  <!--h3--></section>

	  <section role="h3" id="ACL-GettingACLtoLog"><title>
            Getting ACL to Log
          </title>
          <para>
            In order to get log messages from ACL actions use allow-log and
            deny-log for example
          </para>
            <programlisting>
allow-log john@QPID all all
deny-log guest@QPID all all
</programlisting>
	  <!--h3--></section>

          <section role="h3" id="ACL-UserId-2FdomainsrunningwithCbroker"><title>
            User Id /
            domains running with C++ broker
          </title>
          <para>
            The user-id used for ACL is taken from the connection user-id.
            Thus in order to use ACL the broker authentication has to be
            setup. i.e. (if --auth no is used in combination with ACL the
            broker will deny everything)
          </para><para>
            The user id in the ACL file is of the form
            &lt;user-id&gt;@&lt;domain&gt; The Domain is configured via the
            SASL configuration for the broker, and the domain/realm for qpidd
            is set using --realm and default to 'QPID'.
          </para><para>
            To load the ACL module use, load the acl module cmd line or via
            the config file
          </para>
            <programlisting>
./src/qpidd --load-module src/.libs/acl.so
</programlisting>
          <para>
            The ACL plugin provides the following option '--acl-file'. If do
            ACL file is supplied the broker will not enforce ACL. If an ACL
            file name is supplied, and the file does not exist or is invalid
            the broker will not start.
          </para>
            <programlisting>
ACL Options:
  --acl-file FILE       The policy file to load from, loaded from data dir
</programlisting>

	  <!--h3--></section>
	<!--h2--></section>

</chapter>