Reputation: 482
I would like to set up an own Mosquitto broker as a docker container. This is not a problem since there are several ready to run containers out there.
My problem is, how can i configure mosquitto in a way, that i can store the user login credentials, for authentication against mosquitto, in a Database like mysql instead of a password file.
The background is, i would like to configure the access by a PHP script. Im open to other methods instead of using a mysql db.
But i think a db would be the best solution. Im also open to alternatives to Mosquitto. I only would like to use MQTT with a DB based user authentication.
thanks
Upvotes: 2
Views: 4130
Reputation: 2218
The plugin suggested in accepted answer is abandoned!
The current go to plugin is https://github.com/iegomez/mosquitto-go-auth it is even suggested in the official docs.
Upvotes: 0
Reputation: 2875
This repository comes with a pre-configured mosquitto
broker along with a PostgreSQL
DB auth
where you can add
/edit
/delete
users.
Link: https://github.com/vish30/docker-mosquitto
Upvotes: 0
Reputation: 59751
I have a Dockerfile that will build a container with both Mosquitto and the authentication plugin (https://github.com/jpmens/mosquitto-auth-plug). In my case I set it up to work against a instance of MongoDB hosted in the same container, but it would not be too hard to modify it to work against a MySQL instance, either local or remote.
I've put the Dockerfile up on Gist here as a starting reference.
Upvotes: 1