Skip to content

Commit eb3d546

Browse files
author
Morgan Haskel
committed
Merge pull request #312 from cmurphy/fix_305
Make LDAP section more configurable
2 parents 50b9eb3 + ed77028 commit eb3d546

5 files changed

Lines changed: 36 additions & 13 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ LDAP server to use for auth.
239239

240240
User DN pattern for LDAP auth.
241241

242+
####`ldap_other_bind`
243+
244+
How to bind to the LDAP server. Defaults to 'anon'.
245+
246+
####`ldap_config_variables`
247+
248+
Hash of other LDAP config variables.
249+
242250
####`ldap_use_ssl`
243251

244252
Boolean, set to true to use SSL for the LDAP server.

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
$ldap_auth = $rabbitmq::params::ldap_auth,
5050
$ldap_server = $rabbitmq::params::ldap_server,
5151
$ldap_user_dn_pattern = $rabbitmq::params::ldap_user_dn_pattern,
52+
$ldap_other_bind = $rabbitmq::params::ldap_other_bind,
5253
$ldap_use_ssl = $rabbitmq::params::ldap_use_ssl,
5354
$ldap_port = $rabbitmq::params::ldap_port,
5455
$ldap_log = $rabbitmq::params::ldap_log,
56+
$ldap_config_variables = $rabbitmq::params::ldap_config_variables,
5557
$stomp_port = $rabbitmq::params::stomp_port,
5658
$version = $rabbitmq::params::version,
5759
$wipe_db_on_cookie_change = $rabbitmq::params::wipe_db_on_cookie_change,
@@ -108,6 +110,8 @@
108110
validate_bool($ldap_auth)
109111
validate_string($ldap_server)
110112
validate_string($ldap_user_dn_pattern)
113+
validate_string($ldap_other_bind)
114+
validate_hash($ldap_config_variables)
111115
validate_bool($ldap_use_ssl)
112116
validate_re($ldap_port, '\d+')
113117
validate_bool($ldap_log)

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@
105105
$ldap_auth = false
106106
$ldap_server = 'ldap'
107107
$ldap_user_dn_pattern = 'cn=username,ou=People,dc=example,dc=com'
108+
$ldap_other_bind = 'anon'
108109
$ldap_use_ssl = false
109110
$ldap_port = '389'
110111
$ldap_log = false
112+
$ldap_config_variables = {}
111113
$stomp_port = '6163'
112114
$wipe_db_on_cookie_change = false
113115
$cluster_partition_handling = 'ignore'

spec/classes/rabbitmq_spec.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,15 @@
404404

405405
describe 'configuring ldap authentication' do
406406
let :params do
407-
{ :config_stomp => true,
408-
:ldap_auth => true,
409-
:ldap_server => 'ldap.example.com',
410-
:ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
411-
:ldap_use_ssl => false,
412-
:ldap_port => '389',
413-
:ldap_log => true
407+
{ :config_stomp => true,
408+
:ldap_auth => true,
409+
:ldap_server => 'ldap.example.com',
410+
:ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
411+
:ldap_other_bind => 'as_user',
412+
:ldap_use_ssl => false,
413+
:ldap_port => '389',
414+
:ldap_log => true,
415+
:ldap_config_variables => { 'foo' => 'bar' }
414416
}
415417
end
416418

@@ -419,10 +421,10 @@
419421
it 'should contain ldap parameters' do
420422
verify_contents(subject, 'rabbitmq.config',
421423
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
422-
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, anon},',
424+
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
423425
' {servers, ["ldap.example.com"]},',
424426
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
425-
' {port, 389},', ' {log, true}'])
427+
' {port, 389},', ' {foo, bar},', ' {log, true}'])
426428
end
427429
end
428430

@@ -432,9 +434,11 @@
432434
:ldap_auth => true,
433435
:ldap_server => 'ldap.example.com',
434436
:ldap_user_dn_pattern => 'ou=users,dc=example,dc=com',
437+
:ldap_other_bind => 'as_user',
435438
:ldap_use_ssl => false,
436439
:ldap_port => '389',
437-
:ldap_log => true
440+
:ldap_log => true,
441+
:ldap_config_variables => { 'foo' => 'bar' }
438442
}
439443
end
440444

@@ -443,10 +447,10 @@
443447
it 'should contain ldap parameters' do
444448
verify_contents(subject, 'rabbitmq.config',
445449
['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
446-
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, anon},',
450+
' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
447451
' {servers, ["ldap.example.com"]},',
448452
' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
449-
' {port, 389},', ' {log, true}'])
453+
' {port, 389},', ' {foo, bar},', ' {log, true}'])
450454
end
451455
end
452456

templates/rabbitmq.config.erb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,16 @@
8181
<%- if @ldap_auth -%>,
8282
% Configure the LDAP authentication plugin
8383
{rabbitmq_auth_backend_ldap, [
84-
{other_bind, anon},
84+
{other_bind, <%= @ldap_other_bind %>},
8585
{servers, ["<%= @ldap_server %>"]},
8686
{user_dn_pattern, "<%= @ldap_user_dn_pattern %>"},
8787
{use_ssl, <%= @ldap_use_ssl %>},
8888
{port, <%= @ldap_port %>},
89+
<% if @ldap_config_variables -%>
90+
<%- @ldap_config_variables.keys.sort.each do |key| -%>
91+
{<%= key %>, <%= @ldap_config_variables[key] %>},
92+
<%- end -%>
93+
<%- end -%>
8994
{log, <%= @ldap_log %>}
9095
]}
9196
<%- end -%>

0 commit comments

Comments
 (0)