fix issue#95 - Topic filters in ACL rule should support 'eq' tag
This commit is contained in:
parent
cf0068c2b3
commit
02614e8ae4
|
@ -58,7 +58,7 @@ compile({A, all}) when (A =:= allow) orelse (A =:= deny) ->
|
||||||
{A, all};
|
{A, all};
|
||||||
|
|
||||||
compile({A, Who, Access, TopicFilters}) when (A =:= allow) orelse (A =:= deny) ->
|
compile({A, Who, Access, TopicFilters}) when (A =:= allow) orelse (A =:= deny) ->
|
||||||
{A, compile(who, Who), Access, [compile(topic, bin(Topic)) || Topic <- TopicFilters]}.
|
{A, compile(who, Who), Access, [compile(topic, Topic) || Topic <- TopicFilters]}.
|
||||||
|
|
||||||
compile(who, all) ->
|
compile(who, all) ->
|
||||||
all;
|
all;
|
||||||
|
@ -74,8 +74,10 @@ compile(who, {user, all}) ->
|
||||||
compile(who, {user, Username}) ->
|
compile(who, {user, Username}) ->
|
||||||
{user, bin(Username)};
|
{user, bin(Username)};
|
||||||
|
|
||||||
|
compile(topic, {eq, Topic}) ->
|
||||||
|
{eq, emqtt_topic:words(bin(Topic))};
|
||||||
compile(topic, Topic) ->
|
compile(topic, Topic) ->
|
||||||
Words = emqtt_topic:words(Topic),
|
Words = emqtt_topic:words(bin(Topic)),
|
||||||
case 'pattern?'(Words) of
|
case 'pattern?'(Words) of
|
||||||
true -> {pattern, Words};
|
true -> {pattern, Words};
|
||||||
false -> Words
|
false -> Words
|
||||||
|
@ -138,6 +140,8 @@ match_topics(Client, Topic, [TopicFilter|Filters]) ->
|
||||||
false -> match_topics(Client, Topic, Filters)
|
false -> match_topics(Client, Topic, Filters)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
match_topic(Topic, {eq, TopicFilter}) ->
|
||||||
|
Topic =:= TopicFilter;
|
||||||
match_topic(Topic, TopicFilter) ->
|
match_topic(Topic, TopicFilter) ->
|
||||||
emqtt_topic:match(Topic, TopicFilter).
|
emqtt_topic:match(Topic, TopicFilter).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue