Reputation: 195
I have an MQTT broker where devices are connecting to it and publishing data to the broker and I have a nodejs program that helps clients, subscribe to the topic, and receive the data they are publishing through their device.
Now my use case is to provide each client with a unique token which they have to send while connecting the MQTT broker in order to start publishing the data. And I want to validate that client token using an API and then establish a connection between the client and MQTT Broker.
I have searched for my use case but I have not found any help.
Upvotes: 2
Views: 959
Reputation: 346
If you're willing to give up using Mosquitto, you can instead use the aedes node.js library that lets you easily set up an mqtt broker.
There you can implement any auth logic you want, by using the handler.authenticate
, handler.authorizePublish
and handler.authorizeSubscribe
. No need to rely on a plugin.
Upvotes: 0
Reputation: 59608
Mosquitto has an authorisation plugin API that will let you build your authentication scheme.
The doc for the API is here
You can also search GitHub for existing auth plugins e.g. https://github.com/jpmens/mosquitto-auth-plug (this plugin is no longer being developed but there are active forks)
Upvotes: 2