fix(emqx_listeners): fix listener authentication create/update
Listener authentication is a list of authenticators, so each of them must be created or updated individually.
This commit is contained in:
parent
e749ae6863
commit
bf2b5a9f24
|
@ -527,18 +527,26 @@ post_config_update(_Path, _Request, _NewConf, _OldConf, _AppEnvs) ->
|
||||||
|
|
||||||
create_listener(Type, Name, NewConf) ->
|
create_listener(Type, Name, NewConf) ->
|
||||||
Res = start_listener(Type, Name, NewConf),
|
Res = start_listener(Type, Name, NewConf),
|
||||||
recreate_authenticator(Res, Type, Name, NewConf).
|
recreate_authenticators(Res, Type, Name, NewConf).
|
||||||
|
|
||||||
recreate_authenticator(ok, Type, Name, Conf) ->
|
recreate_authenticators(ok, Type, Name, Conf) ->
|
||||||
Chain = listener_id(Type, Name),
|
Chain = listener_id(Type, Name),
|
||||||
_ = emqx_authentication:delete_chain(Chain),
|
_ = emqx_authentication:delete_chain(Chain),
|
||||||
case maps:get(authentication, Conf, []) of
|
do_create_authneticators(Chain, maps:get(authentication, Conf, []));
|
||||||
[] -> ok;
|
recreate_authenticators(Error, _Type, _Name, _NewConf) ->
|
||||||
AuthN -> emqx_authentication:create_authenticator(Chain, AuthN)
|
|
||||||
end;
|
|
||||||
recreate_authenticator(Error, _Type, _Name, _NewConf) ->
|
|
||||||
Error.
|
Error.
|
||||||
|
|
||||||
|
do_create_authneticators(Chain, [AuthN | T]) ->
|
||||||
|
case emqx_authentication:create_authenticator(Chain, AuthN) of
|
||||||
|
{ok, _} ->
|
||||||
|
do_create_authneticators(Chain, T);
|
||||||
|
Error ->
|
||||||
|
_ = emqx_authentication:delete_chain(Chain),
|
||||||
|
Error
|
||||||
|
end;
|
||||||
|
do_create_authneticators(_Chain, []) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
remove_listener(Type, Name, OldConf) ->
|
remove_listener(Type, Name, OldConf) ->
|
||||||
ok = unregister_ocsp_stapling_refresh(Type, Name),
|
ok = unregister_ocsp_stapling_refresh(Type, Name),
|
||||||
case stop_listener(Type, Name, OldConf) of
|
case stop_listener(Type, Name, OldConf) of
|
||||||
|
@ -553,7 +561,7 @@ update_listener(Type, Name, {OldConf, NewConf}) ->
|
||||||
try_clear_ssl_files(certs_dir(Type, Name), NewConf, OldConf),
|
try_clear_ssl_files(certs_dir(Type, Name), NewConf, OldConf),
|
||||||
ok = maybe_unregister_ocsp_stapling_refresh(Type, Name, NewConf),
|
ok = maybe_unregister_ocsp_stapling_refresh(Type, Name, NewConf),
|
||||||
Res = restart_listener(Type, Name, {OldConf, NewConf}),
|
Res = restart_listener(Type, Name, {OldConf, NewConf}),
|
||||||
recreate_authenticator(Res, Type, Name, NewConf).
|
recreate_authenticators(Res, Type, Name, NewConf).
|
||||||
|
|
||||||
perform_listener_changes([]) ->
|
perform_listener_changes([]) ->
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in New Issue