mosquitto-auth

Crates.iomosquitto-auth
lib.rsmosquitto-auth
version0.1.3
sourcesrc
created_at2023-03-15 08:18:44.834937
updated_at2024-11-20 08:46:47.350484
descriptionPlugin for mosquitto authentication
homepagehttps://github.com/arshidkv12/mosquitto-plugin
repositoryhttps://github.com/arshidkv12/mosquitto-plugin
max_upload_size
id810566
size13,081
Arshid (arshidkv12)

documentation

https://github.com/arshidkv12/mosquitto-plugin

README

Mosquitto Dynamic Security (Mosquitto Auth Plugin - Rust)

Mosquitto authentication and ACL (Access control list) checking plugin. It is working based on MYSQL database.

Configuration

How to install?

Download mosquitto-auth.so file and load .conf file as follows mosquitto -c mosquitto.conf

Download

Move mosquitto-auth/linux-64/mosquitto_auth.so to /etc/mosquitto/mosquitto_auth.so

sudo chown mosquitto:mosquitto /etc/mosquitto/mosquitto_auth.so
sudo chmod 755 /etc/mosquitto/mosquitto_auth.so

Then edit mosquitto.conf file from /etc/mosquitto/

Add the following code in /etc/mosquitto/mosquitto.conf file.

The mosquitto.conf file

plugin /etc/mosquitto/mosquitto-auth.so
listener 1883

How to edit the environment (.env) file location?

Edit systemd Linux services environment .env file location. Enter the following code in the terminal.

sudo systemctl edit mosquitto

[Service]
EnvironmentFile=/etc/mosquitto/.env

Configure the MySQL Database

Download mosquitto.sql file and import it to your mysql by phpmyadmin. Then add database credentials in /etc/mosquitto/.env file.

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mosquitto
DB_USERNAME=root
DB_PASSWORD="Pass"

Feel free to PM: https://ciphercoin.com/contact. I can help you to configure.

Documentation

Authentication is working based on MYSQL users table. This plugin is checking username and password. Add username and password in the users table.

ACL: Add access details acls table.

column Value Permission
rw 1 READ
rw 2 WRITE
rw 4 SUBSCRIBE
rw 8 UNSUBSCRIBE

How To Test?

Download mosquitto.sql then import it by phpmyadmin.

Step 1: service mosquitto restart

Step 2: Open the new terminal then enter mosquitto_sub -t "test/su" -u arshid -P Pass@123

Step 3: Open the new terminal then enter mosquitto_pub -t "test/su" -m "This is a message !" -u arshid -P Pass@123

Commit count: 35

cargo fmt