From 90b6c509c07011416b65a539e38a87ace6ce850a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 17 Jun 2026 09:46:17 +0400 Subject: [PATCH] =?UTF-8?q?v0.5.147:=20/v2/impersonation-check=20=E2=80=94?= =?UTF-8?q?=20=D1=81=D1=80=D0=B0=D0=B2=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20aut?= =?UTF-8?q?h-api=20vs=20lk-api-gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2/server.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/v2/server.js b/v2/server.js index c590ac3..4f4b880 100644 --- a/v2/server.js +++ b/v2/server.js @@ -90,29 +90,38 @@ function createV2Router() { } }); - // ── GET /v2/impersonation-check — IAM impersonation: 3 GET эндпоинта ── + // ── GET /v2/impersonation-check — сравнение auth-api vs lk-api-gateway ── router.get('/impersonation-check', async (req, res) => { const token = req.session && req.session.token; if (!token) return res.send('

Нет токена

Войти

'); - const endpoints = [ - { name: 'status', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/status' }, - { name: 'history', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/history' }, - { name: 'history/all', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/history/all' }, + const tests = [ + { + name: 'auth-api /auth/user', + url: 'https://auth-api.ngcloud.ru/api/v1/auth/user', + }, + { + name: 'lk-api-gateway /iam/auth/user', + url: 'https://lk-api-gateway.ngcloud.ru/api/v1/iam/auth/user', + }, + { + name: 'auth-api /impersonation/status', + url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/status', + }, ]; const results = {}; - for (const ep of endpoints) { + for (const t of tests) { try { - const data = await iamFetch(token, ep.url); - results[ep.name] = { ok: true, data }; + const data = await iamFetch(token, t.url); + results[t.name] = { ok: true, data }; } catch (e) { - results[ep.name] = { ok: false, error: e.message }; + results[t.name] = { ok: false, error: e.message }; } } res.set('Content-Type', 'text/html; charset=utf-8'); - res.send(iamStatPage(results)); + res.send(iamComparePage(results)); }); // ── /v2/app — пользовательский CRUD (только с сессией) ────────────── @@ -187,7 +196,7 @@ function debugPage(u, version) { `; } -function iamStatPage(results) { +function iamComparePage(results) { function fmt(data, depth) { if (data === null || data === undefined) return 'null'; if (typeof data === 'string') return '"' + data.replace(/';