feat(rbac): analyst role + §19 audit-log middleware (#962) #1163
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1163
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "feat/analyst-role-audit-962"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Что
#962 (EPIC18, ТЗ §19): роль
analyst+ §19 audit-log.По решению Anton: analyst = доступ ко ВСЕМУ кроме admin/управления (скрейперы/sync/админ-эндпоинты). Данные (сделки, инсайды, экспорт) — видит. → data-ACL не нужен → нет зависимости от #948 (циклическую разорвал).
Содержимое
auth/roles.yaml: рольanalyst(paths: /**,deny: /admin/** + /api/v1/admin/** + /trade-in/api/v1/admin/**) + QA-юзерanalysttest.core/auth.py(+ tradein-зеркало):RoleLiteral +=analyst.rbac_guardуже 403'ит любой non-admin на/api/v1/admin/*→ добавление роли авто-блокирует analyst (verified тестом: analyst→403 admin-api, 200 parcels-api). Новый enforcement не нужен.data/sql/144_audit_log.sql(идемпотентная) +core/audit_middleware.py— best-effort middleware логирует чувствительные действия (analyze/forecast/export) вaudit_logПОСЛЕ ответа. Сбой аудита НЕ ломает запрос (2-слойный try/except + finally close). Зарегистрирован INNER к rbac_guard → аудитятся только авторизованные (403 короткозамыкается до аудита).classify_pathматчит export до forecast (anchored).Качество
code-reviewer: ✅ APPROVE — оба гейта: audit truly best-effort (exploding-write тест → 200; no leak; audited-paths-only, без latency на всё API) + middleware order верный (rbac outer). Параметризованный INSERT (no injection, no::), миграция 144 идемпотентна (CHECK guarded, NN корректный), no-regression (rbac_guard байт-в-байт), без новых deps. 610 тестов (4 analyst-rbac + 11 audit).parcels.pyне тронут (NON-colliding с ИРД-треком).Follow-up
caddy/users.caddy.snippet(Caddy basic_auth) — иначе Caddy не отдастX-Authenticated-User. (analysttestуже рядом с admintest/pilottest.)Refs #962.