mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
feat!: the token on every route, Secure Config Only goes (step 4b)
Under Secured every HTTP route but the public ones needs the token (docs/adr/0006-two-security-modes-eleven-http-routes.md): - isPublicRoute, isWebAsset and originMatchesHost in src/HttpAccess.h, with native tests. - One middleware checks the token. It runs once the body is in, so /restore, /updateFirmware and /updateApplication check it on their first chunk and drop a refused upload. - Static serving answers the web UI's files only: shades.cfg and shades.tmp are no longer served. - The wildcard CORS headers go; WEB_CORS turns them back on for UI work from file://. - The socket refuses a handshake whose Origin doesn't name its Host. - "Secure Config Only" goes: a device set to it is Secured, and /loginContext drops permissions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
13ec38823b
commit
ecb0260f61
16 changed files with 392 additions and 54 deletions
|
|
@ -408,7 +408,6 @@ bool SecuritySettings::fromJSON(JsonObject &obj) {
|
|||
this->parseValueString(obj, "username", this->username, sizeof(this->username));
|
||||
applySecret(obj["password"].as<const char *>(), this->password, sizeof(this->password));
|
||||
applySecret(obj["pin"].as<const char *>(), this->pin, sizeof(this->pin));
|
||||
if(!obj["permissions"].isNull()) this->permissions = obj["permissions"];
|
||||
return true;
|
||||
}
|
||||
bool SecuritySettings::save() {
|
||||
|
|
@ -419,10 +418,11 @@ bool SecuritySettings::save() {
|
|||
pref.putString("username", this->username);
|
||||
pref.putString("password", this->password);
|
||||
pref.putString("pin", this->pin);
|
||||
pref.putChar("permissions", this->permissions);
|
||||
pref.end();
|
||||
return true;
|
||||
}
|
||||
// A device that had "Secure Config Only" keeps its PIN or password and so is
|
||||
// Secured. Its old permissions key goes with the next save's clear().
|
||||
bool SecuritySettings::load() {
|
||||
Preferences pref;
|
||||
pref.begin("SEC");
|
||||
|
|
@ -430,13 +430,12 @@ bool SecuritySettings::load() {
|
|||
if(pref.isKey("username")) pref.getString("username", this->username, sizeof(this->username));
|
||||
if(pref.isKey("password")) pref.getString("password", this->password, sizeof(this->password));
|
||||
if(pref.isKey("pin")) pref.getString("pin", this->pin, sizeof(this->pin));
|
||||
if(pref.isKey("permissions")) this->permissions = pref.getChar("permissions", this->permissions);
|
||||
pref.end();
|
||||
return true;
|
||||
}
|
||||
void SecuritySettings::print() {
|
||||
ESP_LOGD(TAG, "SECURITY Type:%u Username:[%s] Password:[%s] Pin:[%s] Permissions:%u",
|
||||
static_cast<uint8_t>(this->type), this->username, maskSecret(this->password), maskSecret(this->pin), this->permissions);
|
||||
ESP_LOGD(TAG, "SECURITY Type:%u Username:[%s] Password:[%s] Pin:[%s]",
|
||||
static_cast<uint8_t>(this->type), this->username, maskSecret(this->password), maskSecret(this->pin));
|
||||
}
|
||||
|
||||
WifiSettings::WifiSettings() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue