如何为不同的 MQTT 端点使用不同的身份验证方法? [蚊子]

How can I use different authentication methods for different MQTT endpoints? [Mosquitto]

我有一个 Mosquitto MQTT Broker,在一个端口上配置了 Websockets,在另一个端口上配置了 mqtt。

我有一个自定义身份验证插件,它运行良好。然而,我想要的是只有通过 websockets 连接的客户端使用我的插件,而通过 mqtt 协议连接的客户端使用默认的 TLS 身份验证。

我希望有一些我忽略的简单设置可以添加到配置文件中,但欢迎 any/all 解决方案。非常感谢。

来自mosquitto.confman page

per_listener_settings [ true | false ]

If true, then authentication and access control settings will be controlled on a per-listener basis. The following options are affected:

password_file, acl_file, psk_file, allow_anonymous, allow_zero_length_clientid, auth_plugin, auth_opt_*, auto_id_prefix.

Note that if set to true, then a durable client (i.e. with clean session set to false) that has disconnected will use the ACL settings defined for the listener that it was most recently connected to.

The default behaviour is for this to be set to false, which maintains the settings behaviour from previous versions of mosquitto.

Reloaded on reload signal.

如果将此设置为 true,则可以在配置文件中的每个 listener 条目下包含监听器特定设置,它们将各自有自己的 acl/user 设置。