Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable adding of mosquitto users #495

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/source/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,38 @@ Pub/Sub configuration provides connectivity information for the Pub/Sub broker.
of expected observations per day. See :ref:`getting-started` for more information on system requirements.


Note that the ``WIS2BOX_BROKER_PUBLIC`` URL can be used to publish WIS2 notifications to an external broker. By default, the internal broker is used.

Apart from the wis2box internal user defined by the ``WIS2BOX_BROKER_USERNAME`` and ``WIS2BOX_BROKER_PASSWORD`` environment variables, the wis2box broker will also include the user ``everyone`` with password ``everyone``.

The ``everyone`` user has **read-only** access to the ``origin/#`` topic and can be used to allow the WIS2 Global Broker to subscribe to the wis2box.

To add additional users to the wis2box broker, login to the mosquitto container with the following command:

.. code-block:: bash

docker exec -it mosquitto /bin/sh

Then, to add a new user, use the following command:

.. code-block:: bash

mosquitto_passwd -b /mosquitto/config/password.txt <username> <password>

To add or change access rights for mosquitto users, you can edit the file ``/mosquitto/config/acl.conf`` from inside the mosquitto container using the ``vi`` command:

.. code-block:: bash

vi /mosquitto/config/acl.conf

See the mosquitto documentation for more information on the ACL configuration file.

Restart the mosquitto container for the changes to take effect with the command:

.. code-block:: bash

docker restart mosquitto

Web application
^^^^^^^^^^^^^^^

Expand Down
11 changes: 8 additions & 3 deletions wis2box-broker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ if [ -f /tmp/wis2box.crt ]; then
cp /tmp/wis2box.crt /mosquitto/certs
cp /tmp/wis2box.key /mosquitto/certs
chown -R mosquitto:mosquitto /mosquitto/certs
cp /mosquitto/config/mosquitto-ssl.conf /mosquitto/config/mosquitto.conf
cp -f /mosquitto/config/mosquitto-ssl.conf /mosquitto/config/mosquitto.conf
else
echo "SSL disabled"
fi

echo "Setting mosquitto authentication"
mosquitto_passwd -b -c /mosquitto/config/password.txt $WIS2BOX_BROKER_USERNAME $WIS2BOX_BROKER_PASSWORD
mosquitto_passwd -b /mosquitto/config/password.txt everyone everyone
if [ ! -e "/mosquitto/config/password.txt" ]; then
echo "Adding wis2box users to mosquitto password file"
mosquitto_passwd -b -c /mosquitto/config/password.txt $WIS2BOX_BROKER_USERNAME $WIS2BOX_BROKER_PASSWORD
mosquitto_passwd -b /mosquitto/config/password.txt everyone everyone
else
echo "Mosquitto password file already exists. Skipping wis2box user addition."
fi

sed -i "s#_WIS2BOX_BROKER_QUEUE_MAX#$WIS2BOX_BROKER_QUEUE_MAX#" /mosquitto/config/mosquitto.conf
sed -i "s#_WIS2BOX_BROKER_USERNAME#$WIS2BOX_BROKER_USERNAME#" /mosquitto/config/acl.conf
Expand Down
Loading