【问题标题】:Acl file configuration in MosquittoMosquitto中的acl文件配置
【发布时间】:2020-01-28 18:06:16
【问题描述】:

我的蚊子中有 acl 文件:

user b
topic read s1#
topic write s1#

topic write s2
topic read s2


pattern write s3_%c#
pattern read s3_%c#

pattern write s4_%c
pattern read s4_%c


pattern  write s5_%u#
pattern  read s5_%u#

pattern  write s6_%u
pattern  read s6_%u

从客户端 ID abc 到主题 s4_abc 的请求工作正常:

mosquitto_pub -h servername -t s4_abc -m "test" -p 1883 -u b -P b -i abc -d

从客户端 ID abc 向主题 s3_abcA 的以下请求失败:

mosquitto_pub -h servername -t s3_abcA -m "test" -p 1883 -u b -P b -i abc -d

为什么会失败?我期待模式 s3_%c# 表示“s3_abc”之后主题中的任何短语都可以。

【问题讨论】:

    标签: mqtt mosquitto


    【解决方案1】:

    ACL 文件中的主题和模式无效,它们需要在通配符之间有一个/

    通配符只匹配整个主题片段。

    %u%c 也是如此

    来自 mosquitto.conf 手册页:

    可供替换的模式有:

    %c 匹配客户端的客户端 id %u 匹配用户名 客户端。 替换模式必须是唯一的文本 层次结构的级别。模式 ACL 适用于所有用户,即使“用户” 之前已经给出了关键字。

    例子:

    模式写入sensor/%u/data

    允许访问网桥连接消息:

    模式写入$SYS/broker/connection/%c/state

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多