From c70590fb02025cf0ada6a543820f617268340171 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 7 Feb 2024 15:35:05 -0600 Subject: [PATCH] [SYS] Avoid AP generation if no WiFi and config already entered (#1888) For security reason do not generate an Access Point if the configuration has been entered and if the WiFi is not detected at start --- main/main.ino | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main/main.ino b/main/main.ino index fc7223e..5dadaf7 100644 --- a/main/main.ino +++ b/main/main.ino @@ -1835,6 +1835,16 @@ void setup_wifimanager(bool reset_settings) { //set minimum quality of signal so it ignores AP's under that quality wifiManager.setMinimumSignalQuality(MinimumWifiSignalQuality); + if (SPIFFS.begin()) { + Log.trace(F("mounted file system" CR)); + // Check if the config file exists and prevent the portal from showing if yes + // Showing the portal if the config file exist would enable access to the configuration data and to the ESP update page + // This is a security risk if an attacker has access to the gateway password + if (SPIFFS.exists("/config.json")) { + wifiManager.setEnableConfigPortal(false); + } + } + # ifdef ESP32_ETHERNET wifiManager.setBreakAfterConfig(true); // If ethernet is used, we don't want to block the connection by keeping the portal up # endif