1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Initialize passport when only adminAuth.tokens is set

Fixes #3341
This commit is contained in:
Nick O'Leary 2022-01-12 13:26:18 +00:00
parent f8c47f59bc
commit 7732d52583
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 4 additions and 1 deletions

View File

@ -146,7 +146,7 @@ function authenticateUserToken(req) {
} else { } else {
reject(); reject();
} }
}); }).catch(reject);
} else { } else {
reject(); reject();
} }
@ -163,6 +163,7 @@ TokensStrategy.prototype.authenticate = function(req) {
authenticateUserToken(req).then(user => { authenticateUserToken(req).then(user => {
this.success(user,{scope:user.permissions}); this.success(user,{scope:user.permissions});
}).catch(err => { }).catch(err => {
log.trace("token authentication failure: "+err.stack)
this.fail(401); this.fail(401);
}); });
} }

View File

@ -90,6 +90,8 @@ function init(settings,_server,storage,runtimeAPI) {
auth.getToken, auth.getToken,
auth.errorHandler auth.errorHandler
); );
} else if (settings.adminAuth.tokens) {
adminApp.use(passport.initialize());
} }
adminApp.post("/auth/revoke",auth.needsPermission(""),auth.revoke,apiUtil.errorHandler); adminApp.post("/auth/revoke",auth.needsPermission(""),auth.revoke,apiUtil.errorHandler);
} }