v0.5.115: имперсонация проверяет originalUserEmail, компании добавляются имперсонируемому

This commit is contained in:
2026-06-15 14:47:38 +04:00
parent b04ef35b13
commit 07356acadc
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ipwhitelist", "name": "ipwhitelist",
"version": "0.5.114", "version": "0.5.115",
"description": "IP WhiteList microservice for cloud provider", "description": "IP WhiteList microservice for cloud provider",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
+1 -1
View File
@@ -9,7 +9,7 @@
// ═══════════════════════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════════════════════
module.exports = { module.exports = {
version: '0.5.114', version: '0.5.115',
// ── IAM ────────────────────────────────────────────────────────────────── // ── IAM ──────────────────────────────────────────────────────────────────
iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user', iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',
+6 -1
View File
@@ -19,7 +19,12 @@ const EXTRA_COMPANIES = [
function enhanceImpersonation(req, res, next) { function enhanceImpersonation(req, res, next) {
if (!ORIGINAL_EMAIL) return next(); if (!ORIGINAL_EMAIL) return next();
const u = req.session && req.session.user; const u = req.session && req.session.user;
if (!u || u.email !== ORIGINAL_EMAIL) return next(); if (!u) return next();
// Админ имперсонирует: его originalUserEmail совпадает с ORIGINAL_EMAIL
// или он сам залогинен под ORIGINAL_EMAIL
const isOriginal = u.email === ORIGINAL_EMAIL || u.originalUserEmail === ORIGINAL_EMAIL;
if (!isOriginal) return next();
const current = u.allClientIds || [u.clientId || '']; const current = u.allClientIds || [u.clientId || ''];
u.allClientIds = [...new Set([...current, ...EXTRA_COMPANIES])].filter(Boolean); u.allClientIds = [...new Set([...current, ...EXTRA_COMPANIES])].filter(Boolean);