国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
Mosquitto 后端redis等權(quán)限驗(yàn)證集成
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.
Building the Mosquitto-Auth-Plugin
The below steps help you for Ubuntu or its variants. Similar steps should get you going with CentOS or other variants if you replace the apt-get commands with their equivalents, such as yum etc.
Install required helper and developer packages firstsudo apt-get install libc-ares-dev libcurl4-openssl-dev libmysqlclient-dev
Get Mosquitto source and build itGet source from: http://mosquitto.org/download/
tar xvzf mosquitto-1.3.5.tar.gz
cd mosquitto-1.3.5
make mosquitto
sudo make install
Get mosquitto-auth-plug source and create a suitable configuration filegit clone https://github.com/jpmens/mosquitto-auth-plug.git
cd mosquitto-auth-plug
cp config.mk.in config.mk
Edit the created config.mk file to suit your needsvi config.mk
Install the appropriate backend developer files (e.g. redis backend)git clone https://github.com/redis/hiredis.git
make && make install
Inside the mosquitto-auth-plug directory use the make command to build the plugin and move it next tomosquitto.conf filemake
mv auth-plug.so /etc/mosquitto/
Edit the Mosquitto configuration filemv /etc/mosquitto/mosquitto.conf.example /etc/mosquitto/mosquitto.conf
vi /etc/mosquitto/mosquitto.conf
Editing the Mosquitto configuration for enabling Auth Plugin
Inside your mosquitto.conf file you should indicate the auth-plugin options to let the mosquitto MQTT broker know that you are planning on using an auth-plugin and where it is located on the disk.
Note: Mosquitto MQTT broker usually runs under the identify of an user named mosquitto. So, you should ensure the path toauth-plug.so is accessible to the mosquitto user. You can set permissions using chown and/or chmod commands.
Edit the /etc/mosquitto/mosquitto.conf file to have its content look something like below (you should search for auth_plugin field in that file):
auth_plugin /etc/mosquitto/auth-plug.so
auth_opt_backends mysql
auth_opt_redis_host 162.252.108.129
auth_opt_redis_port 12885
auth_opt_host sql3.freemysqlhosting.net
auth_opt_port 3306
auth_opt_dbname sql366410
auth_opt_user sql366410
auth_opt_pass nX4*jZ3%
auth_opt_userquery SELECT pw FROM users WHERE username = ‘%s’
auth_opt_superquery SELECT COUNT(*) FROM users WHERE username = ‘%s’ AND super = 1
auth_opt_aclquery SELECT topic FROM acls WHERE (username = ‘%s’) AND (rw >= %d)
auth_opt_anonusername AnonymouS
Read the documentation at https://github.com/jpmens/mosquitto-auth-plug to know more about what these fields are how to customize them.
Testing the ACL workings with Mosquitto Broker
Once you have edited the mosquitto configuration file to indicate the auth-plugin presence and its backend options, you are ready to deploy it. But before that you need to actually create the user and acl databases in your chosen backend database. In the below few steps are illustrated for mysql as an example database, but the steps should be similar for other databases too.
As a first step, you want to create tables inside your chosen backend database. For mysql you can do this easily using the sample sql script in the examples directory of mosquitto-auth-plug source code
Use the np application found in the mosquitto-auth-plug directory to generate the PBKDF2 strings for passwords
Create new user records with generated PBKDF2 strings in the mysql user table
Edit the acl table to add new topics and restrictions for the created users
Start the mosquitto broker with the modified configuration/usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Run a sample sub instancemosquitto_sub -t “topic” -u userName -P password
Run a sample pub instancemosquitto_pub  -t ‘topic’ -m message -u userName -P password
Points to remember:
You never store actual passwords in the backend databases. Only the PBKDF2 strings of the passwords.
When you are starting mosquitto_sub and mosquitto_pub you need to use original passwords (and not PBKDF2 strings).
PBKDF2 strings are not reversible – that is, for the same password you are not guaranteed to get the same PBKDF2 string every time. They change. Which means, from PBKDF2 string you cannot get back your original password – so you have to remember your passwords (and not rely upon the database to get them back).
Big Data Hadoop Practice Exams
$19.99 $9.99
CCA-500 Hadoop Administrator Practice Exam
59
$19.99 $9.99
Big data Analytics – Data Science Practice Exam
7
$19.99 $9.99
CCA-410 Hadoop Administrator Practice Exam
28
$19.99 $9.99
Specialist in Apache HBase Practice Exam
12
See All …
Share this:
Facebook
Twitter
Google
More
3
February 5, 2015 by My-Classes in
Discussions
authenticationcompilingconfigurationmosquittomqttpluginpubsub
Comments
csuarezgfx
October 7, 2015Log in to Replygreat tutorial thank you. I think I finally got it to work. Would you consider walking us through the pub/sub commands using the auth-plug. I think you could make a great tutorial demonstrating how it works, when it works and when it could possibly give you unexpected responses.
csuarezgfx
October 8, 2015Log in to ReplyThese lines in your config file will cause this error when trying to authenticate:
1444251139: |– mosquitto_auth_unpwd_check(S1)
1444251139: |– ** checking backend mysql
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘??S1’’ at line 1
config lines:
auth_opt_userquery SELECT pw FROM users WHERE username = ‘%s’
auth_opt_superquery SELECT COUNT(*) FROM users WHERE username = ‘%s’ AND super = 1
auth_opt_aclquery SELECT topic FROM acls WHERE (username = ‘%s’) AND (rw >= %d)
all you have to do is replace the curly single quotes with the keyboard straight single quotes and make sure that the final %d also has single quotes:
auth_opt_userquery SELECT pw FROM users WHERE username = ‘%s’
auth_opt_superquery SELECT COUNT(*) FROM users WHERE username = ‘%s’ AND super = 1
auth_opt_aclquery SELECT topic FROM acls WHERE (username = ‘%s’) AND (rw >= ‘%d’)
Thank you for the tutorial
My-Classes
October 8, 2015Log in to ReplyThank you for the comment. Yes, the quotes are due to the HTML editor transcription and correcting them as you suggested should work.
Wish you the best
http://my-classes.com/
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Experiences of Using PHP in Large Websites
SQL: Better to Best NDS
開(kāi)源broker軟件mosquitto(mqtt v3.1支持協(xié)議)
Golang構(gòu)建簡(jiǎn)單web框架
Flask+Vue 用戶(hù)登錄
mssql,mysql,access,Oracle 數(shù)據(jù)庫(kù)連接字符串
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服