78 lines
2.0 KiB
Plaintext
78 lines
2.0 KiB
Plaintext
= Mosquitto Autorisierung
|
|
|
|
|
|
Konfigurieren Sie Mosquitto, aktivieren Sie die Nutzung der ACL Datei.
|
|
|
|
|
|
listener 1883
|
|
|
|
allow_anonymous true
|
|
password_file /mosquitto/config/users.txt
|
|
acl_file /mosquitto/config/acl.txt
|
|
|
|
|
|
Nicht authentifizierte Clients dürfen `freeforall` und alles unterhalb nutzen.
|
|
|
|
|
|
topic readwrite freeforall
|
|
|
|
|
|
|
|
Authentifizierte User dürfen unterhalb von `users/` ihren Usernamen und alles darunter nutzen.
|
|
|
|
|
|
pattern readwrite users/%u/#
|
|
|
|
|
|
|
|
Das Topic `announcements` darf jeder lesen, der User `thomas` auch schreiben
|
|
|
|
topic read announcements
|
|
user thomas
|
|
topic readwrite announcements
|
|
|
|
|
|
|
|
Testen Sie das Verhalten mit verschiedenen Varianten zu publizieren, variieren Sie auch QoS und MQTT Version.
|
|
|
|
|
|
$ docker run --rm -it --init --net host -v $PWD/config:/mosquitto/config eclipse-mosquitto
|
|
|
|
$ docker run --rm -it --init --net host eclipse-mosquitto \
|
|
mosquitto_sub -V 5 --topic "freeforall" \
|
|
--debug
|
|
|
|
$ docker run --rm -it --init --net host eclipse-mosquitto \
|
|
mosquitto_sub -V 5 --topic "announcements" \
|
|
--debug
|
|
|
|
$ docker run --rm -it --init --net host eclipse-mosquitto \
|
|
mosquitto_sub -V 5 --topic "users/thomas/inbox" \
|
|
--username thomas -P geheim --debug
|
|
|
|
|
|
$ docker run --rm -it --init --net host eclipse-mosquitto \
|
|
mosquitto_pub -V 5 --qos 1 --topic "freeforall" --message "hello all" --debug
|
|
|
|
|
|
$ docker run --rm -it --net host eclipse-mosquitto \
|
|
mosquitto_pub -V 5 --topic announcements --message "not allowed" \
|
|
--debug
|
|
|
|
$ docker run --rm -it --net host eclipse-mosquitto \
|
|
mosquitto_pub --qos 1 --topic announcements --message "not allowed" \
|
|
--debug
|
|
|
|
$ docker run --rm -it --net host eclipse-mosquitto \
|
|
mosquitto_pub -V 5 --qos 1 --topic announcements --message "not allowed" \
|
|
--debug
|
|
|
|
|
|
$ docker run --rm -it --net host eclipse-mosquitto \
|
|
mosquitto_pub -V 5 --qos 1 --topic users/thomas/inbox --message "email for you" \
|
|
--username thomas -P geheim --debug
|
|
|
|
$ docker run --rm -it --net host eclipse-mosquitto \
|
|
mosquitto_pub -V 5 --qos 1 --topic announcements --message "system information" \
|
|
--username thomas -P geheim --debug
|