From f3eb85c4499c549f66c26b79a6bc4252a04c8be5 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 12 Nov 2014 20:58:48 +0000 Subject: [PATCH] Move over to settings.adminAuth --- red/api/auth/index.js | 2 +- red/api/auth/users.js | 6 +++--- red/api/index.js | 1 - red/api/ui.js | 7 ------- red/comms.js | 2 +- test/red/api/auth/index_spec.js | 4 ++-- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/red/api/auth/index.js b/red/api/auth/index.js index 4fdaa02cd..81c8f328d 100644 --- a/red/api/auth/index.js +++ b/red/api/auth/index.js @@ -30,7 +30,7 @@ var server = oauth2orize.createServer(); server.exchange(oauth2orize.exchange.password(strategies.passwordTokenExchange)); function authenticate(req,res,next) { - if (settings.httpAdminAuth) { + if (settings.adminAuth) { if (/^\/auth\/.*/.test(req.originalUrl)) { next(); } else { diff --git a/red/api/auth/users.js b/red/api/auth/users.js index 9416036be..5eb688b66 100644 --- a/red/api/auth/users.js +++ b/red/api/auth/users.js @@ -22,9 +22,9 @@ var settings = require("../../settings"); //{username:"nick",password:crypto.createHash('md5').update("foo",'utf8').digest('hex')} var users = []; -if (settings.httpAdminAuth) { - if (settings.httpAdminAuth.user && settings.httpAdminAuth.pass) { - users.push({username:settings.httpAdminAuth.user, password:settings.httpAdminAuth.pass}); +if (settings.adminAuth) { + if (settings.adminAuth.user && settings.adminAuth.pass) { + users.push({username:settings.adminAuth.user, password:settings.adminAuth.pass}); } } diff --git a/red/api/index.js b/red/api/index.js index 9e3ccd517..bfa09915c 100644 --- a/red/api/index.js +++ b/red/api/index.js @@ -60,7 +60,6 @@ function init(adminApp) { ); adminApp.get("/auth/login",auth.login); adminApp.post("/auth/revoke",auth.revoke); - // Flows adminApp.get("/flows",flows.get); diff --git a/red/api/ui.js b/red/api/ui.js index fa35eac4f..fce8f25f2 100644 --- a/red/api/ui.js +++ b/red/api/ui.js @@ -55,12 +55,5 @@ module.exports = { res.sendfile(defaultIcon); } }, - settings: function(req,res) { - var safeSettings = { - httpNodeRoot: settings.httpNodeRoot, - version: settings.version - }; - res.json(safeSettings); - }, editor: express.static(__dirname + '/../../public') }; diff --git a/red/comms.js b/red/comms.js index f02263d0f..25a34d2df 100644 --- a/red/comms.js +++ b/red/comms.js @@ -46,7 +46,7 @@ function start() { wsServer = new ws.Server({server:server,path:path}); wsServer.on('connection',function(ws) { - var pendingAuth = (settings.httpAdminAuth != null); + var pendingAuth = (settings.adminAuth != null); if (!pendingAuth) { activeConnections.push(ws); } else { diff --git a/test/red/api/auth/index_spec.js b/test/red/api/auth/index_spec.js index 401941465..553f9d60d 100644 --- a/test/red/api/auth/index_spec.js +++ b/test/red/api/auth/index_spec.js @@ -35,7 +35,7 @@ describe("api auth middleware",function() { done(new Error("authentication not applied to auth path")); } }); - settings.init({httpAdminAuth:{}}); + settings.init({adminAuth:{}}); var req = { originalUrl: "/auth/token" }; @@ -52,7 +52,7 @@ describe("api auth middleware",function() { done(); } }); - settings.init({httpAdminAuth:{}}); + settings.init({adminAuth:{}}); var req = { originalUrl: "/" };