{"id":1835,"date":"2019-01-25T20:03:05","date_gmt":"2019-01-25T12:03:05","guid":{"rendered":"https:\/\/zocodev.com\/?p=329"},"modified":"2019-01-25T20:03:05","modified_gmt":"2019-01-25T12:03:05","slug":"mosquitto-auth-plug","status":"publish","type":"post","link":"https:\/\/cloudbool.com\/archive\/mosquitto-auth-plug.html","title":{"rendered":"mosquitto\u8ba4\u8bc1\u6a21\u5757\u7f16\u8bd1"},"content":{"rendered":"<p>\u56e0\u4e3a\u516c\u53f8\u9879\u76ee\u8981\u7528\u5230MQTT\u8fdb\u884c\u901a\u4fe1\uff0c\u8bd5\u4e86\u51e0\u4e2a\u6bd4\u8f83\u51fa\u540d\u7684Broker\u4e4b\u540e\uff0c\u6700\u540e\u8fd8\u662f\u51b3\u5b9a\u9009\u62e9\u5f00\u6e90\u7684mosquitto\uff0c\u4f46\u662f\u56e0\u4e3amosquitto\u672c\u8eab\u4e0d\u5e26MySQL\u8ba4\u8bc1\u529f\u80fd\uff0c\u671f\u95f4\u8e29\u4e86\u4e9b\u5751\uff0c\u7559\u4e2a\u7f16\u8bd1\u8fc7\u7a0b\u8bb0\u5f55\u4e00\u4e0b\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u5199\u5728\u5f00\u59cb<\/h2>\n<p>\u5176\u5b9e\u6211\u4eec\u7684\u4e1a\u52a1\u9700\u6c42\u4e5f\u4e0d\u7b97\u590d\u6742\uff0c\u56e0\u4e3a\u673a\u5668\u53ef\u80fd\u4e0d\u6b62\u5c11\u6570\u51e0\u4e2a\uff0c\u4e0d\u80fd\u91c7\u7528\u5199\u6b7b\u914d\u7f6e\u6587\u4ef6\u7684\u5f62\u5f0f\u8fdb\u884c\u8ba4\u8bc1\uff0c\u60f3\u627e\u4e2a\u53ef\u4ee5\u652f\u6301\u7b2c\u4e09\u65b9\u8ba4\u8bc1\u7684MQTT Broker\uff0c\u6bd4\u5982MySQL\u6216\u8005Redis\uff0c\u8fd9\u6837\u53ef\u4ee5\u52a8\u6001\u7ba1\u7406\u8fde\u63a5\u5230Broker\u7684\u7528\u6237\u3002<\/p>\n<p>\u5728\u51b3\u5b9a\u4f7f\u7528mosquitto\u4e4b\u524d\uff0c\u6211\u4e5f\u8bd5\u8fc7\u4e86\u56fd\u5185\u6bd4\u8f83\u6709\u540d\u7684emqx\uff0c\u56e0\u4e3a\u770b\u4ed6\u4eec\u5b98\u7f51\u6587\u6863\uff0c\u64cd\u4f5c\u8d77\u6765\u65b9\u4fbf\uff0c\u529f\u80fd\u8fd8\u5f3a\u5927\uff0c\u5b89\u88c5\u4e5f\u5bb9\u6613\uff0c\u60f3\u8bd5\u8bd5\u8fd9\u4e2a\u5bf9\u6211\u4eec\u6765\u8bf4\u65b0\u51fa\u7684\u4ea7\u54c1\uff0c\u4f46\u662f\u5728\u914d\u7f6e\u597demqx\u4ee5\u53ca\u76f8\u5173\u7684MySQL\u6570\u636e\u5e93\u53ca\u5bf9\u5e94\u7684\u8868\u4e4b\u540e\u53d1\u73b0\uff0c\u65e0\u8bba\u600e\u4e48\u8bbe\u7f6e\u90fd\u65e0\u6cd5\u8fde\u63a5\u5230Broker\uff0c\u67e5\u770b\u65e5\u5fd7\u51fa\u73b0\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n<pre><code>2019-01-22 15:36:49.837 [error] 0823d407-4506-4ad8-91a3-c9459ec9a1fe1548126026622@192.168.0.167:52079 [MQTT] Username '45360' login failed for auth_modules_not_found\n<\/code><\/pre>\n<p>\u800c\u624b\u52a8\u52a0\u8f7d\u8ba4\u8bc1\u63d2\u4ef6\u53c8\u51fa\u73b0\u8fd9\u4e2a\u63d0\u793a\uff1a<\/p>\n<pre><code>[root@LocalServer ~]# emqx_ctl plugins load emqx_auth_mysql\nload plugin error: already_started\n=ERROR REPORT==== 22-Jan-2019::15:37:51.609510 ===\n[Plugins] Plugin emqx_auth_mysql is already started\n<\/code><\/pre>\n<p>\u4e0d\u7ba1\u662f\u76ee\u524d\u6700\u65b0\u7248\u7684emqx 3.0\u8fd8\u662f\u4e4b\u524d\u7684emqttd 2.x\uff0c\u9047\u5230\u51e0\u4e2abug\u5728\u5404\u4e2a\u641c\u7d22\u5f15\u64ce\u90fd\u627e\u4e0d\u5230\u89e3\u51b3\u65b9\u6848\uff0c\u8fd9\u90fd\u7b97\u4e86\uff0c\u5b98\u7f51\u7559\u7684\u51e0\u4e2aQQ\u7fa4\uff0c\u52a0\u5165\u4e4b\u540e\uff0c\u91cc\u9762\u662f\u6709\u5b98\u65b9\u4eba\u5458\u5728\uff0c\u4f46\u662f\u5e76\u4e0d\u4f1a\u56de\u7b54\u7fa4\u53cb\u7684\u95ee\u9898\uff0c\u9664\u4e86github\u4e5f\u627e\u4e0d\u5230\u5bf9\u5e94\u7684\u8bba\u575b\uff0c\u51fa\u4e8e\u957f\u8fdc\u8003\u8651\uff0c\u6015\u4ee5\u540e\u9047\u5230\u95ee\u9898\u89e3\u51b3\u8d77\u6765\u6210\u672c\u592a\u9ad8\uff0c\u8fd8\u662f\u51b3\u5b9a\u7528\u56de\u5f00\u6e90\u7684mosquitto\uff0c\u800cCentOS7\u81ea\u5e26\u7684mosquitto\u5e76\u6ca1\u6709\u5305\u542bauth\u63d2\u4ef6\uff0c\u4e8e\u662f\u624d\u6709\u4e86\u8fd9\u7bc7\u7f16\u8bd1mosquitto\u7684<strong>mosquitto-auth-plug<\/strong>\u6d41\u6c34\u8d26\u3002<\/p>\n<h2>\u7f16\u8bd1\u524d\u51c6\u5907<\/h2>\n<p>\u6211\u4eec\u6b63\u5f0f\u670d\u52a1\u5668\u6253\u7b97\u91c7\u7528CentOS7\uff0c\u6240\u4ee5\u672c\u5730\u6d4b\u8bd5\u670d\u52a1\u5668\u4e5f\u662f\u91c7\u7528CentOS7\uff0c\u672c\u7bc7\u7f16\u8bd1\u6240\u6d89\u53ca\u7684\u64cd\u4f5c\u4e5f\u662f\u57fa\u4e8eCentOS7\u8fdb\u884c\u3002<\/p>\n<p>\u4e3a\u4e86\u65b9\u4fbf\uff0c\u6211\u4eec\u53ef\u4ee5\u5148\u884c\u6dfb\u52a0\u5b98\u65b9\u7684CentOS7\u6e90\uff1a<\/p>\n<pre><code>vim \/etc\/yum.repos.d\/mqtt.repo\n\n[home_oojah_mqtt]\nname=mqtt (CentOS_CentOS-7)\ntype=rpm-md\nbaseurl=http:\/\/download.opensuse.org\/repositories\/home:\/oojah:\/mqtt\/CentOS_CentOS-7\/\ngpgcheck=1\ngpgkey=http:\/\/download.opensuse.org\/repositories\/home:\/oojah:\/mqtt\/CentOS_CentOS-7\/repodata\/repomd.xml.key\nenabled=1\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b98\u65b9\u7684mosquitto\uff1a<\/p>\n<pre><code>yum install mosquitto\n<\/code><\/pre>\n<p>CentOS7\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\uff0c\u5df2\u7ecf\u5b89\u88c5\u4e86\u7684\u53ef\u4ee5\u5ffd\u7565\uff1a<\/p>\n<pre><code>yum install gcc automake autoconf libtool make \n<\/code><\/pre>\n<p>\u4e0b\u8f7dmosquitto\u6e90\u7801\uff0c\u4e0b\u8f7d\u597d\u89e3\u538b\u5c31\u884c\uff0c\u6ca1\u4ec0\u4e48\u8bf4\u7684\uff1a<br \/>\nhttp:\/\/mosquitto.org\/download\/<\/p>\n<p>mosquitto-auth-plug\u6e90\u7801\uff1a<\/p>\n<pre><code>git clone https:\/\/github.com\/jpmens\/mosquitto-auth-plug\n<\/code><\/pre>\n<p>\u56e0\u4e3a\u6211\u662f\u6253\u7b97\u4f7f\u7528MySQL\u4f5c\u4e3a\u8ba4\u8bc1\u6e90\uff0c\u7f16\u8bd1<strong>mosquitto-auth-plug<\/strong>\u9700\u8981\u4f9d\u8d56MySQL\u7684\u5f00\u53d1\u5e93\uff0c\u800c\u6211\u4eec\u4f7f\u7528\u7684\u662fMySQL\u5b98\u65b9\u63d0\u4f9b\u7684MySQL\u793e\u533a\u7248\uff08\u76f8\u5173\u6587\u7ae0\uff1a<a href=\"https:\/\/zocodev.com\/centos7-mysql.html\">CentOS7\u5b89\u88c5\u914d\u7f6eMySQL<\/a>\uff09\uff0c\u5b89\u88c5MySQL\u5f00\u53d1\u5e93\u6587\u4ef6\uff1a<\/p>\n<pre><code>yum install mysql-community-devel\n<\/code><\/pre>\n<p>\u7136\u540e\u662f\u5b89\u88c5mosquitto\u76f8\u5173\u7684\u4f9d\u8d56\uff1a<\/p>\n<pre><code>yum install libmosquitto-devel.x86_64\n<\/code><\/pre>\n<h2>\u914d\u7f6e\u53ca\u7f16\u8bd1mosquitto-auth-plug<\/h2>\n<p>\u5176\u5b9e\u914d\u7f6e\u8fd9\u4e2a\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4fee\u6539\u5176\u4e2d\u4e00\u4e2a\u6587\u4ef6\u5c31\u884c\uff1a<\/p>\n<pre><code>cp config.mk.in config.mk\n\nvim config.mk\n<\/code><\/pre>\n<p>\u914d\u7f6e\u6587\u4ef6\u9ed8\u8ba4\u9009\u62e9\u7684\u5c31\u662fMySQL\uff0c\u6240\u4ee5\u4e0a\u65b9\u7684\u6570\u636e\u5e93\u4fe1\u606f\u4e0d\u9700\u8981\u6539\uff0c\u8981\u6539\u7684\u53ea\u662f<strong>MOSQUITTO_SRC<\/strong>\u53ca<strong>OPENSSLDIR<\/strong>\u5c31\u884c\uff0c\u524d\u8005\u590d\u5236\u4e0a\u65b9\u4e0b\u8f7d\u89e3\u538b\u540e\u7684mosquitto\u6e90\u7801\u76ee\u5f55\u5c31\u884c\uff0c\u540e\u8005\u53ef\u4ee5\u901a\u8fc7<strong>openssl version -a<\/strong>\u5f97\u5230\uff0cCentOS7\u9ed8\u8ba4\u5728<strong>\/etc\/pki\/tls<\/strong>\u3002<\/p>\n<p>\u4fee\u6539\u597d\u4e4b\u540e\u5728mosquitto-auth-plug\u6267\u884c<strong>make<\/strong>\u5c31\u884c\uff0c\u5982\u679c\u6ca1\u6709\u610f\u5916\uff0c\u80fd\u5728\u76ee\u5f55\u4e0b\u65b9\u5f97\u5230\u4e00\u4e2a<strong>auth-plug.so<\/strong>\uff0c\u8fd9\u5c31\u662f\u6211\u4eec\u9700\u8981\u7684\u63d2\u4ef6\u6587\u4ef6\u3002<\/p>\n<p>\u5c06\u5f97\u5230\u7684\u6587\u4ef6\u590d\u5236\u5230mosquitto\u76f8\u5173\u76ee\u5f55\uff1a<\/p>\n<pre><code>cp auth-plug.so \/var\/lib\/mosquitto\n<\/code><\/pre>\n<h2>mosquitto MySQL\u8ba4\u8bc1\u914d\u7f6e<\/h2>\n<p>\u5982\u679c\u662f\u6309\u4e0a\u65b9\u6b65\u9aa4\u5b89\u88c5\u7684\u5b98\u65b9\u7684mosquitto\u7684\u8bdd\uff0cmosquitto\u7684\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u5728\u662f<strong>\/etc\/mosquitto\/mosquitto.conf<\/strong>\uff0c\u4f46\u662f\u770b\u914d\u7f6e\u6587\u4ef6\u63a8\u8350\u6211\u4eec\u6700\u597d\u662f\u5728<strong>\/etc\/mosquitto\/conf.d\/<\/strong>\u76ee\u5f55\u4e0b\u5b9a\u4e49\u6211\u4eec\u7684\u914d\u7f6e\uff0c\u6240\u4ee5\uff1a<\/p>\n<pre><code>vim \/etc\/mosquitto\/conf.d\/auth.conf\n\nauth_plugin \/var\/lib\/musquitto\/auth-plug.so\n\nauth_opt_backends mysql\n\nauth_opt_host 192.168.0.129\nauth_opt_port 3306\nauth_opt_dbname dbname\nauth_opt_user dbuser\nauth_opt_pass dbpassword\n\nauth_opt_userquery SELECT pw FROM mqtt_users WHERE username = '%s'\nauth_opt_superquery SELECT COUNT(*) FROM mqtt_users WHERE username = '%s' AND super = 1\nauth_opt_aclquery SELECT topic FROM acls WHERE (username = '%s') AND (rw &gt;= %d)\nauth_opt_anonusername AnonymouS\n<\/code><\/pre>\n<p>\u4e0a\u9762\u6570\u636e\u5e93\u90e8\u5206\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u5373\u53ef\u3002<\/p>\n<p>\u800c\u6d89\u53ca\u5230\u7684\u4e24\u4e2a\u8868\uff0c\u7ed3\u6784\u53ca\u521d\u59cb\u6570\u636e\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\uff1ahttps:\/\/github.com\/jpmens\/mosquitto-auth-plug\/blob\/master\/examples\/mysql.sql<\/p>\n<p>\u8fd9\u4e2a\u63d2\u4ef6\u5bc6\u7801\u4f7f\u7528\u7684\u5904\u7406\u65b9\u5f0f\u4e0d\u662f\u666e\u901a\u7684md5\u6216\u8005bcrypt\uff0c\u5b83\u7528\u7684\u662f\u4e00\u79cd\u6211\u4ee5\u524d\u90fd\u6ca1\u89c1\u8fc7\u7684\u53eb\u505a<strong>PBKDF2<\/strong>\u7684\u7b97\u6cd5\uff0c\u5982\u679c\u53ea\u662f\u7b80\u5355\u7684\u4f7f\u7528\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u6267\u884c\u63d2\u4ef6\u6e90\u7801\u76ee\u5f55\u4e0b\u9762\u7684<strong>np<\/strong>\u7a0b\u5e8f\u5373\u53ef\uff0c\u6bd4\u5982\u8bf4\u52a0\u5bc6123456\uff1a<\/p>\n<pre><code>[root@LocalServer mosquitto-auth-plug]# .\/np\nEnter password:\nRe-enter same password:\nPBKDF2$sha256$901$xKEbqtQj\/1A8jlrW$Lo84WQjDJRlgUpH0VgrQSwluo3Yh4brl\n<\/code><\/pre>\n<p>\u53ea\u8981\u914d\u5408\u522b\u7684\u5b57\u6bb5\u63d2\u5165\u5230\u6570\u636e\u5e93\u5c31\u884c\u4e86\u3002<\/p>\n<h2>mosquitto-auth-plug\u7684acls\u8868\u8e29\u7684\u5751<\/h2>\n<p>\u7f51\u4e0a\u5404\u79cd\u6559\u7a0b\u4ee5\u53ca\u63d2\u4ef6\u5b98\u65b9\u6587\u6863\u4e5f\u662f\u8bf4\u53ea\u9700\u8981\u5efa\u7acbacls\u8868\u4ee5\u53ca\u5c06\u8868\u81ea\u5e26\u7684\u6570\u636e\u63d2\u5165\u8fdb\u53bb\u5c31\u53ef\u4ee5\uff0c\u6bd4\u5982\u8bf4\uff1a<\/p>\n<pre><code>INSERT INTO acls (username, topic, rw) VALUES ('jjolie', 'loc\/jjolie', 1);\nINSERT INTO acls (username, topic, rw) VALUES ('jjolie', 'loc\/ro', 1);\nINSERT INTO acls (username, topic, rw) VALUES ('jjolie', 'loc\/rw', 2);\n<\/code><\/pre>\n<p>\u4f46\u662f\uff0c\u6211\u5b9e\u9645\u64cd\u4f5c\u4e4b\u540e\u53d1\u73b0\uff0c\u5982\u679c\u5c06acls\u8868\u7684rw\u5b57\u6bb5\u65e0\u8bba\u662f\u8bbe\u7f6e\u62101\u8fd8\u662f2\uff0c\u767b\u5f55\u4e4b\u540e\u7684\u7528\u6237\u4e0d\u7ba1\u600e\u6837\u90fd\u65e0\u6cd5\u8ba2\u9605\u81ea\u5df1\u53d1\u5e03\u7684\u4e3b\u9898\uff0c\u800c\u547d\u4ee4\u884c\u8f93\u51fa\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre><code>[root@LocalServer conf.d]# mosquitto -c \/etc\/mosquitto\/mosquitto.conf\n1548226914: mosquitto version 1.5.5 starting\n1548226914: Config loaded from \/etc\/mosquitto\/mosquitto.conf.\n1548226914: |-- *** auth-plug: startup\n1548226914: |-- ** Configured order: mysql\n\n1548226914: |-- }}}} MYSQL\n1548226914: |-- SSL is disabled\n1548226914: Opening ipv4 listen socket on port 1883.\n1548226914: Opening ipv6 listen socket on port 1883.\n1548226915: New connection from 192.168.0.167 on port 1883.\n1548226915: |-- mosquitto_auth_unpwd_check(test)\n1548226915: |-- ** checking backend mysql\n1548226915: |-- getuser(test) AUTHENTICATED=1 by mysql\n1548226915: New client connected from 192.168.0.167 as df340202-7f22-429d-b69f-10ae7f4ec4371548226911318 (c1, k10, u'test').\n1548226917: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226917: |-- aclcheck(test, a, 4) AUTHORIZED=0 by none\n1548226917: |--  Cached  [0F3AC5804940450E6618E24965E0D9366D04F994] for (client id not available,test,4)\n1548226918: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226918: |--   mysql: topic_matches(a, a) == 1\n1548226918: |-- aclcheck(test, a, 2) trying to acl with mysql\n1548226918: |-- aclcheck(test, a, 2) AUTHORIZED=1 by mysql\n1548226918: |--  Cached  [159AEA2A69EF3800BD6FC08E9217324386EAECA0] for (client id not available,test,2)\n1548226918: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226918: |-- aclcheck(test, a, 2) CACHEDAUTH: 0\n1548226919: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226919: |-- aclcheck(test, a, 2) CACHEDAUTH: 0\n1548226919: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226919: |-- aclcheck(test, a, 2) CACHEDAUTH: 0\n1548226919: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226919: |-- aclcheck(test, a, 2) CACHEDAUTH: 0\n1548226919: |-- mosquitto_auth_acl_check(..., client id not available, test, a, MOSQ_ACL_WRITE)\n1548226919: |-- aclcheck(test, a, 2) CACHEDAUTH: 0\n^C1548227016: mosquitto version 1.5.5 terminating\n1548227016: Saving in-memory database to \/var\/lib\/mosquitto\/mosquitto.db.\n<\/code><\/pre>\n<p>\u660e\u660e\u662f\u80fd\u6b63\u786e\u767b\u5f55\u5230Broker\uff0c\u4f46\u662f\u5c31\u662f\u6536\u4e0d\u5230\u81ea\u5df1\u53d1\u5e03\u7684\u6d88\u606f\uff0c\u67e5\u4e86\u597d\u4e45\u624d\u627e\u5230\u4e00\u4e2a\u95ee\u9898\u7684\u89e3\u7b54\u8bf4\uff0c\u662f\u56e0\u4e3amosquitto 1.5\u4e4b\u540eMOSQ_ACL_SUBSCRIBE\u6709\u4e86\u53d8\u5316\uff0c\u53ef\u9009\u7684\u503c\u4e0d\u518d\u53ea\u6709\u4ee5\u524d\u76841\u548c2\uff0c\u53d8\u6210\u4e860-7\uff0c\u8fd9\u95ee\u9898\u6574\u6574\u82b1\u8d39\u4e86\u62113\u5929\u7684\u65f6\u95f4\uff0c\u6211\u4e5f\u662f\u5475\u5475\u4e86\u3002<\/p>\n<p>\u8fd9\u662f\u65b0\u7248\u7684ALC\u7b56\u7565\uff1a<\/p>\n<pre><code>0: no access\n1: read\n2: write\n3: read and write\n4: subscribe\n5: read &amp; subscribe\n6: write &amp; subscribe\n7: read, write and subscribe\n<\/code><\/pre>\n<p>\u5982\u679c\u548c\u6211\u4e00\u6837\uff0c\u5404\u9879\u68c0\u67e5\u90fd\u6ca1\u95ee\u9898\uff0c\u800c\u5c31\u662f\u65e0\u6cd5subscribe topic\u7684\u670b\u53cb\uff0c\u53ef\u4ee5\u8bd5\u7740\u66f4\u6539\u4e0b\u4e0a\u9762\u7684rw\u503c\u3002<br \/>\n\u6765\u6e90\uff1ahttps:\/\/stackoverflow.com\/a\/54120778\/10954188<\/p>\n<h2>mosquitto-auth-plug\u914d\u5408Laravel\u4f7f\u7528PHP\u751f\u6210\u5bc6\u7801<\/h2>\n<p>\u4e0a\u9762\u8bf4\u4e86\uff0c\u56e0\u4e3amosquitto-auth-plug\u8fd9\u4e2a\u63d2\u4ef6\u4e0d\u662f\u4f7f\u7528\u666e\u901a\u7684md5\u7b49\u51fd\u6570\u8fdb\u884c\u5904\u7406\u5bc6\u7801\uff0c\u8fd9\u5c31\u5bfc\u81f4\u6211\u4eec\u64cd\u4f5c\u6570\u636e\u5e93\u7b49\u9700\u8981\u6309\u7167\u8fd9\u4e2a\u63d2\u4ef6\u7684\u65b9\u5f0f\u6765\u5904\u7406\u3002<\/p>\n<p>\u8bf4\u5b9e\u8bdd\uff0c\u6211\u4e5f\u627e\u4e86\u5f88\u4e45\u8981\u600e\u4e48\u7528PHP\u6765\u5904\u7406<strong>PBKDF2<\/strong>\u8fd9\u79cd\u683c\u5f0f\uff0c\u7f51\u4e0a\u627e\u4e86\u4e2a\u5e93\u53d1\u73b0\u751f\u6210\u7684\u5bc6\u7801\u683c\u5f0f\u90fd\u548c\u5b98\u65b9\u9884\u8bbe\u7684\u90a3\u51e0\u4e2a\u4e0d\u4e00\u6837\uff0c\u653e\u72d7\u641c\u4e86\u4e00\u628a\u4e4b\u540e\u53d1\u73b0\uff0c\u5176\u5b9e\u63d2\u4ef6\u4f5c\u8005\u5728\u63d2\u4ef6\u6e90\u7801\u76ee\u5f55\u5c31\u6709\u5404\u79cd\u8bed\u8a00\u7684\u52a0\u5bc6\u65b9\u5f0f\u7684\u5b9e\u73b0\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><code>cd mosquitto-auth-plug\/contrib\n\n[root@LocalServer contrib]# ls\nC#  genhash.php  golang  java  nodejs  python  python3  ruby  tinycdb-0.78\n<\/code><\/pre>\n<p>\u8fd8\u662fPHP\u7b80\u5355\u7c97\u66b4\uff0c\u4e00\u4e2a\u6587\u4ef6\u5c31\u89e3\u51b3\u4e86\uff0c\u51c6\u786e\u7684\u8bf4\u662f\u4e24\u4e2a\u51fd\u6570\u5c31\u641e\u5b9a\u4e86\u3002\u5982\u679c\u60f3\u8981\u6574\u5408\u8fdbLaravel\u7684\u8bdd\uff0c\u53ea\u9700\u8981\u5c06genhash.php\u91cc\u9762\u7684\u5185\u5bb9\u60f3\u529e\u6cd5\u6dfb\u52a0\u5230Laravel\u6846\u67b6\u80fd\u52a0\u8f7d\u5230\u7684\u6587\u4ef6\u5c31\u884c\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>mosquitto\u8fd8\u662f\u633a\u5f3a\u5927\u7684\uff0c\u914d\u7f6eMySQL\u8ba4\u8bc1\u867d\u7136\u8fc7\u7a0b\u6709\u70b9\u66f2\u6298\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5b66\u5230\u4e86\u4e0d\u5c11\u4e1c\u897f\uff0c\u4e5f\u7b97\u662f\u5bf9\u5f97\u8d77\u82b1\u8d39\u7684\u65f6\u95f4\u5427\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u516c\u53f8\u9879\u76ee\u8981\u7528\u5230MQTT\u8fdb\u884c\u901a\u4fe1\uff0c\u8bd5\u4e86\u51e0\u4e2a\u6bd4\u8f83\u51fa\u540d\u7684Broker\u4e4b\u540e\uff0c\u6700\u540e\u8fd8\u662f\u51b3\u5b9a\u9009\u62e9\u5f00\u6e90\u7684mosquitt &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/cloudbool.com\/archive\/mosquitto-auth-plug.html\"> <span class=\"screen-reader-text\">mosquitto\u8ba4\u8bc1\u6a21\u5757\u7f16\u8bd1<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[12],"tags":[17,74],"class_list":["post-1835","post","type-post","status-publish","format-standard","hentry","category-app","tag-centos","tag-mqtt"],"_links":{"self":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/comments?post=1835"}],"version-history":[{"count":0,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/posts\/1835\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/media?parent=1835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/categories?post=1835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudbool.com\/archive\/wp-json\/wp\/v2\/tags?post=1835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}