-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathrabbit.schema
2826 lines (2370 loc) · 94.8 KB
/
rabbit.schema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% vim:ft=erlang:
% ==============================
% Rabbit app section
% ==============================
%%
%% Network Connectivity
%% ====================
%%
%% By default, RabbitMQ will listen on all interfaces, using
%% the standard (reserved) AMQP port.
%%
%% {tcp_listeners, [5672]},
%% To listen on a specific interface, provide a tuple of {IpAddress, Port}.
%% For example, to listen only on localhost for both IPv4 and IPv6:
%%
%% {tcp_listeners, [{"127.0.0.1", 5672},
%% {"[::1]", 5672}]},
{mapping, "listeners.tcp", "rabbit.tcp_listeners",[
{datatype, {enum, [none]}}
]}.
{mapping, "listeners.tcp.$name", "rabbit.tcp_listeners",[
{datatype, [integer, ip]}
]}.
{translation, "rabbit.tcp_listeners",
fun(Conf) ->
case cuttlefish:conf_get("listeners.tcp", Conf, undefined) of
none -> [];
_ ->
Settings = cuttlefish_variable:filter_by_prefix("listeners.tcp", Conf),
[ V || {_, V} <- Settings ]
end
end}.
%% TLS listeners are configured in the same fashion as TCP listeners,
%% including the option to control the choice of interface.
%%
%% {ssl_listeners, [5671]},
{mapping, "listeners.ssl", "rabbit.ssl_listeners",[
{datatype, {enum, [none]}}
]}.
{mapping, "listeners.ssl.$name", "rabbit.ssl_listeners",[
{datatype, [integer, ip]}
]}.
{translation, "rabbit.ssl_listeners",
fun(Conf) ->
case cuttlefish:conf_get("listeners.ssl", Conf, undefined) of
none -> [];
_ ->
Settings = cuttlefish_variable:filter_by_prefix("listeners.ssl", Conf),
[ V || {_, V} <- Settings ]
end
end}.
%% Number of Erlang processes that will accept connections for the TCP
%% and TLS listeners.
%%
%% {num_tcp_acceptors, 10},
%% {num_ssl_acceptors, 1},
{mapping, "num_acceptors.ssl", "rabbit.num_ssl_acceptors", [
{datatype, integer}
]}.
{mapping, "num_acceptors.tcp", "rabbit.num_tcp_acceptors", [
{datatype, integer}
]}.
{mapping, "socket_writer.gc_threshold", "rabbit.writer_gc_threshold", [
{datatype, [{atom, off}, integer]}
]}.
{translation, "rabbit.writer_gc_threshold",
fun(Conf) ->
case cuttlefish:conf_get("socket_writer.gc_threshold", Conf, undefined) of
%% missing from the config
undefined -> cuttlefish:unset();
%% explicitly disabled
off -> undefined;
Int when is_integer(Int) andalso Int > 0 ->
Int;
_ ->
cuttlefish:invalid("should be a non-negative integer")
end
end
}.
%% Maximum time for 0-9-1 handshake (after socket connection
%% and TLS handshake), in milliseconds.
%%
%% {handshake_timeout, 10000},
{mapping, "handshake_timeout", "rabbit.handshake_timeout", [
{datatype, [{atom, infinity}, integer]}
]}.
%% Set to 'true' to perform reverse DNS lookups when accepting a
%% connection. Hostnames will then be shown instead of IP addresses
%% in rabbitmqctl and the management plugin.
%%
%% {reverse_dns_lookups, true},
{mapping, "reverse_dns_lookups", "rabbit.reverse_dns_lookups", [
{datatype, {enum, [true, false]}}
]}.
{mapping, "erlang.K", "vm_args.+K", [
{default, "true"},
{level, advanced}
]}.
%%
%% Definition import
%%
%% Original key for definition loading from a JSON file or directory of files. See
%% https://www.rabbitmq.com/docs/management#load-definitions
{mapping, "load_definitions", "rabbit.load_definitions",
[{datatype, string},
{validators, ["file_accessible"]}]}.
%% Newer syntax for definition loading from a JSON file or directory of files. See
%% https://www.rabbitmq.com/docs/management#load-definitions
{mapping, "definitions.local.path", "rabbit.definitions.local_path",
[{datatype, string},
{validators, ["file_accessible"]}]}.
%% Extensive mechanism for loading definitions from a remote source
{mapping, "definitions.import_backend", "rabbit.definitions.import_backend", [
{datatype, atom}
]}.
{translation, "rabbit.definitions.import_backend",
fun(Conf) ->
case cuttlefish:conf_get("definitions.import_backend", Conf, rabbit_definitions_import_local_filesystem) of
%% short aliases for known backends
local_filesystem -> rabbit_definitions_import_local_filesystem;
local -> rabbit_definitions_import_local_filesystem;
https -> rabbit_definitions_import_https;
http -> rabbit_definitions_import_https;
%% accept both rabbitmq_ and rabbit_ (typical core module prefix)
rabbitmq_definitions_import_local_filesystem -> rabbit_definitions_import_local_filesystem;
rabbitmq_definitions_import_http -> rabbit_definitions_import_https;
%% any other value is used as is
Module -> Module
end
end}.
{mapping, "definitions.skip_if_unchanged", "rabbit.definitions.skip_if_unchanged", [
{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.hashing.algorithm", "rabbit.definitions.hashing_algorithm", [
{datatype, {enum, [sha, sha224, sha256, sha384, sha512]}}]}.
%% Load definitions from a remote URL over HTTPS. See
%% https://www.rabbitmq.com/docs/management#load-definitions
{mapping, "definitions.https.url", "rabbit.definitions.url",
[{datatype, string}]}.
%% Client-side TLS settings used by e.g. HTTPS definition loading mechanism.
%% These can be reused by other clients.
{mapping, "definitions.tls.verify", "rabbit.definitions.ssl_options.verify", [
{datatype, {enum, [verify_peer, verify_none]}}]}.
{mapping, "definitions.tls.fail_if_no_peer_cert", "rabbit.definitions.ssl_options.fail_if_no_peer_cert", [
{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.tls.cacertfile", "rabbit.definitions.ssl_options.cacertfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "definitions.tls.certfile", "rabbit.definitions.ssl_options.certfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "definitions.tls.cacerts.$name", "rabbit.definitions.ssl_options.cacerts",
[{datatype, string}]}.
{translation, "rabbit.definitions.ssl_options.cacerts",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("definitions.tls.cacerts", Conf),
[ list_to_binary(V) || {_, V} <- Settings ]
end}.
{mapping, "definitions.tls.cert", "rabbit.definitions.ssl_options.cert",
[{datatype, string}]}.
{translation, "rabbit.definitions.ssl_options.cert",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("definitions.tls.cert", Conf))
end}.
{mapping, "definitions.tls.reuse_session", "rabbit.definitions.ssl_options.reuse_session",
[{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.tls.crl_check", "rabbit.definitions.ssl_options.crl_check",
[{datatype, [{enum, [true, false, peer, best_effort]}]}]}.
{mapping, "definitions.tls.depth", "rabbit.definitions.ssl_options.depth",
[{datatype, integer}, {validators, ["byte"]}]}.
{mapping, "definitions.tls.dh", "rabbit.definitions.ssl_options.dh",
[{datatype, string}]}.
{translation, "rabbit.definitions.ssl_options.dh",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("definitions.tls.dh", Conf))
end}.
{translation, "rabbit.definitions.ssl_options.key",
fun(Conf) ->
case cuttlefish_variable:filter_by_prefix("definitions.tls.key", Conf) of
[{[_,_,Key], Val}|_] -> {list_to_atom(Key), list_to_binary(Val)};
_ -> cuttlefish:unset()
end
end}.
{mapping, "definitions.tls.keyfile", "rabbit.definitions.ssl_options.keyfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "definitions.tls.log_alert", "rabbit.definitions.ssl_options.log_alert",
[{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.tls.password", "rabbit.definitions.ssl_options.password",
[{datatype, [tagged_binary, binary]}]}.
{translation, "rabbit.definitions.ssl_options.password",
fun(Conf) ->
rabbit_cuttlefish:optionally_tagged_string("definitions.tls.password", Conf)
end}.
{mapping, "definitions.tls.secure_renegotiate", "rabbit.definitions.ssl_options.secure_renegotiate",
[{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.tls.reuse_sessions", "rabbit.definitions.ssl_options.reuse_sessions",
[{datatype, {enum, [true, false]}}]}.
{mapping, "definitions.tls.versions.$version", "rabbit.definitions.ssl_options.versions",
[{datatype, atom}]}.
{translation, "rabbit.definitions.ssl_options.versions",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("definitions.tls.versions", Conf),
[V || {_, V} <- Settings]
end}.
{mapping, "definitions.tls.ciphers.$cipher", "rabbit.definitions.ssl_options.ciphers",
[{datatype, string}]}.
{translation, "rabbit.definitions.ssl_options.ciphers",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("definitions.tls.ciphers", Conf),
lists:reverse([V || {_, V} <- Settings])
end}.
{mapping, "definitions.tls.log_level", "rabbit.definitions.ssl_options.log_level",
[{datatype, {enum, [emergency, alert, critical, error, warning, notice, info, debug]}}]}.
%%
%% Seed User, Authentication, Access Control
%%
%% The default "guest" user is only permitted to access the server
%% via a loopback interface (e.g. localhost).
%% {loopback_users, [<<"guest">>]},
%%
%% Uncomment the following line if you want to allow access to the
%% guest user from anywhere on the network.
%% {loopback_users, []},
{mapping, "loopback_users", "rabbit.loopback_users", [
{datatype, {enum, [none]}}
]}.
{mapping, "loopback_users.$user", "rabbit.loopback_users", [
{datatype, atom}
]}.
{translation, "rabbit.loopback_users",
fun(Conf) ->
None = cuttlefish:conf_get("loopback_users", Conf, undefined),
case None of
none -> [];
_ ->
Settings = cuttlefish_variable:filter_by_prefix("loopback_users", Conf),
[ list_to_binary(U) || {["loopback_users", U], V} <- Settings, V == true ]
end
end}.
%% TLS options.
%% See https://www.rabbitmq.com/docs/ssl for full documentation.
%%
%% {ssl_options, [{cacertfile, "/path/to/testca/cacert.pem"},
%% {certfile, "/path/to/server/cert.pem"},
%% {keyfile, "/path/to/server/key.pem"},
%% {verify, verify_peer},
%% {fail_if_no_peer_cert, false}]},
{mapping, "ssl_allow_poodle_attack", "rabbit.ssl_allow_poodle_attack",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options", "rabbit.ssl_options", [
{datatype, {enum, [none]}}
]}.
{translation, "rabbit.ssl_options",
fun(Conf) ->
case cuttlefish:conf_get("ssl_options", Conf, undefined) of
none -> [];
_ -> cuttlefish:invalid("Invalid ssl_options")
end
end}.
{mapping, "ssl_options.verify", "rabbit.ssl_options.verify", [
{datatype, {enum, [verify_peer, verify_none]}}]}.
{mapping, "ssl_options.fail_if_no_peer_cert", "rabbit.ssl_options.fail_if_no_peer_cert", [
{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.cacertfile", "rabbit.ssl_options.cacertfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "ssl_options.certfile", "rabbit.ssl_options.certfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "ssl_options.cacerts.$name", "rabbit.ssl_options.cacerts",
[{datatype, string}]}.
{translation, "rabbit.ssl_options.cacerts",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("ssl_options.cacerts", Conf),
[ list_to_binary(V) || {_, V} <- Settings ]
end}.
{mapping, "ssl_options.cert", "rabbit.ssl_options.cert",
[{datatype, string}]}.
{translation, "rabbit.ssl_options.cert",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("ssl_options.cert", Conf))
end}.
{mapping, "ssl_options.client_renegotiation", "rabbit.ssl_options.client_renegotiation",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.crl_check", "rabbit.ssl_options.crl_check",
[{datatype, [{enum, [true, false, peer, best_effort]}]}]}.
{mapping, "ssl_options.depth", "rabbit.ssl_options.depth",
[{datatype, integer}, {validators, ["byte"]}]}.
{mapping, "ssl_options.dh", "rabbit.ssl_options.dh",
[{datatype, string}]}.
{translation, "rabbit.ssl_options.dh",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("ssl_options.dh", Conf))
end}.
{mapping, "ssl_options.dhfile", "rabbit.ssl_options.dhfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "ssl_options.honor_cipher_order", "rabbit.ssl_options.honor_cipher_order",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.honor_ecc_order", "rabbit.ssl_options.honor_ecc_order",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.key.RSAPrivateKey", "rabbit.ssl_options.key",
[{datatype, string}]}.
{mapping, "ssl_options.key.DSAPrivateKey", "rabbit.ssl_options.key",
[{datatype, string}]}.
{mapping, "ssl_options.key.PrivateKeyInfo", "rabbit.ssl_options.key",
[{datatype, string}]}.
{translation, "rabbit.ssl_options.key",
fun(Conf) ->
case cuttlefish_variable:filter_by_prefix("ssl_options.key", Conf) of
[{[_,_,Key], Val}|_] -> {list_to_atom(Key), list_to_binary(Val)};
_ -> cuttlefish:unset()
end
end}.
{mapping, "ssl_options.keyfile", "rabbit.ssl_options.keyfile",
[{datatype, string}, {validators, ["file_accessible"]}]}.
{mapping, "ssl_options.log_level", "rabbit.ssl_options.log_level",
[{datatype, {enum, [emergency, alert, critical, error, warning, notice, info, debug]}}]}.
{mapping, "ssl_options.log_alert", "rabbit.ssl_options.log_alert",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.password", "rabbit.ssl_options.password",
[{datatype, [tagged_binary, binary]}]}.
{translation, "rabbit.ssl_options.password",
fun(Conf) ->
rabbit_cuttlefish:optionally_tagged_binary("ssl_options.password", Conf)
end}.
{mapping, "ssl_options.psk_identity", "rabbit.ssl_options.psk_identity",
[{datatype, string}]}.
{mapping, "ssl_options.reuse_sessions", "rabbit.ssl_options.reuse_sessions",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.secure_renegotiate", "rabbit.ssl_options.secure_renegotiate",
[{datatype, {enum, [true, false]}}]}.
{mapping, "ssl_options.versions.$version", "rabbit.ssl_options.versions",
[{datatype, atom}]}.
{translation, "rabbit.ssl_options.versions",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("ssl_options.versions", Conf),
[V || {_, V} <- Settings]
end}.
{mapping, "ssl_options.ciphers.$cipher", "rabbit.ssl_options.ciphers",
[{datatype, string}]}.
{translation, "rabbit.ssl_options.ciphers",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("ssl_options.ciphers", Conf),
lists:reverse([V || {_, V} <- Settings])
end}.
{mapping, "ssl_options.bypass_pem_cache", "ssl.bypass_pem_cache",
[{datatype, {enum, [true, false]}}]}.
{mapping, "metadata_store.khepri.default_timeout", "rabbit.khepri_default_timeout",
[{datatype, integer}]}.
%% ===========================================================================
%% Choose the available SASL mechanism(s) to expose.
%% The three default (built in) mechanisms are 'PLAIN', 'AMQPLAIN' and 'ANONYMOUS'.
%% Additional mechanisms can be added via plugins.
%%
%% See https://www.rabbitmq.com/docs/access-control for more details.
%%
%% {auth_mechanisms, ['PLAIN', 'AMQPLAIN', 'ANONYMOUS']},
{mapping, "auth_mechanisms.$name", "rabbit.auth_mechanisms", [
{datatype, atom}]}.
{translation, "rabbit.auth_mechanisms",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("auth_mechanisms", Conf),
Sorted = lists:keysort(1, Settings),
[V || {_, V} <- Sorted]
end}.
%% Select an authentication backend to use. RabbitMQ provides an
%% internal backend in the core.
%%
%% {auth_backends, [rabbit_auth_backend_internal]},
{translation, "rabbit.auth_backends",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("auth_backends", Conf),
BackendModule = fun
(internal) -> rabbit_auth_backend_internal;
(ldap) -> rabbit_auth_backend_ldap;
(http) -> rabbit_auth_backend_http;
(oauth) -> rabbit_auth_backend_oauth2;
(oauth2) -> rabbit_auth_backend_oauth2;
(cache) -> rabbit_auth_backend_cache;
(amqp) -> rabbit_auth_backend_amqp;
(dummy) -> rabbit_auth_backend_dummy;
(Other) when is_atom(Other) -> Other;
(_) -> cuttlefish:invalid("Unknown/unsupported auth backend")
end,
AuthBackends = [{Num, {default, BackendModule(V)}} || {["auth_backends", Num], V} <- Settings],
AuthNBackends = [{Num, {authn, BackendModule(V)}} || {["auth_backends", Num, "authn"], V} <- Settings],
AuthZBackends = [{Num, {authz, BackendModule(V)}} || {["auth_backends", Num, "authz"], V} <- Settings],
Backends = lists:foldl(
fun({NumStr, {Type, V}}, Acc) ->
Num = case catch list_to_integer(NumStr) of
N when is_integer(N) -> N;
Err ->
cuttlefish:invalid(
iolist_to_binary(io_lib:format(
"Auth backend position in the chain should be an integer ~p", [Err])))
end,
NewVal = case dict:find(Num, Acc) of
{ok, {AuthN, AuthZ}} ->
case {Type, AuthN, AuthZ} of
{authn, undefined, _} ->
{V, AuthZ};
{authz, _, undefined} ->
{AuthN, V};
_ ->
cuttlefish:invalid(
iolist_to_binary(
io_lib:format(
"Auth backend already defined for the ~pth ~p backend",
[Num, Type])))
end;
error ->
case Type of
authn -> {V, undefined};
authz -> {undefined, V};
default -> {V, V}
end
end,
dict:store(Num, NewVal, Acc)
end,
dict:new(),
AuthBackends ++ AuthNBackends ++ AuthZBackends),
lists:map(
fun
({Num, {undefined, AuthZ}}) ->
cuttlefish:warn(
io_lib:format(
"Auth backend undefined for the ~pth authz backend. Using ~p",
[Num, AuthZ])),
{AuthZ, AuthZ};
({Num, {AuthN, undefined}}) ->
cuttlefish:warn(
io_lib:format(
"Authz backend undefined for the ~pth authn backend. Using ~p",
[Num, AuthN])),
{AuthN, AuthN};
({_Num, {Auth, Auth}}) -> Auth;
({_Num, {AuthN, AuthZ}}) -> {AuthN, AuthZ}
end,
lists:keysort(1, dict:to_list(Backends)))
end}.
{mapping, "auth_backends.$num", "rabbit.auth_backends", [
{datatype, atom}
]}.
{mapping, "auth_backends.$num.authn", "rabbit.auth_backends",[
{datatype, atom}
]}.
{mapping, "auth_backends.$num.authz", "rabbit.auth_backends",[
{datatype, atom}
]}.
%% This pertains to both the rabbitmq_auth_mechanism_ssl plugin and
%% STOMP ssl_cert_login configurations. See the rabbitmq_stomp
%% configuration section later in this file and the README in
%% https://github.com/rabbitmq/rabbitmq-auth-mechanism-ssl for further
%% details.
%%
%% To use the peer certificate's Common Name (CN) field
%% instead of its Distinguished Name (DN) for username extraction.
%%
%% {ssl_cert_login_from, common_name},
%%
%% To use the first SAN value of type DNS:
%%
%% {ssl_cert_login_from, subject_alternative_name},
%% {ssl_cert_login_san_type, dns},
%% {ssl_cert_login_san_index, 0}
{mapping, "ssl_cert_login_from", "rabbit.ssl_cert_login_from", [
{datatype, {enum, [distinguished_name, common_name, subject_alternative_name, subject_alt_name]}}
]}.
{mapping, "ssl_cert_login_san_type", "rabbit.ssl_cert_login_san_type", [
{datatype, {enum, [dns, ip, email, uri, other_name]}}
]}.
{mapping, "ssl_cert_login_san_index", "rabbit.ssl_cert_login_san_index", [
{datatype, integer}, {validators, ["non_negative_integer"]}
]}.
%% TLS handshake timeout, in milliseconds.
%%
%% {ssl_handshake_timeout, 5000},
{mapping, "ssl_handshake_timeout", "rabbit.ssl_handshake_timeout", [
{datatype, integer}
]}.
%% Cluster name
{mapping, "cluster_name", "rabbit.cluster_name", [
{datatype, string}
]}.
%% Default worker process pool size. Used to limit maximum concurrency rate
%% of certain operations, e.g. queue initialisation and recovery on node boot.
{mapping, "default_worker_pool_size", "rabbit.default_worker_pool_size", [
{datatype, integer}, {validators, ["non_negative_integer"]}
]}.
%% Password hashing implementation. Will only affect newly
%% created users. To recalculate hash for an existing user
%% it's necessary to update her password.
%%
%% When importing definitions exported from versions earlier
%% than 3.6.0, it is possible to go back to MD5 (only do this
%% as a temporary measure!) by setting this to rabbit_password_hashing_md5.
%%
%% To use SHA-512, set to rabbit_password_hashing_sha512.
%%
%% {password_hashing_module, rabbit_password_hashing_sha256},
{mapping, "password_hashing_module", "rabbit.password_hashing_module", [
{datatype, atom}
]}.
%% Credential validation.
%%
{mapping, "credential_validator.validation_backend", "rabbit.credential_validator.validation_backend", [
{datatype, atom}
]}.
{mapping, "credential_validator.min_length", "rabbit.credential_validator.min_length", [
{datatype, integer}, {validators, ["non_negative_integer"]}
]}.
{mapping, "credential_validator.regexp", "rabbit.credential_validator.regexp", [
{datatype, string}
]}.
%%
%% Default User / VHost
%% ====================
%%
%% On first start RabbitMQ will create a vhost and a user. These
%% config items control what gets created. See
%% https://www.rabbitmq.com/docs/access-control for further
%% information about vhosts and access control.
%%
%% {default_vhost, <<"/">>},
%% {default_user, <<"guest">>},
%% {default_pass, <<"guest">>},
%% {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
{mapping, "default_vhost", "rabbit.default_vhost", [
{datatype, string}
]}.
{translation, "rabbit.default_vhost",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("default_vhost", Conf))
end}.
{mapping, "default_user", "rabbit.default_user", [
{datatype, string}
]}.
{translation, "rabbit.default_user",
fun(Conf) ->
list_to_binary(cuttlefish:conf_get("default_user", Conf))
end}.
{mapping, "default_pass", "rabbit.default_pass", [
{datatype, [tagged_binary, binary]}
]}.
{translation, "rabbit.default_pass",
fun(Conf) ->
rabbit_cuttlefish:optionally_tagged_binary("default_pass", Conf)
end}.
{mapping, "default_permissions.configure", "rabbit.default_permissions", [
{datatype, string}
]}.
{mapping, "default_permissions.read", "rabbit.default_permissions", [
{datatype, string}
]}.
{mapping, "default_permissions.write", "rabbit.default_permissions", [
{datatype, string}
]}.
{translation, "rabbit.default_permissions",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("default_permissions", Conf),
Configure = proplists:get_value(["default_permissions", "configure"], Settings),
Read = proplists:get_value(["default_permissions", "read"], Settings),
Write = proplists:get_value(["default_permissions", "write"], Settings),
[list_to_binary(Configure), list_to_binary(Read), list_to_binary(Write)]
end}.
%%
%% Extra Default Users
%% ====================
%%
{mapping, "default_users.$name.vhost_pattern", "rabbit.default_users", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_users.$name.password", "rabbit.default_users", [
{datatype, [tagged_binary, binary]}
]}.
{mapping, "default_users.$name.configure", "rabbit.default_users", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_users.$name.read", "rabbit.default_users", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_users.$name.write", "rabbit.default_users", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_users.$name.tags", "rabbit.default_users", [
{datatype, {list, atom}}
]}.
{translation, "rabbit.default_users", fun(Conf) ->
case rabbit_cuttlefish:aggregate_props(Conf, ["default_users"]) of
[] -> cuttlefish:unset();
Props -> Props
end
end}.
%% Connections that skip SASL layer or use SASL mechanism ANONYMOUS will use this identity.
%% Setting this to a username will allow (anonymous) clients to connect and act as this
%% given user. For production environments, set this value to 'none'.
{mapping, "anonymous_login_user", "rabbit.anonymous_login_user",
[{datatype, [{enum, [none]}, binary]}]}.
{mapping, "anonymous_login_pass", "rabbit.anonymous_login_pass", [
{datatype, [tagged_binary, binary]}
]}.
{translation, "rabbit.anonymous_login_pass",
fun(Conf) ->
rabbit_cuttlefish:optionally_tagged_binary("anonymous_login_pass", Conf)
end}.
%%
%% Default Policies
%% ====================
%%
{mapping, "default_policies.operator.$id.vhost_pattern", "rabbit.default_policies.operator", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_policies.operator.$id.queue_pattern", "rabbit.default_policies.operator", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_policies.operator.$id.expires", "rabbit.default_policies.operator", [
{datatype, {duration, ms}}
]}.
{mapping, "default_policies.operator.$id.message_ttl", "rabbit.default_policies.operator", [
{datatype, {duration, ms}}
]}.
{mapping, "default_policies.operator.$id.max_length", "rabbit.default_policies.operator", [
{validators, ["non_zero_positive_integer"]},
{datatype, integer}
]}.
{mapping, "default_policies.operator.$id.max_length_bytes", "rabbit.default_policies.operator", [
{validators, ["non_zero_positive_integer"]},
{datatype, bytesize}
]}.
{mapping, "default_policies.operator.$id.max_in_memory_bytes", "rabbit.default_policies.operator", [
{validators, ["non_zero_positive_integer"]},
{datatype, bytesize}
]}.
{mapping, "default_policies.operator.$id.max_in_memory_length", "rabbit.default_policies.operator",
[
{validators, ["non_zero_positive_integer"]},
{datatype, integer}
]}.
{mapping, "default_policies.operator.$id.delivery_limit", "rabbit.default_policies.operator", [
{validators, ["non_zero_positive_integer"]},
{datatype, integer}
]}.
{mapping, "default_policies.operator.$id.classic_queues.ha_mode", "rabbit.default_policies.operator", [
{datatype, string}
]}.
{mapping, "default_policies.operator.$id.classic_queues.ha_params", "rabbit.default_policies.operator", [
{datatype, [integer, {list, string}]}
]}.
{mapping, "default_policies.operator.$id.classic_queues.ha_sync_mode", "rabbit.default_policies.operator", [
{datatype, string}
]}.
{mapping, "default_policies.operator.$id.classic_queues.queue_version", "rabbit.default_policies.operator",
[
{validators, ["non_zero_positive_integer"]},
{datatype, integer}
]}.
{translation, "rabbit.default_policies.operator", fun(Conf) ->
Props = rabbit_cuttlefish:aggregate_props(
Conf,
["default_policies", "operator"],
fun({["default_policies","operator",ID,"classic_queues"|T], V}) ->
NewV = case T of
["ha_sync_mode"] ->
list_to_binary(V);
["ha_mode"] ->
list_to_binary(V);
_ -> V
end,
{["default_policies","operator",ID|T], NewV};
({["default_policies","operator",ID, "queue_pattern"], V}) ->
{["default_policies","operator",ID,"queue_pattern"], list_to_binary(V)};
(E) -> E
end),
case Props of
[] -> cuttlefish:unset();
Props -> Props
end
end}.
%%
%% Default VHost Limits
%% ====================
%%
{mapping, "default_limits.vhosts.$id.pattern", "rabbit.default_limits.vhosts", [
{validators, ["valid_regex"]},
{datatype, string}
]}.
{mapping, "default_limits.vhosts.$id.max_connections", "rabbit.default_limits.vhosts", [
{validators, [ "non_zero_positive_integer"]},
{datatype, integer}
]}.
{mapping, "default_limits.vhosts.$id.max_queues", "rabbit.default_limits.vhosts", [
{validators, [ "non_zero_positive_integer"]},
{datatype, integer}
]}.
{translation, "rabbit.default_limits.vhosts", fun(Conf) ->
case rabbit_cuttlefish:aggregate_props(Conf, ["default_limits", "vhosts"]) of
[] -> cuttlefish:unset();
Props -> Props
end
end}.
%% Tags for default user
%%
%% For more details about tags, see the documentation for the
%% Management Plugin at https://www.rabbitmq.com/docs/management.
%%
%% {default_user_tags, [administrator]},
{mapping, "default_user_tags.$tag", "rabbit.default_user_tags",
[{datatype, {enum, [true, false]}}]}.
{translation, "rabbit.default_user_tags",
fun(Conf) ->
Settings = cuttlefish_variable:filter_by_prefix("default_user_tags", Conf),
[ list_to_atom(Key) || {[_,Key], Val} <- Settings, Val == true ]
end}.
%%
%% Additional network and protocol related configuration
%% =====================================================
%%
%% Set the default connection heartbeat timeout (in seconds).
%%
%% {heartbeat, 600},
{mapping, "heartbeat", "rabbit.heartbeat", [{datatype, integer}]}.
%% Set the max permissible size of an AMQP 0-9-1 frame (in bytes).
%%
%% {frame_max, 131072},
{mapping, "frame_max", "rabbit.frame_max", [{datatype, bytesize}]}.
%% Set the max frame size the server will accept before connection
%% tuning starts
%%
%% {initial_frame_max, 4096},
{mapping, "initial_frame_max", "rabbit.initial_frame_max", [{datatype, bytesize}]}.
%% Set the max permissible number of channels per connection.
%% 0 means "no limit".
%%
%% {channel_max, 0},
{mapping, "channel_max", "rabbit.channel_max", [{datatype, integer}]}.
{mapping, "channel_max_per_node", "rabbit.channel_max_per_node",
[{datatype, [{atom, infinity}, integer]}]}.
{translation, "rabbit.channel_max_per_node",
fun(Conf) ->
case cuttlefish:conf_get("channel_max_per_node", Conf, undefined) of
undefined -> cuttlefish:unset();
infinity -> infinity;
Val when is_integer(Val) andalso Val > 0 -> Val;
_ -> cuttlefish:invalid("should be positive integer or 'infinity'")
end
end
}.
%% Set the max allowed number of consumers per channel.
%% `infinity` means "no limit".
%%
%% {consumer_max_per_channel, infinity},
{mapping, "consumer_max_per_channel", "rabbit.consumer_max_per_channel",
[{datatype, [{atom, infinity}, integer]}]}.
{translation, "rabbit.consumer_max_per_channel",
fun(Conf) ->
case cuttlefish:conf_get("consumer_max_per_channel", Conf, undefined) of
undefined -> cuttlefish:unset();
infinity -> infinity;
Val when is_integer(Val) andalso Val > 0 -> Val;
_ -> cuttlefish:invalid("should be positive integer or 'infinity'")
end
end
}.
%% Sets the maximum number of AMQP 1.0 sessions that can be simultaneously
%% active on an AMQP 1.0 connection.
%%
%% {session_max_per_connection, 1},
{mapping, "session_max_per_connection", "rabbit.session_max_per_connection",
[{datatype, integer}, {validators, ["positive_16_bit_unsigned_integer"]}]}.
%% Sets the maximum number of AMQP 1.0 links that can be simultaneously
%% active on an AMQP 1.0 session.
%%
%% {link_max_per_session, 10},
{mapping, "link_max_per_session", "rabbit.link_max_per_session",
[{datatype, integer}, {validators, ["positive_32_bit_unsigned_integer"]}]}.
%% Set the max permissible number of client connections per node.
%% `infinity` means "no limit".
%%
%% {connection_max, infinity},
{mapping, "connection_max", "rabbit.connection_max",
[{datatype, [{atom, infinity}, integer]}]}.
{translation, "rabbit.connection_max",
fun(Conf) ->
case cuttlefish:conf_get("connection_max", Conf, undefined) of
undefined -> cuttlefish:unset();
infinity -> infinity;
Val when is_integer(Val) -> Val;
_ -> cuttlefish:invalid("should be a non-negative integer")
end
end
}.
{mapping, "ranch_connection_max", "rabbit.ranch_connection_max",
[{datatype, [{atom, infinity}, integer]}]}.
{translation, "rabbit.ranch_connection_max",
fun(Conf) ->
case cuttlefish:conf_get("ranch_connection_max", Conf, undefined) of
undefined -> cuttlefish:unset();
infinity -> infinity;
Val when is_integer(Val) -> Val;
_ -> cuttlefish:invalid("should be a non-negative integer")
end
end
}.
{mapping, "vhost_max", "rabbit.vhost_max",
[{datatype, [{atom, infinity}, integer]}, {validators, ["non_negative_integer"]}]}.