mosquitto mysql_mosquitto权限验证

本文介绍了如何在Mosquitto MQTT Broker中使用mosquitto-auth-plug进行权限验证,包括安装依赖、编译mosquitto和mosquitto-auth-plug、配置MySQL数据库、编辑mosquitto配置文件以及测试ACL功能。重点是mosquitto-auth-plug的配置和使用,以及在不同数据库后端如MySQL上的应用。
摘要由CSDN通过智能技术生成

https://www.lixiaodong.com/?p=1631.安装需要的包sudo apt-get install libc-ares-dev libcurl4-openssl-dev libmysqlclient-dev2.下载mosquitto源码并编译安装从http://mosquitto.org/download/ 下载源码并解压到某个目录,进入该目录编译安装make mosquittosudo make install3.下载mosquitto-auth-plug源码git clone https://github.com/jpmens/mosquitto-auth-plug.git并使用copy命令生成config.mk文件:cp config.mk.in config.mk编辑config.mk:根据需要选择合适的后台。我这里只使用mysql数据库验证用户,BACKEND_MYSQL这一行是yes,其余行都是no。在MOSQUITTO_SRC一行输入mosquitto的源码路径,比如MOSQUITTO_SRC =/root/mosquitto-1.4.4/。在OPENSSLDIR一行输入openssl的路径,比如OPENSSLDIR = /usr/lib/ssl。可以使用以下命令得到openssl的路径:openssl version -a4.进入mosquitto-auth-plug所在目录,使用make命令生成so文件。5.移动so文件到mosquitto目录(不是源码目录,而是安装后的目录)mv auth-plug.so /etc/mosquitto/6.编辑mosquitto配置文件mosquitto-auth-plug的源码里已经有多种范例配置文件,可以使用这些文件。比如,我用mysql做验证,可以使用 examples目录下的mosquitto-mysql.conf。mv mosquitto.conf mosquitto.conf.origin(保留原始配置文件,供以后使用)mv mosquitto-auth-plug目录/examples/mosquitto-mysql.conf mosquitto目录/mosquitto.conf根据实际情况,编辑文件里的auth_plugin,backend,数据库host,端口,数据库名,用户,密码,sql语句等。7.运行mosquitto并观察输出mosquitto -c mosquitto-conf -v问题:1. 输出显示Unable to load auth plugin ".../auth-plug.so"解决:编辑Mosquitto源码目录下的config.mk:WITH_SRV:=no然后重新编译:make cleanmake生成新的so文件。

How to make Access Control Lists (ACL) work for Mosquitto MQTT Broker with Auth Plugin?

If you planning to strengthening your MQTT service, then access control lists (ACL) are mandatory. Mosquitto broker supports this ACL feature through auth plugins.

One versatile auth-plugin for mosquitto that you should consider using is https://github.com/jpmens/mosquitto-auth-plug. It is very flexible, in that it can support multiple backends as auth provider databases, ranging from CDB, Redis to MySQL and Http. However, getting it compiled and making it start to work is not that straight forward or easy. Hence, this post. It gives some starting point to our students who are venturing into Mosquitto Authentication systems to get started.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值