@@ -9,36 +9,68 @@ Check official docs about this topic here: <https://docs.vernemq.com/configurati
To interact with database, you have to run `redis-cli` inside `vmq-redis` running container.
Use `docker exec ...` or start a shell session through Portainer to access `vmq-redis`.
### List clients
### Create clients
```sh
$ redis-cli
> KEYS *
> SET "[\"\",\"client-1\",\"user-1\"]""{\"passhash\":\"$2a$12$4WvSLjSMai7viDn0Dh3VAeYkQEkSPefybwjUO8FkmLrEr7O2MBrue\",\"subscribe_acl\":[{\"pattern\":\"test-topic\"}]}"
OK
> SET "[\"\",\"client-2\",\"user-2\"]""{\"passhash\":\"$2a$12$4WvSLjSMai7viDn0Dh3VAeYkQEkSPefybwjUO8FkmLrEr7O2MBrue\",\"publish_acl\":[{\"pattern\":\"test-topic\"}]}"
OK
```
### Create client
Here, you define a pair of new keys `"[\"\",\"client-1\",\"user-1\"]"` and `"[\"\",\"client-2\",\"user-2\"]"`. It means:
```sh
$ redis-cli
1. empty mountpoint.
1.`client-<n>` client IDs.
1.`user-<n>` usernames.
> SET "[\"\",\"test-client\",\"test-user\"]""{\"passhash\":\"$2a$12$WDzmynWSMRVzfszQkB2MsOWYQK9qGtfjVpO8iBdimTOjCK/u6CzJK\",\"subscribe_acl\":[{\"pattern\":\"a/+/c\"}]}"
This means subscribe granted to `test-topic` topic to `user-1` user (from `client-1` client) and publish granted to `test-topic` topic to `user-2` user (from `client-2` client), both using same password hash.
Here, you define a new key `"[\"\",\"test-client\",\"test-user\"]"` (empty mountpoint, `test-client` client ID, `test-user` username) with value `"{\"passhash\":\"$2a$12$WDzmynWSMRVzfszQkB2MsOWYQK9qGtfjVpO8iBdimTOjCK/u6CzJK\",\"subscribe_acl\":[{\"pattern\":\"a/+/c\"}]}"`.
This value contains a bcrypt password hash `passhash`, generated for password value `changeme`.
This value contains a bcrypt password hash `passhash` and a list of topic patterns `subscribe_acl` with granted access for this client.
Create a new password and generate a bcrypt hash (with 12 rounds) for it. You can use any tool, <https://www.browserling.com/tools/bcrypt> for example.
Decide a new password and generate a bcrypt hash (with 12 rounds) for it.
You can use any tool, <https://www.browserling.com/tools/bcrypt> for example.
### List clients
```sh
$ redis-cli
> KEYS *
1)"[\"\",\"client-1\",\"user-1\"]"
2)"[\"\",\"client-2\",\"user-2\"]"
```
### Delete client
```sh
$ redis-cli
> DEL "[\"\",\"test-client\",\"test-user\"]"
> DEL "[\"\",\"client-1\",\"user-1\"]""[\"\",\"client-2\",\"user-2\"]"
(integer) 2
```
## Usage example
You can test broker using any MQTT client, like Mosquitto (install with `sudo apt install mosquitto-clients`).