Qrome - added option to turn off web interface authentication
parent
c605410058
commit
417e5f2964
|
|
@ -70,6 +70,7 @@ boolean IS_METRIC = false; // false = Imperial and true = Metric
|
||||||
|
|
||||||
const int WEBSERVER_PORT = 80; // The port you can access this device on over HTTP
|
const int WEBSERVER_PORT = 80; // The port you can access this device on over HTTP
|
||||||
const boolean WEBSERVER_ENABLED = true; // Device will provide a web interface via http://[ip]:[port]/
|
const boolean WEBSERVER_ENABLED = true; // Device will provide a web interface via http://[ip]:[port]/
|
||||||
|
boolean IS_BASIC_AUTH = true; // true = require athentication to change configuration settings / false = no auth
|
||||||
char* www_username = "admin"; // User account for the Web Interface
|
char* www_username = "admin"; // User account for the Web Interface
|
||||||
char* www_password = "password"; // Password for the Web Interface
|
char* www_password = "password"; // Password for the Web Interface
|
||||||
float UtcOffset = -7; // Hour offset from GMT for your timezone
|
float UtcOffset = -7; // Hour offset from GMT for your timezone
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ SOFTWARE.
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#define VERSION "2.1"
|
#define VERSION "2.2"
|
||||||
|
|
||||||
#define HOSTNAME "OctMon-"
|
#define HOSTNAME "OctMon-"
|
||||||
#define CONFIG "/conf.txt"
|
#define CONFIG "/conf.txt"
|
||||||
|
|
@ -115,6 +115,7 @@ String CHANGE_FORM = "<form class='w3-container' action='/updateconfig' method=
|
||||||
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>"
|
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>"
|
||||||
"<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
"<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
||||||
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
||||||
|
"<input name='isBasicAuth' class='w3-check w3-margin-top' type='checkbox' %IS_BASICAUTH_CHECKED%> Use Security Credentials for Configuration Changes"
|
||||||
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
||||||
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
||||||
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
||||||
|
|
@ -373,8 +374,15 @@ void getUpdateTime() {
|
||||||
digitalWrite(externalLight, HIGH); // turn off the LED
|
digitalWrite(externalLight, HIGH); // turn off the LED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean authentication() {
|
||||||
|
if (IS_BASIC_AUTH && (strlen(www_username) >= 1 && strlen(www_password) >= 1)) {
|
||||||
|
return server.authenticate(www_username, www_password);
|
||||||
|
}
|
||||||
|
return true; // Authentication not required
|
||||||
|
}
|
||||||
|
|
||||||
void handleSystemReset() {
|
void handleSystemReset() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
Serial.println("Reset System Configuration");
|
Serial.println("Reset System Configuration");
|
||||||
|
|
@ -385,7 +393,7 @@ void handleSystemReset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUpdateWeather() {
|
void handleUpdateWeather() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
DISPLAYWEATHER = server.hasArg("isWeatherEnabled");
|
DISPLAYWEATHER = server.hasArg("isWeatherEnabled");
|
||||||
|
|
@ -400,7 +408,7 @@ void handleUpdateWeather() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleUpdateConfig() {
|
void handleUpdateConfig() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
OctoPrintApiKey = server.arg("octoPrintApiKey");
|
OctoPrintApiKey = server.arg("octoPrintApiKey");
|
||||||
|
|
@ -414,6 +422,7 @@ void handleUpdateConfig() {
|
||||||
minutesBetweenDataRefresh = server.arg("refresh").toInt();
|
minutesBetweenDataRefresh = server.arg("refresh").toInt();
|
||||||
themeColor = server.arg("theme");
|
themeColor = server.arg("theme");
|
||||||
UtcOffset = server.arg("utcoffset").toFloat();
|
UtcOffset = server.arg("utcoffset").toFloat();
|
||||||
|
IS_BASIC_AUTH = server.hasArg("isBasicAuth");
|
||||||
String temp = server.arg("userid");
|
String temp = server.arg("userid");
|
||||||
temp.toCharArray(www_username, sizeof(temp));
|
temp.toCharArray(www_username, sizeof(temp));
|
||||||
temp = server.arg("stationpassword");
|
temp = server.arg("stationpassword");
|
||||||
|
|
@ -427,7 +436,7 @@ void handleUpdateConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleWifiReset() {
|
void handleWifiReset() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
//WiFiManager
|
//WiFiManager
|
||||||
|
|
@ -439,7 +448,7 @@ void handleWifiReset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleWeatherConfigure() {
|
void handleWeatherConfigure() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
digitalWrite(externalLight, LOW);
|
digitalWrite(externalLight, LOW);
|
||||||
|
|
@ -479,7 +488,7 @@ void handleWeatherConfigure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleConfigure() {
|
void handleConfigure() {
|
||||||
if (!server.authenticate(www_username, www_password)) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
digitalWrite(externalLight, LOW);
|
digitalWrite(externalLight, LOW);
|
||||||
|
|
@ -519,6 +528,11 @@ void handleConfigure() {
|
||||||
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
||||||
form.replace("%THEME_OPTIONS%", themeOptions);
|
form.replace("%THEME_OPTIONS%", themeOptions);
|
||||||
form.replace("%UTCOFFSET%", String(UtcOffset));
|
form.replace("%UTCOFFSET%", String(UtcOffset));
|
||||||
|
String isUseSecurityChecked = "";
|
||||||
|
if (IS_BASIC_AUTH) {
|
||||||
|
isUseSecurityChecked = "checked='checked'";
|
||||||
|
}
|
||||||
|
form.replace("%IS_BASICAUTH_CHECKED%", isUseSecurityChecked);
|
||||||
form.replace("%USERID%", String(www_username));
|
form.replace("%USERID%", String(www_username));
|
||||||
form.replace("%STATIONPASSWORD%", String(www_password));
|
form.replace("%STATIONPASSWORD%", String(www_password));
|
||||||
|
|
||||||
|
|
@ -933,6 +947,7 @@ void writeSettings() {
|
||||||
f.println("octoPass=" + OctoAuthPass);
|
f.println("octoPass=" + OctoAuthPass);
|
||||||
f.println("refreshRate=" + String(minutesBetweenDataRefresh));
|
f.println("refreshRate=" + String(minutesBetweenDataRefresh));
|
||||||
f.println("themeColor=" + themeColor);
|
f.println("themeColor=" + themeColor);
|
||||||
|
f.println("IS_BASIC_AUTH=" + String(IS_BASIC_AUTH));
|
||||||
f.println("www_username=" + String(www_username));
|
f.println("www_username=" + String(www_username));
|
||||||
f.println("www_password=" + String(www_password));
|
f.println("www_password=" + String(www_password));
|
||||||
f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
||||||
|
|
@ -1000,6 +1015,10 @@ void readSettings() {
|
||||||
themeColor.trim();
|
themeColor.trim();
|
||||||
Serial.println("themeColor=" + themeColor);
|
Serial.println("themeColor=" + themeColor);
|
||||||
}
|
}
|
||||||
|
if (line.indexOf("IS_BASIC_AUTH=") >= 0) {
|
||||||
|
IS_BASIC_AUTH = line.substring(line.lastIndexOf("IS_BASIC_AUTH=") + 14).toInt();
|
||||||
|
Serial.println("IS_BASIC_AUTH=" + String(IS_BASIC_AUTH));
|
||||||
|
}
|
||||||
if (line.indexOf("www_username=") >= 0) {
|
if (line.indexOf("www_username=") >= 0) {
|
||||||
String temp = line.substring(line.lastIndexOf("www_username=") + 13);
|
String temp = line.substring(line.lastIndexOf("www_username=") + 13);
|
||||||
temp.trim();
|
temp.trim();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue