refactor(authn): call lists:foreach instaed of list comprehension
This commit is contained in:
parent
16c652586b
commit
3dcccc0b33
|
@ -14,6 +14,9 @@
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-ifndef(EMQX_AUTHN_HRL).
|
||||||
|
-define(EMQX_AUTHN_HRL, true).
|
||||||
|
|
||||||
-define(APP, emqx_authn).
|
-define(APP, emqx_authn).
|
||||||
|
|
||||||
-define(AUTHN, emqx_authentication).
|
-define(AUTHN, emqx_authentication).
|
||||||
|
@ -23,3 +26,5 @@
|
||||||
-define(RE_PLACEHOLDER, "\\$\\{[a-z0-9\\-]+\\}").
|
-define(RE_PLACEHOLDER, "\\$\\{[a-z0-9\\-]+\\}").
|
||||||
|
|
||||||
-define(AUTH_SHARD, emqx_authn_shard).
|
-define(AUTH_SHARD, emqx_authn_shard).
|
||||||
|
|
||||||
|
-endif.
|
||||||
|
|
|
@ -45,17 +45,20 @@ stop(_State) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
add_providers() ->
|
add_providers() ->
|
||||||
_ = [?AUTHN:add_provider(AuthNType, Provider) || {AuthNType, Provider} <- providers()], ok.
|
lists:foreach(fun(AuthNType, Provider}) ->
|
||||||
|
?AUTHN:add_provider(AuthNType, Provider)
|
||||||
|
end, providers()).
|
||||||
|
|
||||||
remove_providers() ->
|
remove_providers() ->
|
||||||
_ = [?AUTHN:remove_provider(AuthNType) || {AuthNType, _} <- providers()], ok.
|
lists:foreach(fun({AuthNType, _}) ->
|
||||||
|
?AUTHN:remove_provider(AuthNType)
|
||||||
|
end, providers()).
|
||||||
|
|
||||||
initialize() ->
|
initialize() ->
|
||||||
?AUTHN:initialize_authentication(?GLOBAL, emqx:get_raw_config([authentication], [])),
|
?AUTHN:initialize_authentication(?GLOBAL, emqx:get_raw_config([authentication], [])),
|
||||||
lists:foreach(fun({ListenerID, ListenerConfig}) ->
|
lists:foreach(fun({ListenerID, ListenerConfig}) ->
|
||||||
?AUTHN:initialize_authentication(ListenerID, maps:get(authentication, ListenerConfig, []))
|
?AUTHN:initialize_authentication(ListenerID, maps:get(authentication, ListenerConfig, []))
|
||||||
end, emqx_listeners:list()),
|
end, emqx_listeners:list()).
|
||||||
ok.
|
|
||||||
|
|
||||||
providers() ->
|
providers() ->
|
||||||
[ {{'password-based', 'built-in-database'}, emqx_authn_mnesia}
|
[ {{'password-based', 'built-in-database'}, emqx_authn_mnesia}
|
||||||
|
|
Loading…
Reference in New Issue