【问题标题】:How add authentication in MQTT transport WSO2 Message broker如何在 MQTT 传输 WSO2 消息代理中添加身份验证
【发布时间】:2017-08-22 23:00:13
【问题描述】:

我使用 WSO2 消息代理创建了一个示例发布和订阅模型项目。

import threading
import paho.mqtt.client as mqtt

def publish_1(client,topic):
    message="on"
    print("publish data")
    client.publish(topic,message)
    publish_1(client,topic)


broker="localhost"
topic_pub='/temperature123'
topic_sub='$SYS/#'

def on_connect(client, userdata, rc):
    print("Connected with result code "+str(rc))
    client.subscribe(topic_sub)


def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker, 1883, 60)
thread1=threading.Thread(target=publish_1,args=(client,topic_pub))
thread1.start()

但是这个实现没有安全性。

有人可以帮我在 WSO2 消息代理中的 MQTT 订阅中设置身份验证吗? 而且我在 WSO2 消息代理应用程序https://localhost:9443/carbon 中也没有看到任何订阅的节点信息@

【问题讨论】:

    标签: wso2 mqtt messagebroker wso2mb


    【解决方案1】:

    我的经验是使用 Mosquitto 而不是使用 WSO2 MB,但快速浏览一下 WSO2 MB 文档,它似乎支持 SSL,这是保护 MQTT 的标准方法 (https://docs.wso2.com/display/MB310/Enabling+SSL+Support)。这样做的过程非常简单,只需分发正确的密钥和证书,然后使用 tsl_set() 在脚本中配置它们。

    如果您需要更精细的用户/主题级别控件,它们看起来像是通过更大的 WSO2 框架 (https://docs.wso2.com/pages/viewpage.action?pageId=30540550#SecurityinWSO2MessageBroker/ApacheQpid-Auth) 提供的。但我会让有更多 WSO2 经验的人在那里解释你的选择。

    编辑:顺便说一句,以 / 开头的主题被视为一种不好的做法,因为它会创建一个令人困惑的 / 层。我会把主题写成“temperature123”

    【讨论】:

    • 感谢您的回答,但我需要在消息代理中进行一些基于角色的授权。例如,user1 可以在主题 /temperature 中发布消息,但 user2 不能这样做
    猜你喜欢
    • 2016-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-25
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多