Merge pull request #11703 from lafirest/fix/ldap_bind
fix(ldap): use the search result as bind target
This commit is contained in:
commit
39820be5ff
|
@ -124,11 +124,11 @@ login(
|
||||||
of
|
of
|
||||||
{ok, []} ->
|
{ok, []} ->
|
||||||
{error, user_not_found};
|
{error, user_not_found};
|
||||||
{ok, [_Entry | _]} ->
|
{ok, [Entry | _]} ->
|
||||||
case
|
case
|
||||||
emqx_resource:simple_sync_query(
|
emqx_resource:simple_sync_query(
|
||||||
ResourceId,
|
ResourceId,
|
||||||
{bind, Sign}
|
{bind, Entry#eldap_entry.object_name, Sign}
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
ok ->
|
ok ->
|
||||||
|
|
|
@ -177,7 +177,7 @@ on_query(InstId, {query, Data, Attrs}, State) ->
|
||||||
on_query(InstId, {query, Data}, [{attributes, Attrs}], State);
|
on_query(InstId, {query, Data}, [{attributes, Attrs}], State);
|
||||||
on_query(InstId, {query, Data, Attrs, Timeout}, State) ->
|
on_query(InstId, {query, Data, Attrs, Timeout}, State) ->
|
||||||
on_query(InstId, {query, Data}, [{attributes, Attrs}, {timeout, Timeout}], State);
|
on_query(InstId, {query, Data}, [{attributes, Attrs}, {timeout, Timeout}], State);
|
||||||
on_query(InstId, {bind, _Data} = Req, State) ->
|
on_query(InstId, {bind, _DN, _Data} = Req, State) ->
|
||||||
emqx_ldap_bind_worker:on_query(InstId, Req, State).
|
emqx_ldap_bind_worker:on_query(InstId, Req, State).
|
||||||
|
|
||||||
on_get_status(_InstId, #{pool_name := PoolName} = _State) ->
|
on_get_status(_InstId, #{pool_name := PoolName} = _State) ->
|
||||||
|
|
|
@ -95,11 +95,11 @@ authenticate(
|
||||||
of
|
of
|
||||||
{ok, []} ->
|
{ok, []} ->
|
||||||
ignore;
|
ignore;
|
||||||
{ok, [_Entry | _]} ->
|
{ok, [Entry | _]} ->
|
||||||
case
|
case
|
||||||
emqx_resource:simple_sync_query(
|
emqx_resource:simple_sync_query(
|
||||||
ResourceId,
|
ResourceId,
|
||||||
{bind, Credential}
|
{bind, Entry#eldap_entry.object_name, Credential}
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
ok ->
|
ok ->
|
||||||
|
|
|
@ -58,14 +58,12 @@ on_stop(InstId, _State) ->
|
||||||
|
|
||||||
on_query(
|
on_query(
|
||||||
InstId,
|
InstId,
|
||||||
{bind, Data},
|
{bind, DN, Data},
|
||||||
#{
|
#{
|
||||||
base_tokens := DNTks,
|
|
||||||
bind_password := PWTks,
|
bind_password := PWTks,
|
||||||
bind_pool_name := PoolName
|
bind_pool_name := PoolName
|
||||||
} = State
|
} = State
|
||||||
) ->
|
) ->
|
||||||
DN = emqx_placeholder:proc_tmpl(DNTks, Data),
|
|
||||||
Password = emqx_placeholder:proc_tmpl(PWTks, Data),
|
Password = emqx_placeholder:proc_tmpl(PWTks, Data),
|
||||||
|
|
||||||
LogMeta = #{connector => InstId, state => State},
|
LogMeta = #{connector => InstId, state => State},
|
||||||
|
|
Loading…
Reference in New Issue