3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 17:45:03 +00:00

Fix overzealous auth requirement in API

This commit is contained in:
Dragory 2019-07-22 00:49:05 +03:00
parent 153674da7d
commit e37987946f
2 changed files with 6 additions and 15 deletions

View file

@ -134,13 +134,13 @@ export function initAuth(app: express.Express) {
res.json({ valid: true });
});
app.post("/auth/logout", ...getRequireAPITokenHandlers(), async (req: Request, res: Response) => {
app.post("/auth/logout", ...apiTokenAuthHandlers(), async (req: Request, res: Response) => {
await apiLogins.expireApiKey(req.user.apiKey);
return ok(res);
});
}
function getRequireAPITokenHandlers() {
export function apiTokenAuthHandlers() {
return [
passport.authenticate("api-token", { failWithError: true }),
(err, req, res, next) => {
@ -148,7 +148,3 @@ function getRequireAPITokenHandlers() {
},
];
}
export function requireAPIToken(router: express.Router) {
router.use(...getRequireAPITokenHandlers());
}