Authentication 如何使用redis作为mosquitto ACL的后端

Authentication 如何使用redis作为mosquitto ACL的后端,authentication,redis,mqtt,acl,mosquitto,Authentication,Redis,Mqtt,Acl,Mosquitto,我正在开发Mosquito,并计划使用Redis作为后端来处理用户名/密码对身份验证和ACL。我正在使用JPmens的身份验证插件来实现这一点 莫斯基托形态: auth_opt_backends redis auth_plugin /etc/mosquitto/auth-plug.so auth_opt_redis_host 127.0.0.1 auth_opt_redis_port 6379 auth_opt_redis_userquery GET %s auth_opt_redis_aclq

我正在开发Mosquito,并计划使用Redis作为后端来处理用户名/密码对身份验证和ACL。我正在使用JPmens的身份验证插件来实现这一点

莫斯基托形态:

auth_opt_backends redis
auth_plugin /etc/mosquitto/auth-plug.so
auth_opt_redis_host 127.0.0.1
auth_opt_redis_port 6379
auth_opt_redis_userquery GET %s
auth_opt_redis_aclquery GET %s-%s
以下名称/密码对可用于身份验证

SET user1 PBKDF2$sha256$901$Qh18ysY4wstXoHhk$g8d2aDzbz3rYztvJiO3dsV698jzECxSg
以下设置不适用于ACL:

SET user1-test 2
以下是mosquitto的日志:

1507037072: Denied PUBLISH from mosqpub/3838-ip-172-31- (d0, q0, r0, m0, 'user1-test', ... (4 bytes))
1507037072: Received DISCONNECT from mosqpub/3838-ip-172-31-
因此,每当我尝试发布/订阅Mosquit以验证用户,但不允许发布和断开用户连接时

使用以下各项进行测试:

mosquitto_pub -p 1884 -t "test" -m "demo" -u user1 -P xyz 
对于sub:

mosquitto_sub -p 1884 -t "test" -u user1 -P xyz

好的,我已经解决了

您提供的日志中缺少一个重要的部分。您应该包括以下行:

1507135115: ACL denying access to client with dangerous client id "mosqpub/2232-tiefighter"
问题是插件被阻塞,因为客户端id包含“/”

代码中包含以下部分:

/* We are using pattern based acls. Check whether the username or  
 * client id contains a +, # or / and if so deny access.  
 *
 * Without this, a malicious client may configure its username/client  
 * id to bypass ACL checks (or have a username/client id that cannot
 * publish or receive messages to its own place in the hierarchy).  
 */
解决方案是使用-i选项设置mosquitto_sub和mosquitto_pub的客户端id,例如:

mosquitto_pub -p 1884 -t "test" -m "demo" -u user1 -P xyz -i publisher

仅仅说它不起作用是没有帮助的。您需要解释它是如何工作的,它是允许所有消息还是不允许任何消息?测试时,您在日志中看到了什么?您是如何测试的。@hardillb我编辑了这个问题..那么,现在您能告诉我问题出在哪里吗..:)还有一个疑问,在redis数据库中将多个topisc(acl主题)设置为同一用户的方法是什么。只需设置多个用户主题条目