DEV Community

Arshid
Arshid

Posted on

Mosquitto Auth Plugin - Rust

We can easily configure the MySQL Mosquitto-auth plugin. It is open source dynamic security plugin. Developed with rust programming language.

  1. Install the Mosquitto (MQTT) to Server Install the mosquitto from Ubuntu’s software repository.

Update the package information

sudo apt update
Enter fullscreen mode Exit fullscreen mode
  1. Install the mosquitto package.
sudo apt install -y mosquitto
Enter fullscreen mode Exit fullscreen mode
  1. Stop the mosquitto service
sudo systemctl stop mosquitto
Enter fullscreen mode Exit fullscreen mode
  1. Download mosquitto-auth.so file (Download)

  2. Edit mosquitto.conf file

sudo vi /etc/mosquitto/mosquitto.conf
Enter fullscreen mode Exit fullscreen mode
  1. And add the following entries to the mosquitto.conf file.
plugin /path/to/mosquitto_auth.so
#listener 1883
Enter fullscreen mode Exit fullscreen mode

Configure MySQL Database and Tables

Download the mosquitto.sql file and import it to your MySQL by PHPMyAdmin. Then create a .env file and add database credentials.

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mosquitto
DB_USERNAME=root
DB_PASSWORD="Pass"
Enter fullscreen mode Exit fullscreen mode

Move .env file to /

mv /path/to/.env /.env
Enter fullscreen mode Exit fullscreen mode

Start the mosquitto server

sudo systemctl start mosquitto
Enter fullscreen mode Exit fullscreen mode

Now it is ready to check username with password and permission.

Top comments (0)