chore(authn): fix dialyzer
This commit is contained in:
parent
69755ad3fb
commit
bb4e5fdb4f
|
@ -659,7 +659,11 @@ reply(Reply, State) ->
|
||||||
certs_dir(Dirs) when is_list(Dirs) ->
|
certs_dir(Dirs) when is_list(Dirs) ->
|
||||||
to_bin(filename:join([emqx:get_config([node, data_dir]), "certs/authn"] ++ Dirs)).
|
to_bin(filename:join([emqx:get_config([node, data_dir]), "certs/authn"] ++ Dirs)).
|
||||||
|
|
||||||
convert_certs(CertsDir, #{<<"ssl">> := SSLOpts} = Config) ->
|
convert_certs(CertsDir, Config) ->
|
||||||
|
case maps:get(<<"ssl">>, Config, undefined) of
|
||||||
|
undefined ->
|
||||||
|
Config;
|
||||||
|
SSLOpts ->
|
||||||
NSSLOPts = lists:foldl(fun(K, Acc) ->
|
NSSLOPts = lists:foldl(fun(K, Acc) ->
|
||||||
case maps:get(K, Acc, undefined) of
|
case maps:get(K, Acc, undefined) of
|
||||||
undefined -> Acc;
|
undefined -> Acc;
|
||||||
|
@ -669,11 +673,14 @@ convert_certs(CertsDir, #{<<"ssl">> := SSLOpts} = Config) ->
|
||||||
Acc#{K => CertFile}
|
Acc#{K => CertFile}
|
||||||
end
|
end
|
||||||
end, SSLOpts, [<<"certfile">>, <<"keyfile">>, <<"cacertfile">>]),
|
end, SSLOpts, [<<"certfile">>, <<"keyfile">>, <<"cacertfile">>]),
|
||||||
Config#{<<"ssl">> => NSSLOPts};
|
Config#{<<"ssl">> => NSSLOPts}
|
||||||
convert_certs(_CertsDir, Config) ->
|
end.
|
||||||
Config.
|
|
||||||
|
|
||||||
convert_certs(CertsDir, #{<<"ssl">> := NewSSLOpts} = NewConfig, OldConfig) ->
|
convert_certs(CertsDir, NewConfig, OldConfig) ->
|
||||||
|
case maps:get(<<"ssl">>, NewConfig, undefined) of
|
||||||
|
undefined ->
|
||||||
|
NewConfig;
|
||||||
|
NewSSLOpts ->
|
||||||
OldSSLOpts = maps:get(<<"ssl">>, OldConfig, #{}),
|
OldSSLOpts = maps:get(<<"ssl">>, OldConfig, #{}),
|
||||||
Diff = diff_certs(NewSSLOpts, OldSSLOpts),
|
Diff = diff_certs(NewSSLOpts, OldSSLOpts),
|
||||||
NSSLOpts = lists:foldl(fun({identical, K}, Acc) ->
|
NSSLOpts = lists:foldl(fun({identical, K}, Acc) ->
|
||||||
|
@ -683,18 +690,20 @@ convert_certs(CertsDir, #{<<"ssl">> := NewSSLOpts} = NewConfig, OldConfig) ->
|
||||||
ok = save_cert_to_file(CertFile, maps:get(K, NewSSLOpts)),
|
ok = save_cert_to_file(CertFile, maps:get(K, NewSSLOpts)),
|
||||||
Acc#{K => CertFile}
|
Acc#{K => CertFile}
|
||||||
end, NewSSLOpts, Diff),
|
end, NewSSLOpts, Diff),
|
||||||
NewConfig#{<<"ssl">> => NSSLOpts};
|
NewConfig#{<<"ssl">> => NSSLOpts}
|
||||||
convert_certs(_CertsDir, NewConfig, _OldConfig) ->
|
end.
|
||||||
NewConfig.
|
|
||||||
|
|
||||||
clear_certs(CertsDir, #{<<"ssl">> := SSLOpts}) ->
|
clear_certs(CertsDir, Config) ->
|
||||||
|
case maps:get(<<"ssl">>, Config, undefined) of
|
||||||
|
undefined ->
|
||||||
|
ok;
|
||||||
|
SSLOpts ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({_, Filename}) ->
|
fun({_, Filename}) ->
|
||||||
_ = file:delete(filename:join([CertsDir, Filename]))
|
_ = file:delete(filename:join([CertsDir, Filename]))
|
||||||
end,
|
end,
|
||||||
maps:to_list(maps:with([<<"certfile">>, <<"keyfile">>, <<"cacertfile">>], SSLOpts)));
|
maps:to_list(maps:with([<<"certfile">>, <<"keyfile">>, <<"cacertfile">>], SSLOpts)))
|
||||||
clear_certs(_CertsDir, _Config) ->
|
end.
|
||||||
ok.
|
|
||||||
|
|
||||||
save_cert_to_file(Filename, PemBin) ->
|
save_cert_to_file(Filename, PemBin) ->
|
||||||
case public_key:pem_decode(PemBin) =/= [] of
|
case public_key:pem_decode(PemBin) =/= [] of
|
||||||
|
|
|
@ -1840,9 +1840,8 @@ find_listener(ListenerID) ->
|
||||||
{ok, {Type, Name}}
|
{ok, {Type, Name}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
create_authenticator(ConfKeyPath, ChainName0, Config) ->
|
create_authenticator(ConfKeyPath, ChainName, Config) ->
|
||||||
ChainName = to_atom(ChainName0),
|
case update_config(ConfKeyPath, {create_authenticator, to_atom(ChainName), Config}) of
|
||||||
case update_config(ConfKeyPath, {create_authenticator, ChainName, Config}) of
|
|
||||||
{ok, #{post_config_update := #{?AUTHN := #{id := ID}},
|
{ok, #{post_config_update := #{?AUTHN := #{id := ID}},
|
||||||
raw_config := AuthenticatorsConfig}} ->
|
raw_config := AuthenticatorsConfig}} ->
|
||||||
{ok, AuthenticatorConfig} = find_config(ID, AuthenticatorsConfig),
|
{ok, AuthenticatorConfig} = find_config(ID, AuthenticatorsConfig),
|
||||||
|
@ -1866,9 +1865,8 @@ list_authenticator(ConfKeyPath, AuthenticatorID) ->
|
||||||
serialize_error(Reason)
|
serialize_error(Reason)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
update_authenticator(ConfKeyPath, ChainName0, AuthenticatorID, Config) ->
|
update_authenticator(ConfKeyPath, ChainName, AuthenticatorID, Config) ->
|
||||||
ChainName = to_atom(ChainName0),
|
case update_config(ConfKeyPath, {update_authenticator, to_atom(ChainName), AuthenticatorID, Config}) of
|
||||||
case update_config(ConfKeyPath, {update_authenticator, ChainName, AuthenticatorID, Config}) of
|
|
||||||
{ok, #{post_config_update := #{?AUTHN := #{id := ID}},
|
{ok, #{post_config_update := #{?AUTHN := #{id := ID}},
|
||||||
raw_config := AuthenticatorsConfig}} ->
|
raw_config := AuthenticatorsConfig}} ->
|
||||||
{ok, AuthenticatorConfig} = find_config(ID, AuthenticatorsConfig),
|
{ok, AuthenticatorConfig} = find_config(ID, AuthenticatorsConfig),
|
||||||
|
|
Loading…
Reference in New Issue