Browse Source

Keep secure credentials in a separate config file (#16773)

felixstorm 4 years ago
parent
commit
38a9706e16
No account linked to committer's email address
4 changed files with 17 additions and 5 deletions
  1. 3
    0
      .gitignore
  2. 10
    2
      Marlin/Configuration_adv.h
  3. 2
    1
      buildroot/bin/opt_set
  4. 2
    2
      buildroot/share/tests/esp32-tests

+ 3
- 0
.gitignore View File

@@ -146,6 +146,9 @@ Marlin/*/*/readme.txt
146 146
 Marlin/*/*/*/readme.txt
147 147
 Marlin/*/*/*/*/readme.txt
148 148
 
149
+# Secure Credentials
150
+Configuration_Secure.h
151
+
149 152
 #Visual Studio
150 153
 *.sln
151 154
 *.vcxproj

+ 10
- 2
Marlin/Configuration_adv.h View File

@@ -3023,11 +3023,19 @@
3023 3023
 //#define ESP3D_WIFISUPPORT   // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)
3024 3024
 
3025 3025
 #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
3026
-  #define WIFI_SSID "Wifi SSID"
3027
-  #define WIFI_PWD  "Wifi Password"
3028 3026
   //#define WEBSUPPORT          // Start a webserver (which may include auto-discovery)
3029 3027
   //#define OTASUPPORT          // Support over-the-air firmware updates
3030 3028
   //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
3029
+
3030
+  /**
3031
+   * To set a default WiFi SSID / Password, create a file called Configuration_Secure.h with
3032
+   * the following defines, customized for your network. This specific file is excluded via
3033
+   * .gitignore to prevent it from accidentally leaking to the public.
3034
+   *
3035
+   *   #define WIFI_SSID "WiFi SSID"
3036
+   *   #define WIFI_PWD  "WiFi Password"
3037
+   */
3038
+  //#include "Configuration_Secure.h" // External file with WiFi SSID / Password
3031 3039
 #endif
3032 3040
 
3033 3041
 /**

+ 2
- 1
buildroot/bin/opt_set View File

@@ -8,4 +8,5 @@ SED=$(which gsed || which sed)
8 8
 # Logic for returning nonzero based on answer here: https://stackoverflow.com/a/15966279/104648
9 9
 eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration.h" ||
10 10
 eval "${SED} -i '/\(\/\/\)*\([[:blank:]]*\)\(#define \b${1}\b\).*$/{s//\2\3 ${2}/;h};\${x;/./{x;q0};x;q9}' Marlin/Configuration_adv.h" ||
11
-(echo "ERROR: opt_set Can't find ${1}" >&2 && exit 9)
11
+eval "echo '#define ${@}' >>Marlin/Configuration_adv.h" ||
12
+(echo "ERROR: opt_set Can't set or add ${1}" >&2 && exit 9)

+ 2
- 2
buildroot/share/tests/esp32-tests View File

@@ -12,8 +12,8 @@ set -e
12 12
 restore_configs
13 13
 opt_set MOTHERBOARD BOARD_ESPRESSIF_ESP32
14 14
 opt_enable WIFISUPPORT GCODE_MACROS BAUD_RATE_GCODE
15
-opt_set WIFI_SSID "\"ssid\""
16
-opt_set WIFI_PWD "\"password\""
15
+opt_add WIFI_SSID "\"ssid\""
16
+opt_add WIFI_PWD "\"password\""
17 17
 opt_set TX_BUFFER_SIZE 64
18 18
 opt_add WEBSUPPORT
19 19
 exec_test $1 $2 "ESP32 with WIFISUPPORT and WEBSUPPORT"

Loading…
Cancel
Save