It consists of a docker-compose file that launches an mqtt broker with restricting access: only clients that manage the same access credentials ( username and password ) at the connection time are served.
docker-composelaunches the broker mqtt. It listens onlocalhost:1883. Themainloop.pyis used to interact with the broker, passing the authentication parameters. There is aconfig.jsonfile to set endpoint and credentials in order to interact with the broker. Changing username or password, the communication fails.
- It uses the
eclipse-mosquittoimage. There are two volumes to mount,mosquitto.confanddat.txt. The first is a configuration file, the second contains username and encrypted password.
allow_anonymous false
password_file /mosquitto/data/dat.txt
- create a text file, like the figure below
-
install
mosquitto -
now encrypt the password with the command
mosquitto_passwd -U <text_file>. The result of the encryption is shown in the figure below
docker-compose uppython3 mainloop.pyIf username and password used by the client are the same as those mounted on the broker, everything works. Vice versa the communication fails.

