diff --git a/apps/emqx/src/emqx_authentication.erl b/apps/emqx/src/emqx_authentication.erl index b8476de56..2e53d85eb 100644 --- a/apps/emqx/src/emqx_authentication.erl +++ b/apps/emqx/src/emqx_authentication.erl @@ -226,7 +226,7 @@ do_pre_config_update({move_authenticator, _ChainName, AuthenticatorID, Position} end end. --spec post_config_update(update_request, map() | list(), emqx_config:raw_config(), emqx_config:app_envs()) +-spec post_config_update(update_request(), map() | list(), emqx_config:raw_config(), emqx_config:app_envs()) -> ok | {ok, map()} | {error, term()}. post_config_update(UpdateReq, NewConfig, OldConfig, AppEnvs) -> do_post_config_update(UpdateReq, check_config(to_list(NewConfig)), OldConfig, AppEnvs). diff --git a/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl b/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl index 5495b139a..daa7f8073 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl @@ -214,7 +214,7 @@ default_headers_no_content_type() -> transform_header_name(Headers) -> maps:fold(fun(K0, V, Acc) -> - K = list_to_binary(string:to_lower(binary_to_list(K0))), + K = list_to_binary(string:to_lower(to_list(K0))), maps:put(K, V, Acc) end, #{}, Headers). @@ -301,3 +301,8 @@ parse_body(<<"application/x-www-form-urlencoded">>, Body) -> {ok, maps:from_list(cow_qs:parse_qs(Body))}; parse_body(ContentType, _) -> {error, {unsupported_content_type, ContentType}}. + +to_list(A) when is_atom(A) -> + atom_to_list(A); +to_list(B) when is_binary(B) -> + binary_to_list(B). diff --git a/apps/emqx_authz/src/emqx_authz_schema.erl b/apps/emqx_authz/src/emqx_authz_schema.erl index b90d522e8..b3915b7c0 100644 --- a/apps/emqx_authz/src/emqx_authz_schema.erl +++ b/apps/emqx_authz/src/emqx_authz_schema.erl @@ -66,7 +66,7 @@ fields(http_get) -> }, converter => fun (Headers0) -> Headers1 = maps:fold(fun(K0, V, AccIn) -> - K1 = iolist_to_binary(string:to_lower(binary_to_list(K0))), + K1 = iolist_to_binary(string:to_lower(to_list(K0))), maps:put(K1, V, AccIn) end, #{}, Headers0), maps:merge(#{ <<"accept">> => <<"application/json">> @@ -177,3 +177,8 @@ connector_fields(DB, Fields) -> , {enable, #{type => boolean(), default => true}} ] ++ Mod:fields(Fields). + +to_list(A) when is_atom(A) -> + atom_to_list(A); +to_list(B) when is_binary(B) -> + binary_to_list(B). \ No newline at end of file