This commit is contained in:
parent
ec28773893
commit
4f0bd74f87
|
@ -100,6 +100,9 @@ log.crash.file = {{ platform_log_dir }}/crash.log
|
||||||
## Allow Anonymous authentication
|
## Allow Anonymous authentication
|
||||||
mqtt.allow_anonymous = true
|
mqtt.allow_anonymous = true
|
||||||
|
|
||||||
|
## ACL nomatch
|
||||||
|
mqtt.acl_nomatch = allow
|
||||||
|
|
||||||
## Default ACL File
|
## Default ACL File
|
||||||
mqtt.acl_file = {{ platform_etc_dir }}/acl.conf
|
mqtt.acl_file = {{ platform_etc_dir }}/acl.conf
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,12 @@ end}.
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
%% @doc ACL nomatch
|
||||||
|
{mapping, "mqtt.acl_nomatch", "emqttd.acl_nomatch", [
|
||||||
|
{default, allow},
|
||||||
|
{datatype, {enum, [allow, deny]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
%% @doc Default ACL File
|
%% @doc Default ACL File
|
||||||
{mapping, "mqtt.acl_file", "emqttd.acl_file", [
|
{mapping, "mqtt.acl_file", "emqttd.acl_file", [
|
||||||
{datatype, string},
|
{datatype, string},
|
||||||
|
|
|
@ -71,16 +71,10 @@ auth(Client, Password, [{Mod, State, _Seq} | Mods]) ->
|
||||||
PubSub :: pubsub(),
|
PubSub :: pubsub(),
|
||||||
Topic :: binary()).
|
Topic :: binary()).
|
||||||
check_acl(Client, PubSub, Topic) when ?PS(PubSub) ->
|
check_acl(Client, PubSub, Topic) when ?PS(PubSub) ->
|
||||||
case lookup_mods(acl) of
|
check_acl(Client, PubSub, Topic, lookup_mods(acl)).
|
||||||
[] -> case emqttd:env(allow_anonymous, false) of
|
|
||||||
true -> allow;
|
check_acl(_Client, _PubSub, _Topic, []) ->
|
||||||
false -> deny
|
emqttd:env(acl_nomatch, allow);
|
||||||
end;
|
|
||||||
AclMods -> check_acl(Client, PubSub, Topic, AclMods)
|
|
||||||
end.
|
|
||||||
check_acl(#mqtt_client{client_id = ClientId}, PubSub, Topic, []) ->
|
|
||||||
lager:error("ACL: nomatch for ~s ~s ~s", [ClientId, PubSub, Topic]),
|
|
||||||
allow;
|
|
||||||
check_acl(Client, PubSub, Topic, [{Mod, State, _Seq}|AclMods]) ->
|
check_acl(Client, PubSub, Topic, [{Mod, State, _Seq}|AclMods]) ->
|
||||||
case Mod:check_acl({Client, PubSub, Topic}, State) of
|
case Mod:check_acl({Client, PubSub, Topic}, State) of
|
||||||
allow -> allow;
|
allow -> allow;
|
||||||
|
|
Loading…
Reference in New Issue