Skip to content

Commit

Permalink
Fix: force websocket clients to authenticate
Browse files Browse the repository at this point in the history
when changing the security settings (disabling read-only access or
changing the password), existing websocket connections are now closed,
forcing the respective clients to authenticate (with the new password).
otherwise, existing websocket clients keep connected even though the
security settings now expect authentication with a (changed) password.
  • Loading branch information
schlimmchen committed Sep 30, 2024
1 parent ebb225f commit d5d1a99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/WebApi_ws_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ void WebApiWsConsoleClass::reload()

if (config.Security.AllowReadonly) { return; }

_ws.enable(false);
_simpleDigestAuth.setPassword(config.Security.Password);
_ws.addMiddleware(&_simpleDigestAuth);
_ws.closeAll();
_ws.enable(true);
}

void WebApiWsConsoleClass::wsCleanupTaskCb()
Expand Down
3 changes: 3 additions & 0 deletions src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ void WebApiWsLiveClass::reload()

if (config.Security.AllowReadonly) { return; }

_ws.enable(false);
_simpleDigestAuth.setPassword(config.Security.Password);
_ws.addMiddleware(&_simpleDigestAuth);
_ws.closeAll();
_ws.enable(true);
}

void WebApiWsLiveClass::wsCleanupTaskCb()
Expand Down

0 comments on commit d5d1a99

Please sign in to comment.