Search code examples
dockerpluginsmqttmosquitto

Mosquitto dynamic security does not allow to insert clients or roles


Hi everyone I've been trying to use mosquitto dynamic security plugin, the broker is running in a docker container, and so far everything seems to work as expected I can generate de file dynamic-secutiry.json for that I used the following command mosquitto_ctrl dynsec init path/to/dynamic-security.json user and after that, I set the password as user, so managed to open the file and make sure that it was created right, and indeed it was. However, when I try to modify the file like adding a new client for instance I got the following message Connection error: Not authorized in order to add new clients I've been something like this mosquitto_ctrl -u user -P user dynsec createRole rolepizza and then I'm getting this: enter image description here

That's the dynamic-security.json

enter image description here

Finally my mosquitto.conf enter image description here

I've been following this tutorials:

https://www.youtube.com/watch?v=QvRBtRH2mN0

http://www.steves-internet-guide.com/understanding-mosquitto-dynamic-security-plugin/

I'd appreciate it if someone could tell me what I've been doing wrong. Thanks in advance


Solution

  • As hashed out in the comments, the problem was most likely a lack of write permissions on dynamic-security.json file due to creating it as root.

    Mosquitto will normally drop root permissions on startup, so all config/log files should be writable by a none privileged user (you can set the user in the mosquitto.conf file.