fix(ldap): remove the parse_config, it never work

This commit is contained in:
firest 2023-09-27 22:15:19 +08:00
parent ffd9a35d69
commit 57781d0544
4 changed files with 6 additions and 28 deletions

View File

@ -86,7 +86,7 @@ destroy(#{resource_id := ResourceId}) ->
parse_config(Config0) ->
Config = ensure_bind_password(Config0),
{Config, emqx_ldap:parse_config(Config, [query_timeout], [])}.
{Config, maps:with([query_timeout], Config0)}.
%% In this feature, the `bind_password` is fixed, so it should conceal from the swagger,
%% but the connector still needs it, hence we should add it back here

View File

@ -27,7 +27,7 @@
-export([roots/0, fields/1, desc/1]).
-export([do_get_status/1, parse_config/3]).
-export([do_get_status/1]).
-define(LDAP_HOST_OPTIONS, #{
default_port => 389
@ -114,28 +114,6 @@ ensure_username(required) ->
ensure_username(Field) ->
?ECS:username(Field).
parse_config(Config, ToKeep, ToString) ->
Convert = fun(Value) ->
case lists:member(Value, ToString) of
true ->
erlang:binary_to_list(Value);
_ ->
Value
end
end,
lists:foldl(
fun(Key, Acc) ->
case maps:find(Key, Config) of
{ok, Value} ->
Acc#{Key => Convert(Value)};
_ ->
Acc
end
end,
#{},
ToKeep ++ ToString
).
%% ===================================================================
callback_mode() -> always_sync.

View File

@ -143,7 +143,7 @@ authenticate(
end.
parse_config(Config) ->
emqx_ldap:parse_config(Config, [query_timeout], [password_attribute, is_superuser_attribute]).
maps:with([query_timeout, password_attribute, is_superuser_attribute], Config).
%% To compatible v4.x
is_enabled(Password, #eldap_entry{attributes = Attributes} = Entry, State) ->

View File

@ -134,9 +134,9 @@ do_authorize(_Action, _Topic, [], _Entry) ->
nomatch.
new_annotations(Init, Source) ->
State = emqx_ldap:parse_config(Source, [query_timeout], [
publish_attribute, subscribe_attribute, all_attribute
]),
State = maps:with(
[query_timeout, publish_attribute, subscribe_attribute, all_attribute], Source
),
maps:merge(Init, State).
select_attrs(#{action_type := publish}, #{publish_attribute := Pub, all_attribute := All}) ->