support cascading multiple acl modules

This commit is contained in:
turtled 2017-03-30 09:43:35 +08:00
parent 4f0bd74f87
commit 5c866d91b4
2 changed files with 3 additions and 6 deletions

View File

@ -24,6 +24,3 @@
{deny, all, subscribe, ["$SYS/#", {eq, "#"}]}. {deny, all, subscribe, ["$SYS/#", {eq, "#"}]}.
{allow, all}.

View File

@ -30,7 +30,7 @@
-define(ACL_RULE_TAB, mqtt_acl_rule). -define(ACL_RULE_TAB, mqtt_acl_rule).
-record(state, {config, nomatch = allow}). -record(state, {config}).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% API %% API
@ -86,11 +86,11 @@ filter(_PubSub, {_AllowDeny, _Who, _, _Topics}) ->
State :: #state{}). State :: #state{}).
check_acl(_Who, #state{config = undefined}) -> check_acl(_Who, #state{config = undefined}) ->
allow; allow;
check_acl({Client, PubSub, Topic}, #state{nomatch = Default}) -> check_acl({Client, PubSub, Topic}, #state{}) ->
case match(Client, Topic, lookup(PubSub)) of case match(Client, Topic, lookup(PubSub)) of
{matched, allow} -> allow; {matched, allow} -> allow;
{matched, deny} -> deny; {matched, deny} -> deny;
nomatch -> Default nomatch -> ignore
end. end.
lookup(PubSub) -> lookup(PubSub) ->