v0.5.174: timeout IAM 5с, rate-limiters на login/CRUD/export

This commit is contained in:
“Naeel”
2026-06-22 19:24:58 +04:00
parent c6ca9c4389
commit eed88ecadf
4 changed files with 14 additions and 8 deletions
+4 -2
View File
@@ -36,7 +36,7 @@ async function checkImpersonation(token, req, u) {
const url = config.iamApiBase + '/auth/user';
const uObj = new URL(url);
const data = await new Promise((resolve, reject) => {
https.get({
const req = https.get({
hostname: uObj.hostname, port: 443, path: uObj.pathname,
headers: { Authorization: 'Bearer ' + token, Accept: 'application/json' },
}, res => {
@@ -46,7 +46,9 @@ async function checkImpersonation(token, req, u) {
if (res.statusCode !== 200) return reject(new Error(res.statusCode + ': ' + d.slice(0, 200)));
try { resolve(JSON.parse(d)); } catch (e) { reject(e); }
});
}).on('error', reject);
});
req.on('error', reject);
req.setTimeout(5000, () => { req.destroy(); reject(new Error('timeout')); });
});
const imp = data.impersonation || {};