with ESPAsyncWebServer 3.3.0, the setAuthentication() method became
deprecated and a replacement method was provided which acts as a shim
and uses the new middleware-based approach to setup authentication. in
order to eventually apply a changed "read-only access allowed" setting,
the setAuthentication() method was called periodically. the shim
implementation each time allocates a new AuthenticationMiddleware and
adds it to the chain of middlewares, eventually exhausting the memory.
we now use the new middleware-based approach ourselves and only add the
respective AuthenticatonMiddleware instance once to the respective
websocket server instance.
a regression where enabling unauthenticated read-only access is not
applied until reboot is also fixed. all the AuthenticationMiddleware
instances were never removed from the chain of middlewares when calling
setAuthentication("", "").
20 lines
414 B
C++
20 lines
414 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
|
|
#include <ESPAsyncWebServer.h>
|
|
#include <TaskSchedulerDeclarations.h>
|
|
|
|
class WebApiWsConsoleClass {
|
|
public:
|
|
WebApiWsConsoleClass();
|
|
void init(AsyncWebServer& server, Scheduler& scheduler);
|
|
void reload();
|
|
|
|
private:
|
|
AsyncWebSocket _ws;
|
|
AuthenticationMiddleware _simpleDigestAuth;
|
|
|
|
Task _wsCleanupTask;
|
|
void wsCleanupTaskCb();
|
|
};
|