From 74efaa3c2de03830a1c903b6f1dde55227ac0bd0 Mon Sep 17 00:00:00 2001 From: Kevin Godell Date: Mon, 19 Feb 2024 16:42:14 -0600 Subject: [PATCH] let settings.httpNodeAuth accept single middleware or array of middlewares to replace built-in basic-auth middleware at top level of RED.httpNode --- packages/node_modules/node-red/red.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 63c0188bd..022f08304 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -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); }