chore(jwt-acl): avoid the disruptions caused by rule formatting errors

This commit is contained in:
JianBo He 2022-10-21 11:39:17 +08:00
parent fa4203effa
commit 38e87579c0
1 changed files with 9 additions and 6 deletions

View File

@ -114,12 +114,15 @@ verify_acl(ClientInfo, Acl, PubSub, Topic) ->
subscribe -> <<"sub">>; subscribe -> <<"sub">>;
publish -> <<"pub">> publish -> <<"pub">>
end, end,
case {maps:get(<<"all">>, Acl, []), maps:get(Key, Acl, [])} of Rules0 = lists:foldl(
{Rules1, Rules2} when is_list(Rules1) andalso is_list(Rules2) -> fun(K, Acc) ->
verify_acl(ClientInfo, Rules1 ++ Rules2, Topic); [case maps:get(K, Acl, undefined) of
{_, _} -> R when is_list(R) -> R;
{stop, deny} _ -> []
end. end | Acc]
end, [], [<<"all">>, Key]),
Rules = lists:concat(Rules0),
verify_acl(ClientInfo, Rules, Topic).
verify_acl(_ClientInfo, [], _Topic) -> {stop, deny}; verify_acl(_ClientInfo, [], _Topic) -> {stop, deny};
verify_acl(ClientInfo, [AclTopic | AclTopics], Topic) -> verify_acl(ClientInfo, [AclTopic | AclTopics], Topic) ->