-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enabled authentication for MQTT
fixes #13
- Loading branch information
1 parent
6a2c570
commit 58a5112
Showing
11 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
FROM arm64v8/eclipse-mosquitto:2.0.10 | ||
FROM arm64v8/eclipse-mosquitto:2.0.14 | ||
|
||
COPY mosquitto.conf /mosquitto/config/mosquitto.conf | ||
COPY mosquitto.conf /mosquitto/config/mosquitto.conf | ||
COPY docker-entrypoint.sh . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Mosquitto | ||
|
||
This container configures [Eclipse Mosquitto](https://github.com/eclipse/mosquitto) as a MQTT message broker sensors can send their data to. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/ash | ||
set -e | ||
|
||
# Configure auth | ||
if [[ -z "${MQTT_USER}" || -z "${MQTT_PASSWORD}" ]]; then | ||
echo "Using un-authenticated configuration" | ||
else | ||
echo "Configruing username/password authentication" | ||
sed -i -e 's/^#password_file$/password_file \/mosquitto\/config\/passwd/g' -e 's/^allow_anonymous true$/allow_anonymous false/' /mosquitto/config/mosquitto.conf | ||
mosquitto_passwd -c -b /mosquitto/config/passwd "${MQTT_USER}" "${MQTT_PASSWORD}" | ||
fi | ||
|
||
# Set permissions | ||
user="$(id -u)" | ||
if [ "$user" = '0' ]; then | ||
[ -d "/mosquitto" ] && chown -R mosquitto:mosquitto /mosquitto || true | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
FROM arm64v8/telegraf:1.15.4 | ||
FROM telegraf:1.19 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y vim netcat \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY telegraf.conf /etc/telegraf/telegraf.conf | ||
COPY entrypoint.sh /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Configure auth | ||
if [[ -z "${MQTT_USER}" || -z "${MQTT_PASSWORD}" ]]; then | ||
echo "Using un-authenticated configuration" | ||
else | ||
echo "Configuring username/password authentication" | ||
sed -i -e 's/^ # username =.*/ username = \"'"${MQTT_USER}"'\"/g' -e 's/^ # password =.*/ password = \"'"${MQTT_PASSWORD}"'\"/g' /etc/telegraf/telegraf.conf | ||
fi | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ $EUID -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec setpriv --reuid telegraf --init-groups "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters