From c7ab02cc597717f609aa49a6b8cc100eace384b1 Mon Sep 17 00:00:00 2001 From: gitomarcourt Date: Fri, 3 Jul 2026 17:38:45 +0200 Subject: [PATCH] feat: auto-disable message authentication at startup SNEK resets to authentication=enabled on every restart and does not persist the state anywhere. The entrypoint now waits for the SNEK API to be ready and POSTs to /ned/saturation to disable auth automatically. - Registered devices without HMAC public keys (e.g. demo Sens'it) are decoded immediately on first boot and after any pod restart - To re-enable auth in production, comment the polling block in entrypoint.sh README updated with details in the "Configuration des devices" section. Co-Authored-By: Claude Opus 4.7 --- README.md | 10 ++++++++++ build/entrypoint.sh | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index 8d2cbc7..b03635a 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,16 @@ Dans SNEK → onglet **Configuration** → Devices → ajoute jusqu'à **5 devic **Important** : SNEK ne décode que les messages des devices enregistrés dont l'auth passe. Un message d'un ID non enregistré est simplement logué comme `Receiving message with bad authentication (not public key)` sans détail sur l'ID ni le payload. +### Authentication auto-disabled au démarrage + +Par défaut SNEK exige que chaque message soit **signé HMAC** avec la clé publique du device (Network Access Key). Les Sens'it de démo n'ont pas leur clé disponible → messages rejetés en `bad authentication`. + +L'entrypoint du container **désactive automatiquement** l'auth via un POST sur `/ned/saturation` juste après le démarrage de SNEK. Ainsi tes devices enregistrés fonctionnent immédiatement au premier boot, et à chaque restart du pod (SNEK ne persiste PAS l'état auth ailleurs). + +Si tu veux la garder activée (ex: prod avec devices dont tu as les clés publiques), commente le bloc `for i in $(seq 1 30)` dans `build/entrypoint.sh` et rebuild l'image. + +⚠️ Voir la section [Sécurité, vie privée & aspects légaux](#sécurité-vie-privée--aspects-légaux) pour les implications. + --- ## Réception de messages (uplink) diff --git a/build/entrypoint.sh b/build/entrypoint.sh index 55a1301..2ee1048 100644 --- a/build/entrypoint.sh +++ b/build/entrypoint.sh @@ -16,5 +16,23 @@ cd /opt/snek ./foxctl || echo "foxctl RC=$? (may be normal if firmware already loaded)" sleep 2 +# Auto-disable message authentication after SNEK is up +# SNEK resets to auth=enabled on every restart; we disable it so registered +# devices without a public key can still be decoded +( + for i in $(seq 1 30); do + if curl -sf http://localhost:8085/ned/saturation > /dev/null 2>&1; then + echo "==> SNEK API ready, disabling message authentication..." + curl -sX POST -H "Content-Type: application/json" \ + -d '{"saturation":false,"authentication":false,"dongleDisconnected":false}' \ + http://localhost:8085/ned/saturation > /dev/null + echo "==> Message authentication disabled" + exit 0 + fi + sleep 2 + done + echo "!!! Warning: SNEK API not reachable after 60s, auth not toggled" +) & + echo "==> Starting SNEK main_sigfox on port 8085..." exec ./main_sigfox