Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 2d44b4a

Browse files
Allow auth_ldap.dn_lookup_bind to be set to anon in rabbitmq.conf, closes #94
[#158471902]
1 parent 1ae3acb commit 2d44b4a

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

priv/schema/rabbitmq_auth_backend_ldap.schema

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,25 @@ end}.
106106
[{datatype, [{enum, [none]}, string]}]}.
107107

108108
{mapping, "auth_ldap.dn_lookup_bind", "rabbitmq_auth_backend_ldap.dn_lookup_bind",
109-
[{datatype, [{enum, [as_user]}]}]}.
109+
[{datatype, [{enum, [as_user, anon]}]}]}.
110110

111111
{mapping, "auth_ldap.dn_lookup_bind.user_dn", "rabbitmq_auth_backend_ldap.dn_lookup_bind",
112112
[{datatype, [string]}]}.
113113

114114
{mapping, "auth_ldap.dn_lookup_bind.password", "rabbitmq_auth_backend_ldap.dn_lookup_bind",
115115
[{datatype, [string]}]}.
116116

117+
%% - as_user (to bind as the authenticated user - requires a password)
118+
%% - anon (to bind anonymously)
119+
%% - {UserDN, Password} (to bind with a specified user name and password)
120+
%%
121+
%% Defaults to 'as_user'.
122+
117123
{translation, "rabbitmq_auth_backend_ldap.dn_lookup_bind",
118124
fun(Conf) ->
119125
case cuttlefish:conf_get("auth_ldap.dn_lookup_bind", Conf, undefined) of
120126
as_user -> as_user;
127+
anon -> anon;
121128
_ ->
122129
User = cuttlefish:conf_get("auth_ldap.dn_lookup_bind.user_dn", Conf),
123130
Pass = cuttlefish:conf_get("auth_ldap.dn_lookup_bind.password", Conf),
@@ -138,8 +145,6 @@ end}.
138145
%% - {UserDN, Password} (to bind with a specified user name and password)
139146
%%
140147
%% Defaults to 'as_user'.
141-
%%
142-
%% {other_bind, as_user},
143148

144149
{mapping, "auth_ldap.other_bind", "rabbitmq_auth_backend_ldap.other_bind",
145150
[{datatype, {enum, [as_user, anon]}}]}.

src/rabbit_auth_backend_ldap.erl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,11 @@ vhost_if_defined(VHost) -> [{vhost, VHost}].
719719

720720
dn_lookup_when() -> case {env(dn_lookup_attribute), env(dn_lookup_bind)} of
721721
{none, _} -> never;
722-
{_, as_user} -> postbind;
723-
{_, _} -> prebind
722+
{_, as_user} -> postbind;
723+
%% make it more obvious what the invariants are,
724+
%% see rabbitmq/rabbitmq-auth-backend-ldap#94. MK.
725+
{_, anon} -> prebind;
726+
{_, _} -> prebind
724727
end.
725728

726729
username_to_dn_prebind(Username) ->

test/config_schema_SUITE_data/rabbitmq_auth_backend_ldap.snippets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,20 @@
109109
auth_ldap.dn_lookup_bind.password = password",
110110
[{rabbitmq_auth_backend_ldap,[{dn_lookup_bind,{"username","password"}}]}],
111111
[rabbitmq_auth_backend_ldap]},
112+
{db_lookup_bind_anon,
113+
"auth_ldap.dn_lookup_bind = anon",
114+
[{rabbitmq_auth_backend_ldap,[{dn_lookup_bind,anon}]}],
115+
[rabbitmq_auth_backend_ldap]},
112116
{other_bind_anon,
113117
"auth_ldap.other_bind = anon",
114118
[{rabbitmq_auth_backend_ldap,[{other_bind,anon}]}],
115119
[rabbitmq_auth_backend_ldap]},
120+
{both_binds_anon,
121+
"auth_ldap.dn_lookup_bind = anon
122+
auth_ldap.other_bind = anon",
123+
[{rabbitmq_auth_backend_ldap,[{dn_lookup_bind,anon},
124+
{other_bind,anon}]}],
125+
[rabbitmq_auth_backend_ldap]},
116126
{other_bind_as_user,
117127
"auth_ldap.other_bind = as_user",
118128
[{rabbitmq_auth_backend_ldap,[{other_bind,as_user}]}],

0 commit comments

Comments
 (0)