From 11bdfcb8f0a3f8e0451a49c28fe0750913636fbc Mon Sep 17 00:00:00 2001 From: zhouzb Date: Fri, 24 Sep 2021 17:04:20 +0800 Subject: [PATCH] fix(authn): fix bugs in http and pgsql authn --- apps/emqx_authn/src/simple_authn/emqx_authn_http.erl | 4 ++-- apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 77a8a94c8..363963f96 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl @@ -188,8 +188,8 @@ check_url(URL) -> end. check_body(Body) -> - lists:any(fun({_, V}) -> - not is_binary(V) + lists:all(fun({_, V}) -> + is_binary(V) end, maps:to_list(Body)). default_headers() -> diff --git a/apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl b/apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl index 78632610e..d626e2dab 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl @@ -150,7 +150,7 @@ check_password(Password, parse_query(Query) -> case re:run(Query, ?RE_PLACEHOLDER, [global, {capture, all, binary}]) of {match, Captured} -> - PlaceHolders = [PlaceHolder || PlaceHolder <- Captured], + PlaceHolders = [PlaceHolder || [PlaceHolder] <- Captured], Replacements = ["$" ++ integer_to_list(I) || I <- lists:seq(1, length(Captured))], NQuery = lists:foldl(fun({PlaceHolder, Replacement}, Query0) -> re:replace(Query0, <<"'\\", PlaceHolder/binary, "'">>, Replacement, [{return, binary}])