Commit Graph
258 Commits
Author SHA1 Message Date
naeel 5c09844002 v2: модуль аутентификации Keycloak + IAM, роутер /v2
- v2/src/auth/index.js — login(), fetchIamUser(), exchangeCode(), buildAuthUrl()
- v2/src/config/index.js — приоритет V2_* → KC_* → умолчания
- v2/server.js — createV2Router(), монтируется в server.js как /v2
- server.js — app.use('/v2', createV2Router()) перед UI-роутером
- bump 0.5.57 → 0.5.58
2026-06-12 15:47:32 +04:00
naeel b2f1cae37d docs: session history 2026-06-11 with remaining tasks 2026-06-12 13:43:25 +04:00
naeel 2993f95b8d tz 2026-06-11 21:38:19 +04:00
naeel 199585be67 docs: add actual TOR (ТЗ-факт) based on implemented features 2026-06-11 21:36:40 +04:00
naeel f818f454a3 fix: deleted entries shown with strikethrough + opacity, edit/delete hidden 2026-06-11 21:26:05 +04:00
naeel bc209aeab8 release: bump 0.5.57 2026-06-11 21:15:45 +04:00
naeel a601570a4a fix: return includeDeleted checkbox + submit button for admin filter (no JS) 2026-06-11 21:07:59 +04:00
naeel 5781b37882 fix: audit table has impersonated_by column + filter uses button submit (no JS) 2026-06-11 20:47:03 +04:00
naeel ffdc12bdf8 fix: syntax error in /debug-session — missing closing brace 2026-06-11 20:39:30 +04:00
naeel 001db2a556 debug: /debug-session shows last audit log entries (impersonated_by) 2026-06-11 20:32:23 +04:00
naeel 447acba762 fix: impersonation banner shows activeClientId instead of raw JWT clientId 2026-06-11 20:27:08 +04:00
naeel 8f9e0a96ad fix: reject client_id when allowedIds list is empty (no IAM, no JWT claims) 2026-06-11 20:18:55 +04:00
naeel 68ea44a81d fix: X-Imp-* headers bridge UI→API impersonation + timezone GMT+4 2026-06-11 20:17:07 +04:00
naeel d0a0fdc264 chore: exclude sonnet analysis files from git 2026-06-11 20:03:08 +04:00
naeel 1350f0dbba security: fix OIDC state check bypass + open redirect in login-token
- oidc.js: remove || true — state check now works in all environments
- auth.js: wrap returnTo in safeReturn (was unprotected on line 166)
2026-06-11 20:02:49 +04:00
naeel 351cb6afe6 feat: test impersonation via IMPERSONATION_ORIGINAL/TARGET/COMPANY env vars
- ui/index.js: resolveUser checks env vars, only for matching email
- Закомментировать блок 'TEST IMPERSONATION' для прода
2026-06-11 19:25:11 +04:00
naeel e0cbf4bf35 fix: /export defaults to JSON, ?format=txt for plain text 2026-06-11 16:32:19 +04:00
naeel e3c4c738aa feat: /export?format=json — JSON export for admin 2026-06-11 16:29:24 +04:00
naeel 3bc285dc93 fix: /export only for adminMode users, not public 2026-06-11 16:28:15 +04:00
naeel 6025d84959 fix: add ALTER TABLE migration for impersonated_by column 2026-06-11 16:20:52 +04:00
naeel 7758d70dcf feat: double audit — impersonated_by in audit_log
- db.js: add impersonated_by column to audit_log
- queries.js: logAudit accepts impersonatedBy, all CRUD pass it
- api/routes/entries.js: pass req.user.originalUserEmail as impersonatedBy
- При имперсонации: created_by=импактируемый, impersonated_by=админ
2026-06-11 16:10:41 +04:00
naeel 9c51e449ab fix: remove canWrite from IAM — it is IAM RBAC, not our app logic
- IAM permissions.can_write defaults to false for all users
- Our app controls writes via adminMode + company membership
2026-06-11 16:01:55 +04:00
naeel 9a331eec82 feat: full IAM impersonation support — read-only + original user + canWrite
- src/auth.js: all impersonation fields + permissions.can_write
- src/routes/oidc.js: save all fields to session
- ui/index.js: canWrite, originalUserEmail in req.user
- ui/routes/entries.js: read-only guard on POST/PATCH/DELETE
- docs/PLAN-impersonation.md: updated with implemented items
2026-06-11 15:54:56 +04:00
naeel a2cfd2c10f feat: IAM impersonation support — isImpersonated flag + banner
- src/auth.js: fetchIamUser extract isImpersonated from response
- src/routes/oidc.js: save isImpersonated to session
- ui/index.js: isImpersonated in req.user
- ui/routes/entries.js: pass isImpersonated to render
- views/index.ejs: banner 'Режим имперсонации'
- docs/PLAN-impersonation.md: план дальнейших шагов (двойной аудит)
2026-06-11 15:34:19 +04:00
naeel 7b3dd8b4b3 fix: всегда показывать email залогиненного, не owner_email компании
- Убрано selectedCompany.owner_email из отображения «пользователь»
- Админ видит свой email, а не создателя компании
2026-06-11 15:16:59 +04:00
naeel ce6b67e72a fix: email from session.user first, not JWT payload
- req.session.user.email приоритетнее payload.email
- Исправляет отображение чужого email в header
2026-06-11 15:08:07 +04:00
naeel 9cb53df8b1 fix: toggle as pure HTML form — no JS, no fetch, just POST+redirect
- views/index.ejs: onclick+fetch → form method=POST с button
- ui/routes/auth.js: JSON → res.redirect(Referer)
- Текст меняется: «Администратор» ↔ «Выйти из админки»
2026-06-11 14:59:59 +04:00
naeel fa4d5646fa fix: toggle now works — JSON response + immediate CSS flip
- /toggle-admin returns JSON {ok, adminMode} instead of redirect
- onclick: toggle CSS instantly, then fetch, then reload on ok
2026-06-11 14:42:31 +04:00
naeel f739754c3b fix: pass canAdminMode to render + bump 0.5.47 2026-06-11 14:34:42 +04:00
naeel cad6ebb4d6 release: bump 0.5.46 2026-06-11 14:24:46 +04:00
naeel 8b891a4bed fix: remove duplicate catch block causing startup crash 2026-06-11 14:19:01 +04:00
naeel 08248229b9 fix: если email мой — isAdmin = true, canAdminMode = true
- isAdmin = iamAdmin || (payload.email/login === ntazetdinov@nubes.ru)
2026-06-11 14:10:52 +04:00
naeel 2fbdc3259b hardcode: canAdminMode для ntazetdinov@nubes.ru без зависимостей
- Просто хардкод email = 'ntazetdinov@nubes.ru'
- Убран лишний фетч email из сессии/payload/logging
2026-06-11 14:10:00 +04:00
naeel d54a72ca2c debug: add resolveUser logging for canAdminMode diagnosis 2026-06-11 14:04:36 +04:00
naeel 4af34616f9 fix: canAdminMode по email ntazetdinov@nubes.ru вместо isAdmin
- ui/index.js: email берётся из сессии (IAM/Keycloak)
- canAdminMode: (isAdmin AND WZ01112) OR (ntazetdinov@nubes.ru AND WZ01112)
- Временно для тестов, убрать после настройки IAM isAdmin
2026-06-11 13:41:35 +04:00
naeel 13466ebd37 simplify: toggle adminMode, canAdminMode flag, remove getOrCreateCompany fallback
- ui/index.js: canAdminMode = isAdmin AND WZ01112 (временно || WZ01112)
- views/index.ejs: checkbox → toggle с JS fetch, условие canAdminMode
- ui/routes/entries.js: убран getOrCreateCompany-фоллбек для админа
- Админ без ?company= видит список компаний, без автозагрузки
- isAdmin теперь чисто из IAM (без || WZ01112)
2026-06-11 13:15:37 +04:00
naeel 1794610f77 fix: ownCo not found → getOrCreateCompany instead of companies[0]
- Убрал fallback на companies[0] — небезопасно
- Если компания админа не найдена — создаём через getOrCreateCompany
2026-06-11 11:18:59 +04:00
naeel 2acad33fd4 fix: admin without ?company= loads own company (no redirect)
- Убрал редирект на ?company=<id> — админ видит свою компанию по умолчанию
- ownCo ищется по clientId из сессии, если не найдена — первая из списка
- Больше не пишет ?company= в URL при первом входе
2026-06-11 11:16:37 +04:00
naeel 4f1f64dd6c feat: adminMode — чек-бокс переключения админского интерфейса
Шаг 1: /toggle-admin роут в ui/routes/auth.js
  - переключает req.session.adminMode
  - canAdmin = isAdmin || clientId === WZ01112 (временно)

Шаг 2: resolveUser в ui/index.js
  - req.user.adminMode из req.session.adminMode
  - isAdmin = IAM.isAdmin || clientId === WZ01112 (временно)

Шаг 3: adminMode вместо isAdmin в интерфейсе
  - ui/routes/entries.js: adminMode решает админский view
  - ui/routes/admin.js: requireAdmin проверяет adminMode

Шаг 4: views/index.ejs
  - чек-бокс «Администратор» (виден только если isAdmin)
  - ссылки Аудит/Лимиты видны только при adminMode
  - селектор компаний — при adminMode
2026-06-11 11:08:03 +04:00
naeel 8c1787df19 bump 0.5.37 — debug /debug-session endpoint 2026-06-11 10:49:54 +04:00
naeel 02859d6a7a fix: replace regex constraint with LIKE '%/%' for PG compat
- constraint CHECK (value_cidr LIKE '%/%') instead of regex
- regex broke on managed PG with standard_conforming_strings=off
- ALTER TABLE adds constraint on existing tables
2026-06-10 11:51:08 +04:00
naeel 32cb0f4ac6 fix: block clientId login in OIDC mode (crash fix)
- ui/routes/auth.js: auth.isOidc → redirect to /login with error instead of
  calling issueMockToken which throws 'Mock keypair not initialized'
- This was crashing the process via unhandled promise rejection
2026-06-10 11:42:50 +04:00
naeel e22b7ac408 bump 0.5.34 — save idToken for logout 2026-06-09 22:37:05 +04:00
naeel 54f950b7d1 bump 0.5.33 — revert idToken, logout via KC config 2026-06-09 22:29:15 +04:00
naeel 9fc3665292 bump 0.5.32 — remove audience check from JWT verify 2026-06-09 22:17:23 +04:00
naeel 4a45546b0d bump 0.5.31 — disable state check in production for SSO test 2026-06-09 22:01:26 +04:00
naeel 9b76333b22 bump 0.5.30 — restore state check, clean code 2026-06-09 21:59:26 +04:00
naeel a39f97f3b4 bump 0.5.29 — add KC_BASE_URL to exchange error 2026-06-09 21:56:45 +04:00
naeel 6c5215513c bump 0.5.28 — disable state check for SSO test 2026-06-09 21:53:07 +04:00
naeel 61361ec7e2 bump 0.5.27 — error handler: URL, user, clientId, stack 2026-06-09 21:01:33 +04:00