3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Refresh dashboard authentication on every API call and every 15 minutes

This commit is contained in:
Dragory 2021-05-22 21:15:13 +03:00
parent 553fb57c46
commit f3a90faaa7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
4 changed files with 63 additions and 5 deletions

View file

@ -86,6 +86,7 @@ export function initAuth(app: express.Express) {
const userId = await apiLogins.getUserIdByApiKey(apiKey);
if (userId) {
void apiLogins.refreshApiKeyExpiryTime(apiKey); // Refresh expiry time in the background
return cb(null, { apiKey, userId });
}
@ -154,6 +155,12 @@ export function initAuth(app: express.Express) {
await apiLogins.expireApiKey(req.user!.apiKey);
return ok(res);
});
// API route to refresh the given API token's expiry time
// The actual refreshing happens in the api-token passport strategy above, so we just return 200 OK here
app.post("/auth/refresh", ...apiTokenAuthHandlers(), (req, res) => {
return ok(res);
});
}
export function apiTokenAuthHandlers() {