security
RBAC & Approval Model
Peran bersifat aditif; satu user bisa punya beberapa peran. owner org (control plane) lebih tinggi dari admin project.
On this page
- Status: Frozen
- Terkait:
05-security/SECURITY.md,03-api/INVENTORY.md,06-frontend/UX.md - Schema:
Approval,WhoAmI
1. Peran
| Peran | Fokus | Tidak boleh |
|---|---|---|
| preparer | Menyiapkan data, kontrak, keputusan | Approve, akses audit, ubah member |
| reviewer | Meninjau keputusan di /review | Mengubah kontrak, approve financial |
| approver | Menyetujui keputusan/assumption/projection | Menyiapkan data, ubah residency |
| auditor | Melihat audit, usage, planning (read-only) | Aksi apa pun yang mengubah state |
| admin | Konfigurasi project, member, kredensial, residency | Menjadi approver tunggal untuk financial (four-eyes) |
Peran bersifat aditif; satu user bisa punya beberapa peran. owner org (control plane)
lebih tinggi dari admin project.
2. Matriks endpoint × peran
Legenda: ✓ = boleh, – = tidak, R = read-only, A = butuh approval/four-eyes.
| Area | Endpoint (contoh) | preparer | reviewer | approver | auditor | admin |
|---|---|---|---|---|---|---|
| Whoami | GET /whoami | ✓ | ✓ | ✓ | ✓ | ✓ |
| Overview | GET /usage | R | R | R | ✓ | ✓ |
| Onboarding | POST /onboarding/*, PUT /onboarding/contract | ✓ | – | – | – | ✓ |
| Onboarding activate | POST /onboarding/activate | A | – | A | – | A |
| Decisions | POST /decisions, GET /decisions | ✓ | R | R | R | ✓ |
| Decision detail | GET /decisions/{id} | ✓ | ✓ | ✓ | ✓ | ✓ |
| Review queue | GET /decisions?status=needs_review | – | ✓ | ✓ | – | ✓ |
| Approval decide | POST /approvals/{id}/decide | – | A | A | – | A |
| Agents | PATCH /agents/{id} | – | – | – | – | ✓ |
| Agent mode → auto | PATCH /agents/{id} (mode) | – | – | A | – | A |
| Datasets | POST/GET /datasets, query | ✓ | – | – | R | ✓ |
| Contract | PUT /onboarding/contract | ✓ | – | A | – | ✓ |
| Syncs | `POST /syncs/{id}/pause | resume` | ✓ | – | – | – |
| Connectors | POST/DELETE /connectors | – | – | – | – | ✓ |
| Actions read | GET /actions | ✓ | ✓ | ✓ | ✓ | ✓ |
| Actions patch | PATCH /actions/{id} | – | – | – | – | ✓ |
| Action read/write_low | POST /actions/{id}/test | ✓ | – | – | – | ✓ |
| Action financial | POST /action-invocations | – | – | A | – | A |
| Reconcile | POST /.../reconcile | – | – | A | – | A |
| Credentials | POST/GET/DELETE /credentials | – | – | – | – | ✓ |
| Assumptions | GET/PUT /assumptions | ✓ | – | A | R | ✓ |
| Projections | POST /projections | ✓ | – | R | R | ✓ |
| Deviations | GET /.../deviations | ✓ | – | ✓ | R | ✓ |
| Documents render | POST /documents/render | ✓ | – | – | – | ✓ |
| Corrections | POST /documents/{id}/corrections | ✓ | – | – | – | ✓ |
| Evals | GET /evals/{id} | R | R | R | ✓ | ✓ |
| Audit | GET /audit, GET /audit/{id}/proof | – | – | – | ✓ | ✓ |
| Webhooks | POST/GET/DELETE /webhooks | – | – | – | – | ✓ |
| Members | POST /members (control plane) | – | – | – | – | ✓ |
| Residency | PUT /settings/residency | – | – | A | – | A |
| Billing | control plane | – | – | – | R | ✓ |
Aturan: UI memfilter berdasarkan GET /whoami. API tetap menegakkan; UI bukan boundary.
3. Aktor manusia vs mesin
| Aksi | Kredensial mesin | Manusia |
|---|---|---|
POST /decisions | ✓ | ✓ |
GET /decisions/{id} | ✓ | ✓ |
POST /approvals | ✓ (membuat request) | ✓ |
POST /approvals/{id}/decide | ✓ (butuh scope approvals:write) | ✓ |
PATCH /agents/{id} mode auto | – | ✓ + approval |
POST /action-invocations financial | – | ✓ + four-eyes |
PUT /settings/residency | – | ✓ + approval |
GET /audit | – | ✓ (auditor/admin) |
Kredensial mesin boleh memicu kebutuhan approval, tidak boleh memberi approval.
4. Four-eyes
Berlaku untuk:
| Subject | Aturan |
|---|---|
action-invocation (financial) | requestedBy != decidedBy, minimal 2 approver |
agent-mode → auto | requestedBy != decidedBy, reviewer + admin |
contract (material change) | requestedBy != decidedBy |
projection (perubahan laporan pack) | Direksi → Komisaris (dua peran berbeda) |
residency | admin + approver |
Implementasi:
if (approval.subjectType === 'action-invocation' && action.risk === 'financial') {
require(approval.requestedBy !== actor.id);
require(roles.includes('approver'));
require(countApprovals(approval.id, 'approver') >= 2);
}
Aturan tambahan:
- Admin tidak boleh menjadi satu-satunya approver financial.
- Delegasi tidak boleh membuat orang yang sama menjadi requester & approver.
- Approval kedaluwarsa (
expired) tidak bisa dipakai; harus dibuat ulang.
5. Approval lifecycle
pending ──► approved
│
├──► rejected
├──► expired (dueAt lewat)
└──► canceled (subject berubah)
| Field | Aturan |
|---|---|
requiredRole | Minimum role yang boleh decide |
dueAt | SLA; default 24 jam, pack dapat menaikkan |
conditions | Syarat tambahan (mis. "hanya untuk amount < X") |
note | Alasan |
decidedBy | Manusia; tidak boleh mesin |
decidedAt | Waktu keputusan |
Setiap transisi menulis audit entry.
6. Delegasi & cuti
- Delegasi eksplisit, bercatat, dengan masa berlaku.
- Delegasi tidak memindahkan four-eyes: requester tetap tidak boleh approve.
- Delegasi untuk
financialhanya keapprover, bukanadminyang sama. - Saat delegasi berakhir, approval yang belum diputuskan kembali ke antrean.
7. Visibilitas UI per peran
| Seksi | preparer | reviewer | approver | auditor | admin |
|---|---|---|---|---|---|
| Overview | ✓ | ✓ | ✓ | ✓ | ✓ |
| Onboarding | ✓ | – | – | – | ✓ |
| Decisions | ✓ | ✓ | – | ✓ | ✓ |
| Review queue | – | ✓ | ✓ | – | ✓ |
| Actions (financial) | – | – | ✓ | – | ✓ |
| Actions (read/write_low) | ✓ | – | – | – | ✓ |
| Data & contracts | ✓ | – | – | ✓ | ✓ |
| Planning | ✓ | – | ✓ | ✓ | ✓ |
| Audit | – | – | – | ✓ | ✓ |
| Usage & billing | – | – | – | ✓ | ✓ |
| Settings (members, residency) | – | – | – | – | ✓ |
8. Test wajib
| Test | Ekspektasi |
|---|---|
| Reviewer approve financial | 403 |
Key tanpa approvals:write | 403 insufficient_scope |
| Requester approve sendiri | 403 four_eyes_required |
| Dua approver berbeda | 200 |
| Auditor POST apa pun | 403 |
| Reviewer lihat audit | 403 |
| Admin ubah residency sendiri | 403 / butuh approval |
| UI menampilkan tombol yang ditolak API | harus 0 (test snapshot /whoami) |