我正在使用 mosquitto-go-auth 插件在 mosquitto 代理中进行身份验证。
我已经通过以下链接设置了插件
https://github.com/iegomez/mosquitto-go-auth
https://www.chirpstack.io/project/guides/mqtt-authentication/#build-for-mosquitto-14x
这是我的 mosquitto.conf
per_listener_settings false
listener 1883
protocol mqtt
auth_plugin /home/user/mosquitto-go-auth/go-auth.so
allow_anonymous false
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
当我重新启动我的经纪人时。 我在日志文件中得到了这个。
1731240636: ├── TLS-PSK checking enabled.
1731240636: └── Extended authentication not enabled.
1731240636: mosquitto version 2.0.15 starting
1731240636: Config loaded from /etc/mosquitto/mosquitto.conf.
1731240636: Loading plugin: /home/user/mosquitto-go-auth/go-auth.so
1731240636: ├── Username/password checking enabled.
1731240636: ├── TLS-PSK checking enabled.
1731240636: └── Extended authentication not enabled.
1731240637: mosquitto version 2.0.15 starting
1731240637: Config loaded from /etc/mosquitto/mosquitto.conf.
1731240637: Loading plugin: /home/user/mosquitto-go-auth/go-auth.so
1731240637: ├── Username/password checking enabled.
1731240637: ├── TLS-PSK checking enabled.
1731240637: └── Extended authentication not enabled.
1731240637: mosquitto version 2.0.15 starting
1731240637: Config loaded from /etc/mosquitto/mosquitto.conf.
1731240637: Loading plugin: /home/user/mosquitto-go-auth/go-auth.so
1731240637: ├── Username/password checking enabled.
1731240637: ├── TLS-PSK checking enabled.
1731240637: └── Extended authentication not enabled.
如果我删除插件,那么代理工作正常。但是如果我添加身份验证插件,它就会失败。
go-auth 插件需要配置,而不仅仅是加载。
在
mosquitto.conf
文件中,您需要选择 go-auth 插件可以使用的众多后端之一,并包含一组以 auth_pluing_opt_
开头的选项
例如配置 http 身份验证支持如下所示:
per_listener_settings false
allow_anonymous false
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
listener 1883
protocol mqtt
auth_plugin /home/user/mosquitto-go-auth/go-auth.so
auth_opt_backends http
auth_opt_hasher bcrypt
auth_opt_cache true
auth_opt_auth_cache_seconds 30
auth_opt_acl_cache_seconds 90
auth_opt_auth_jitter_second 3
auth_opt_acl_jitter_seconds 5
auth_opt_http_host auth.backend.com
auth_opt_http_port 80
auth_opt_http_getuser_uri /api/comms/auth/client
auth_opt_http_aclcheck_uri /api/comms/auth/acl