Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3b738e9ee |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ipwhitelist",
|
"name": "ipwhitelist",
|
||||||
"version": "0.5.150",
|
"version": "0.5.147",
|
||||||
"description": "IP WhiteList microservice for cloud provider",
|
"description": "IP WhiteList microservice for cloud provider",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@
|
|||||||
// ── IAM API ───────────────────────────────────────────────────────────────────
|
// ── IAM API ───────────────────────────────────────────────────────────────────
|
||||||
// URL IAM-сервиса для получения профилей пользователя (GET /api/v1/auth/user)
|
// URL IAM-сервиса для получения профилей пользователя (GET /api/v1/auth/user)
|
||||||
// и переключения активной компании (POST /api/v1/user/switch-profile).
|
// и переключения активной компании (POST /api/v1/user/switch-profile).
|
||||||
const IAM_API_URL = (process.env.IAM_API_URL || 'https://auth-api.ngcloud.ru').replace(/\/$/, '');
|
const IAM_API_URL = (process.env.IAM_API_URL || 'https://auth-api-dev.ngcloud.ru').replace(/\/$/, '');
|
||||||
|
|
||||||
// ── Мок-пользователи (только dev/staging) ─────────────────────────────────────
|
// ── Мок-пользователи (только dev/staging) ─────────────────────────────────────
|
||||||
// В продакшене этот список не используется — вход через Keycloak.
|
// В продакшене этот список не используется — вход через Keycloak.
|
||||||
|
|||||||
+15
-43
@@ -69,7 +69,7 @@ function createV2Router() {
|
|||||||
const token = req.session && req.session.token;
|
const token = req.session && req.session.token;
|
||||||
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
||||||
try {
|
try {
|
||||||
const raw = await iamFetch(token, config.iamApiBase + '/auth/user');
|
const raw = await iamFetch(token, 'https://auth-api-test.ngcloud.ru/api/v1/auth/user');
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
res.set('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.send(rawPage('IAM TEST', raw));
|
res.send(rawPage('IAM TEST', raw));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -82,7 +82,7 @@ function createV2Router() {
|
|||||||
const token = req.session && req.session.token;
|
const token = req.session && req.session.token;
|
||||||
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
||||||
try {
|
try {
|
||||||
const raw = await iamFetch(token, config.iamApiBase + '/auth/user');
|
const raw = await iamFetch(token, 'https://auth-api-dev.ngcloud.ru/api/v1/auth/user');
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
res.set('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.send(rawPage('IAM DEV', raw));
|
res.send(rawPage('IAM DEV', raw));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -90,39 +90,29 @@ function createV2Router() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── GET /v2/iam-gateway-test — сравнение auth-api vs lk-api-gateway ──
|
// ── GET /v2/impersonation-check — IAM impersonation: 3 GET эндпоинта ──
|
||||||
router.get('/iam-gateway-test', async (req, res) => {
|
router.get('/impersonation-check', async (req, res) => {
|
||||||
const token = req.session && req.session.token;
|
const token = req.session && req.session.token;
|
||||||
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
if (!token) return res.send('<h2>Нет токена</h2><p><a href="/v2/login">Войти</a></p>');
|
||||||
|
|
||||||
const base = config.iamApiBase;
|
const endpoints = [
|
||||||
const tests = [
|
{ 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: 'auth-api /auth/user',
|
{ name: 'history/all', url: 'https://auth-api.ngcloud.ru/api/v1/impersonation/history/all' },
|
||||||
url: base + '/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: base + '/impersonation/status',
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const results = {};
|
const results = {};
|
||||||
for (const t of tests) {
|
for (const ep of endpoints) {
|
||||||
try {
|
try {
|
||||||
const data = await iamFetch(token, t.url);
|
const data = await iamFetch(token, ep.url);
|
||||||
results[t.name] = { ok: true, data };
|
results[ep.name] = { ok: true, data };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
results[t.name] = { ok: false, error: e.message };
|
results[ep.name] = { ok: false, error: e.message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
res.set('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.send(iamComparePage(results));
|
res.send(iamStatPage(results));
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── /v2/app — пользовательский CRUD (только с сессией) ──────────────
|
// ── /v2/app — пользовательский CRUD (только с сессией) ──────────────
|
||||||
@@ -146,25 +136,7 @@ function createV2Router() {
|
|||||||
router.use('/export', createExportRouter());
|
router.use('/export', createExportRouter());
|
||||||
|
|
||||||
// ── GET /v2/logout — редирект на основной выход ─────────────────────
|
// ── GET /v2/logout — редирект на основной выход ─────────────────────
|
||||||
router.get('/logout', (req, res) => {
|
router.get('/logout', (req, res) => res.redirect('/logout'));
|
||||||
const ua = (req.headers['user-agent'] || '').toLowerCase();
|
|
||||||
const isBrowser = ua.includes('mozilla') || ua.includes('chrome') || ua.includes('safari');
|
|
||||||
if (isBrowser) {
|
|
||||||
res.set('Content-Type', 'text/html; charset=utf-8');
|
|
||||||
return res.send('<!DOCTYPE html><html><head><meta charset="utf-8"><title>Выход</title>'
|
|
||||||
+ '<style>body{font-family:sans-serif;background:#111;color:#eee;padding:40px;text-align:center}'
|
|
||||||
+ 'h2{color:#4fc3f7}p{font-size:16px;margin:20px 0}'
|
|
||||||
+ '.btn{display:inline-block;padding:12px 24px;margin:0 10px;border-radius:6px;text-decoration:none;font-size:16px}'
|
|
||||||
+ '.btn-yes{background:#ef5350;color:#fff}.btn-no{background:#333;color:#eee}'
|
|
||||||
+ '</style></head><body>'
|
|
||||||
+ '<h2>Выход из приложения</h2>'
|
|
||||||
+ '<p>Выход завершит сессию во всех сервисах Nubes (Keycloak SSO).<br>Вы уверены?</p>'
|
|
||||||
+ '<a href="/logout" class="btn btn-yes">Да, выйти</a>'
|
|
||||||
+ '<a href="/v2/app" class="btn btn-no">Отмена</a>'
|
|
||||||
+ '</body></html>');
|
|
||||||
}
|
|
||||||
res.redirect('/logout');
|
|
||||||
});
|
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
}
|
}
|
||||||
@@ -215,7 +187,7 @@ function debugPage(u, version) {
|
|||||||
</body></html>`;
|
</body></html>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function iamComparePage(results) {
|
function iamStatPage(results) {
|
||||||
function fmt(data, depth) {
|
function fmt(data, depth) {
|
||||||
if (data === null || data === undefined) return '<span style="color:#888">null</span>';
|
if (data === null || data === undefined) return '<span style="color:#888">null</span>';
|
||||||
if (typeof data === 'string') return '<span style="color:#ce93d8">"' + data.replace(/</g, '<') + '"</span>';
|
if (typeof data === 'string') return '<span style="color:#ce93d8">"' + data.replace(/</g, '<') + '"</span>';
|
||||||
|
|||||||
Reference in New Issue
Block a user