diff --git a/docs/iam-impersonation-api.md b/docs/iam-impersonation-api.md new file mode 100644 index 0000000..e374bc6 --- /dev/null +++ b/docs/iam-impersonation-api.md @@ -0,0 +1,83 @@ +# IAM Impersonation API + +> Источник: Swagger `https://auth-api-dev.ngcloud.ru/api/v1/documentation/` +> Дата: 2026-06-16 + +## Все эндпоинты имперсонации + +| Метод | Путь | Описание | +|-------|------|----------| +| `POST` | `/api/v1/impersonation/start` | Начать имперсонацию | +| `POST` | `/api/v1/impersonation/end` | Завершить имперсонацию | +| `POST` | `/api/v1/impersonation/extend` | Продлить сессию имперсонации | +| `GET` | `/api/v1/impersonation/status` | Статус текущей имперсонации | +| `GET` | `/api/v1/impersonation/history` | История своих имперсонаций | +| `GET` | `/api/v1/impersonation/history/all` | История имперсонаций всех админов | + +## Формат ImpersonationStartRequest + +```json +{ + "type": "user", + "entity_id": "UUID контакта (contactId из userInfo)", + "reason": "описание причины" +} +``` + +- `entity_id` — **UUID таргета** (кого имперсонируем), не свой +- `type` — всегда `"user"` + +## curl-команды + +### Начать имперсонацию + +```bash +curl --http2 -X POST \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -H "Accept: application/json" \ + "https://auth-api.ngcloud.ru/api/v1/impersonation/start" \ + -d '{"type":"user","entity_id":"UUID_таргета","reason":"тест"}' +``` + +### Статус + +```bash +curl --http2 \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/json" \ + "https://auth-api.ngcloud.ru/api/v1/impersonation/status" +``` + +### История + +```bash +curl --http2 \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/json" \ + "https://auth-api.ngcloud.ru/api/v1/impersonation/history" +``` + +### Продлить + +```bash +curl --http2 -X POST \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/json" \ + "https://auth-api.ngcloud.ru/api/v1/impersonation/extend" +``` + +### Завершить + +```bash +curl --http2 -X POST \ + -H "Authorization: Bearer $TOKEN" \ + -H "Accept: application/json" \ + "https://auth-api.ngcloud.ru/api/v1/impersonation/end" +``` + +## Примечания + +- Требуется роль IAM-админа или право на объект `impersonation` +- `--http2` обязателен для обхода ddos-guard +- Стенды: `auth-api.ngcloud.ru` (prod), `auth-api-test.ngcloud.ru` (test), `auth-api-dev.ngcloud.ru` (dev) diff --git a/package.json b/package.json index 471b91f..d2c7ed4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.146", + "version": "0.5.147", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/v2/server.js b/v2/server.js index 48e38af..6d25198 100644 --- a/v2/server.js +++ b/v2/server.js @@ -90,6 +90,31 @@ function createV2Router() { } }); + // ── GET /v2/impersonation-check — IAM impersonation: все GET эндпоинты ─ + router.get('/impersonation-check', async (req, res) => { + const token = req.session && req.session.token; + if (!token) return res.send('