From ce1772c2b53e81228aa4e1c7f5d86d12bcc367a4 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sun, 29 Aug 2021 22:15:45 +0200 Subject: [PATCH] fix(emqx_authz): fix typo in authz annotation key rule -> rules --- apps/emqx_authz/src/emqx_authz.erl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/emqx_authz/src/emqx_authz.erl b/apps/emqx_authz/src/emqx_authz.erl index 3e60cc32e..d935bc4a1 100644 --- a/apps/emqx_authz/src/emqx_authz.erl +++ b/apps/emqx_authz/src/emqx_authz.erl @@ -314,22 +314,20 @@ authorize(#{username := Username, {stop, DefaultResult} end. -do_authorize(Client, PubSub, Topic, - [#{type := file, - enable := true, - annotations := #{rule := Rules} - } | Tail] ) -> +do_authorize(_Client, _PubSub, _Topic, []) -> + nomatch; +do_authorize(Client, PubSub, Topic, [#{enable := false} | Rest]) -> + do_authorize(Client, PubSub, Topic, Rest); +do_authorize(Client, PubSub, Topic, [#{type := file} = F | Tail]) -> + #{annotations := #{rules := Rules}} = F, case emqx_authz_rule:match(Client, PubSub, Topic, Rules) of nomatch -> do_authorize(Client, PubSub, Topic, Tail); Matched -> Matched end; do_authorize(Client, PubSub, Topic, - [Connector = #{type := Type, - enable := true - } | Tail] ) -> - Mod = list_to_existing_atom(io_lib:format("~s_~s",[emqx_authz, Type])), + [Connector = #{type := Type} | Tail] ) -> + Mod = list_to_existing_atom(io_lib:format("emqx_authz_~s",[Type])), case Mod:authorize(Client, PubSub, Topic, Connector) of nomatch -> do_authorize(Client, PubSub, Topic, Tail); Matched -> Matched - end; -do_authorize(_Client, _PubSub, _Topic, []) -> nomatch. + end.