fix(authn_redis): Avoid duplicating check for non-existent keys
This commit is contained in:
parent
62fd955a0e
commit
8590fef829
|
@ -141,12 +141,8 @@ authenticate(
|
||||||
{ok, []} ->
|
{ok, []} ->
|
||||||
ignore;
|
ignore;
|
||||||
{ok, Values} ->
|
{ok, Values} ->
|
||||||
case check_query_matched(Values) of
|
case merge(Fields, Values) of
|
||||||
false ->
|
Selected when Selected =/= #{} ->
|
||||||
%% key not exists
|
|
||||||
ignore;
|
|
||||||
_ ->
|
|
||||||
Selected = merge(Fields, Values),
|
|
||||||
case
|
case
|
||||||
emqx_authn_utils:check_password_from_selected_map(
|
emqx_authn_utils:check_password_from_selected_map(
|
||||||
Algorithm, Selected, Password
|
Algorithm, Selected, Password
|
||||||
|
@ -156,7 +152,15 @@ authenticate(
|
||||||
{ok, emqx_authn_utils:is_superuser(Selected)};
|
{ok, emqx_authn_utils:is_superuser(Selected)};
|
||||||
{error, _Reason} = Error ->
|
{error, _Reason} = Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end;
|
||||||
|
_ ->
|
||||||
|
?TRACE_AUTHN_PROVIDER(info, "redis_query_not_matched", #{
|
||||||
|
resource => ResourceId,
|
||||||
|
cmd => Command,
|
||||||
|
keys => NKey,
|
||||||
|
fields => Fields
|
||||||
|
}),
|
||||||
|
ignore
|
||||||
end;
|
end;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?TRACE_AUTHN_PROVIDER(error, "redis_query_failed", #{
|
?TRACE_AUTHN_PROVIDER(error, "redis_query_failed", #{
|
||||||
|
@ -228,10 +232,3 @@ merge(Fields, Values) ->
|
||||||
|| {K, V} <- lists:zip(Fields, Values), V =/= undefined
|
|| {K, V} <- lists:zip(Fields, Values), V =/= undefined
|
||||||
]
|
]
|
||||||
).
|
).
|
||||||
|
|
||||||
check_query_matched(undefined) ->
|
|
||||||
false;
|
|
||||||
check_query_matched(List) when is_list(List) ->
|
|
||||||
lists:any(fun(E) -> E =/= undefined end, List);
|
|
||||||
check_query_matched(_) ->
|
|
||||||
true.
|
|
||||||
|
|
Loading…
Reference in New Issue