let settings.httpNodeAuth accept single middleware or array of middlewares to replace built-in basic-auth middleware at top level of RED.httpNode

pull/4572/head
Kevin Godell 2024-02-19 16:42:14 -06:00
parent 2291dc6132
commit 74efaa3c2d
1 changed files with 7 additions and 1 deletions

View File

@ -408,9 +408,15 @@ httpsPromise.then(function(startupHttps) {
if (settings.httpAdminRoot !== false) {
app.use(settings.httpAdminRoot,RED.httpAdmin);
}
if (settings.httpNodeRoot !== false && settings.httpNodeAuth) {
app.use(settings.httpNodeRoot,basicAuthMiddleware(settings.httpNodeAuth.user,settings.httpNodeAuth.pass));
if (typeof settings.httpNodeAuth === "function" || Array.isArray(settings.httpNodeAuth)) {
app.use(settings.httpNodeRoot, settings.httpNodeAuth);
} else {
app.use(settings.httpNodeRoot, basicAuthMiddleware(settings.httpNodeAuth.user, settings.httpNodeAuth.pass));
}
}
if (settings.httpNodeRoot !== false) {
app.use(settings.httpNodeRoot,RED.httpNode);
}