2017-10-04 4 views
-1

私はMosquittoに取り組んでおり、Redisをバックエンドとして使用してユーザー名とパスワードのペア認証とACLの両方を処理する予定です。私はJPmensの認証プラグインを使ってこれを行っています。 モスキートACLのバックエンドとしてredisを使用する方法

はmosquitto confに:

SET user1-test 2 

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のために動作しません認証のために正常に動作しています以下は、モスキートのログです:

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- 

私はpub/sub mosquittoをしようとするとユーザーは認証されますが、ユーザーの公開と切断は許可されません。

テストで:サブ用

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

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

Just saそれがうまくいきません。どのように動作しないか、すべてのメッセージを許可するのか、それとも何も許さないのかを説明する必要がありますか?あなたがそれをテストするときにログには何が表示されますか?どのようにそれをテストしていますか? – hardillb

+0

@hardillb私は質問を編集しました。だから、あなたは問題が何であるか教えてください。:) –

答えて

0

OK、私はこれを働いてきました。

提供したログには重要なビットがありません。あなたは、次の行が含まれている必要があります。

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 
+0

ありがとうman..its働く –

+0

もう1つの疑問は、何が複数のトピックス(acl topics)をredisデータベース内の同じユーザー。 –

+0

複数のユーザートピックエントリを設定しました – hardillb

関連する問題