Files
svfs/deploy/mqtt/config/acl
T
chakcy 9dc2dde59f
tests / ubuntu-latest / py3.13 (push) Has been cancelled
tests / windows-latest / py3.13 (push) Has been cancelled
tests / ubuntu-latest / py3.13 (pull_request) Has been cancelled
tests / windows-latest / py3.13 (pull_request) Has been cancelled
modify: 消息模块
2026-09-17 11:23:34 +08:00

51 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# svfs 消息模块的 ACL 示例(最小权限)。默认**未启用**——要用就在
# mosquitto.conf 里解开 allow_anonymous false / password_file / acl_file 三行,
# 否则这份文件不会生效。
#
# 规则先记两条,踩坑都出在这儿:
#
# * 这里的 <用户名> 是 **MQTT 连接的 username**。客户端默认用 svfs 登录名
# (settings.mqtt_config:mqtt_username 留空 = 登录名),所以通常两者一致;
# 在设置里覆盖过 broker 账号时,以覆盖后的为准。
# * 组织标识(下面的 default)要**换成你的 SVFS_ORG**,且不能写成通配——
# 多租户隔离靠的就是这一段。用户名里有特殊字符时按百分号编码填
# (拿 svfs_client.topics.topic_segment 算一下,例如「张三」→ %E5%BC%A0%E4%B8%89)。
# ---- 匿名段:第一个 user 之前的规则属于匿名连接 ----------------------
#
# 开了 allow_anonymous false 后这一段就没用了(示例服务端届时要用下面的
# svfs-server 账号发布)。留着是为了「允许匿名发布、但读取仍受控」的折中场景。
topic write svfs/default/user/+/message
topic write svfs/default/user/+/plugin/+
topic write svfs/default/broadcast/#
# ---- 服务端发布账号 --------------------------------------------------
#
# 服务端要能给任意用户写消息;它只需要写,不需要读。
user svfs-server
topic write svfs/default/user/+/message
topic write svfs/default/user/+/plugin/+
topic write svfs/default/broadcast/#
topic write svfs/default/broadcast/plugin/+
# ---- 客户端:每人只读自己那两条订阅主题 ------------------------------
#
# 客户端登录后订阅的是 svfs/<org>/user/<自己>/# 与 svfs/<org>/broadcast/#,
# 所以只给这些就够(读不到别人的消息、也没有写权限)。
user alice
topic read svfs/default/user/alice/#
topic read svfs/default/broadcast/#
user bob
topic read svfs/default/user/bob/#
topic read svfs/default/broadcast/#
# ---- 等价的通配写法(可选) ------------------------------------------
#
# 用户多了不想一个个写,可以用 pattern:%u 会被替换成连接用的用户名。
# 前提是 %u 独占一个主题层级(不能写成 svfs/default/user/%u-2/# 这种)。
# 注意 pattern 对所有用户生效(包括匿名与 svfs-server),所以这里只给读。
#
# pattern read svfs/default/user/%u/#
# pattern read svfs/default/broadcast/#