diff --git a/conf/systemd.service b/conf/systemd.service index 7c3a7be..9d04cef 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,7 +5,7 @@ After=network.target [Service] User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/domoticz -www __PORT__ -sslwww 0 -log /var/log/__APP__/__APP__.log -loglevel normal,status +ExecStart=__FINALPATH__/domoticz -www __PORT__ -sslwww 0 -log /var/log/__APP__/__APP__.log -loglevel normal,status,error WorkingDirectory=__FINALPATH__/ PermissionsStartOnly=true ExecStartPre=setcap 'cap_net_bind_service=+ep cap_net_raw=+eip' __FINALPATH__/domoticz diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 374c29b..66a8856 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -3,3 +3,13 @@ * No user management nor LDAP integration This function is [not planned to be implemented into the app](https://github.com/domoticz/domoticz/issues/838), hence it's not planned into the package neither. * Backup cannot be restored on a different machine type (arm, x86...) as compiled sources are different + +## Security consideration + +Although you may activate a login page on the application (either from the *Setup/Settings/System/Website protection* menu or from the *Setup/More Options/Edit Users* menu), it doesn't seems to be very reliable and secure so far (version 2022.2 at the time of writing). Work is ongoing to strengthen the security ([see here](https://www.domoticz.com/wiki/Security)) in future version but is not yet released. + +### recommandation + +It seems advisable to not make the app publicly available outside of the yunohost sso (public = yes at install or setting the domoticz permission to 'visitors' in the admin panel). If for any reason you need to, I recommend the following: + - Activate the website protection/user management (with login page instead of Basic-auth) + - In *Setup/Settings/System/Local Networks (no username/password)* enter the address of the nginx proxy (should be "::1;127.0.0.1" in any standard Yunohost installation) so that the Fail2ban settings is active (see last lines of [this wiki](https://www.domoticz.com/wiki/WebServer_Proxy) diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index c705f4e..368dd82 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -3,3 +3,13 @@ * Pas de gestion d'utilisateurs ni d'intégration LDAP. L'application ne [prévoit pas de gérer les utilisateurs par LDAP](https://github.com/domoticz/domoticz/issues/838), donc le package non plus. * Un backup ne peut pas être restauré sur un type de machine différente de celle d'origine (x86, arm...) car les sources compilées doivent être différentes + +## A propos de la sécurité + +Bien que vous pouviez activer une page de connexion dans l'application (soit depuis le menu *Configuration/Paramètres/Système/Sécurité* ou depuis *Configuration/Plus d'options/Gérer les utilisateurs*), les fonctionnalités ne semblent pas très avancées et safe pour l'instant (version 2022.2 au moment d'écrire). Un travail a été entrepris pour renforcer la sécurité ([voir ici](https://www.domoticz.com/wiki/Security)) dans les versions futures mais n'a pas encore été released. + +### recommandations + +Il semble conseillé de ne pas rendre l'application publique en dehors du sso yunohost (public = oui à l'installaiton ou mettre la permission domoticz à 'Visiteurs' dans le panel d'administration Yunohost). Si pour quelques raisons que ce soit, vous deviez le faire, je vous recommande: + - d'activer la sécurité de connexion à domoticz (plutot avec la login page qu'avec la basic-auth) + - Dans *Configuration/Système/Réseaux Locaux (pas d'authentification)* d'entrer les adresses du proxy nginx (cela devrait être "::1;127.0.0.1" dans une installation Yunohost Standard) afin que Fail2ban puisse bloquer les tentatives de connexions (voir les dernières lignes de [ce wiki](https://www.domoticz.com/wiki/WebServer_Proxy) \ No newline at end of file diff --git a/manifest.json b/manifest.json index 88d9854..b9a0866 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Very light weight open sources home automation system that lets you monitor and configure miscellaneous devices", "fr": "Logiciel open sources et gratuit de domotique qui vous permet de configurer un grand nombre d'appareils" }, - "version": "2020.2~ynh5", + "version": "2020.2~ynh6", "url": "https://www.domoticz.com", "upstream": { "license": "GPL-3.0-or-later", diff --git a/scripts/backup b/scripts/backup index b54794c..ffa3451 100755 --- a/scripts/backup +++ b/scripts/backup @@ -57,6 +57,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP FAIL2BAN CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index ece1c6a..6a86c16 100755 --- a/scripts/install +++ b/scripts/install @@ -229,6 +229,21 @@ ynh_systemd_action --service_name="$app" --action="start" #Restarting mosquitto to take changes into account [[ ! -z "$mqtt_domain" ]] && ynh_systemd_action --service_name=mosquitto --action="restart" +#================================================= +# SETUP FAIL2BAN +#================================================= +ynh_script_progression --message="Configuring Fail2Ban..." --weight=8 + +# Make sure a log file exists (mostly for CI tests) +log_file=/var/log/$app/$app.log +if [ ! -f "$log_file" ]; then + touch "$log_file" + chown $app: "$log_file" +fi + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed login attempt from .*$" --max_retry=5 + #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index ba5b4b6..1d25cb4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -94,6 +94,14 @@ ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate +#================================================= +# REMOVE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=8 + +# Remove the dedicated Fail2Ban config +ynh_remove_fail2ban_config + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 9054a91..adc7480 100755 --- a/scripts/restore +++ b/scripts/restore @@ -159,6 +159,21 @@ ynh_script_progression --message="Restoring various files..." ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/95-nginx_domoticz" yunohost tools regen-conf postfix +#================================================= +# RESTORE THE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=7 + +ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" + +log_file=/var/log/$app/$app.log +if [ ! -f "$log_file" ]; then + touch "$log_file" + chown $app: "$log_file" +fi + +ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 5bc2c61..b213629 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -267,6 +267,20 @@ chown -R domoticz: /var/log/"$app" ynh_use_logrotate --logfile="/var/log/$app/$app.log" --non-append [[ ! -z "$mqtt_domain" ]] && ynh_use_logrotate --logfile="/var/log/mosquitto/" --non-append +#================================================= +# SETUP FAIL2BAN +#================================================= +ynh_script_progression --message="Configuring Fail2Ban..." --weight=8 + +# Make sure a log file exists (mostly for CI tests) +log_file=/var/log/$app/$app.log +if [ ! -f "$log_file" ]; then + touch "$log_file" + chown $app: "$log_file" +fi + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="$log_file" --failregex="^.*Error: Failed login attempt from .*$" --max_retry=5 #================================================= # INTEGRATE SERVICE IN YUNOHOST