RBAC Architecture & Role Definitions (L0βL4)
Dokumentasi lengkap Role-Based Access Control (RBAC) multi-level untuk sistem MStore yang dapat scale dari Micro business hingga Multi-National Corporation (MNC) dengan 57 roles terstruktur.π― Prinsip Desain
Arsitektur ini dibangun berdasarkan 4 pilar utama:Security
Principle of Least Privilege & Segregation of Duties
Efficiency
Role dapat dirangkap aman untuk tim kecil (kurang dari 50 staff)
Auditability
Semua transaksi critical ada trail & approval log
Scalability
Mudah upgrade dari L1 ke L4 tanpa breaking change
π Level Overview
Total: 57 roles across 5 business levels
π§© L0 β Micro / Solo
π― Fokus: Sistem sederhana untuk 1β3 user tanpa approval flow πΌ Contoh Bisnis: Warung, freelancer, jasa kecilRoles
Karakteristik
- β Simple & Fast: Setup < 5 menit
- β No SoD: Tidak ada aturan rangkap jabatan
- β Single Device: Ideal untuk POS mini
- β οΈ No Approval: Tidak ada workflow approval
π§© L1 β SME (SmallβMedium Enterprise)
π― Fokus: ERP dasar β Finance, HR, Inventory πΌ Contoh Bisnis: Toko retail, bengkel, cafe, grosir kecilRoles
Karakteristik
- β Efisien: Cukup 6 role untuk 5-20 staff
- β Tanpa konflik: Belum ada SoD strict
- β Rangkap aman: 1 orang boleh > 1 role
- β οΈ Basic approval: Approval sederhana saja
π§© L2 β Enterprise
π― Fokus: Multi-department, approval flow, RBAC penuh πΌ Contoh Bisnis: Manufaktur, e-commerce besar, distribusiCore Roles (24 total)
- Management (3)
- Finance (4)
- Operations (6)
- Marketing & CRM (4)
- Customer Service (2)
- R&D (2)
- Support (3)
- Approvers (2)
- L2_OWN-MGR: Akses penuh & approval tertinggi
- L2_ADM-BIZ: Konfigurasi bisnis (COA, tax, workflow)
- L2_ADM-SYS: Infrastruktur teknis (deployment, backup)
Segregation of Duties (SoD)
Karakteristik
- β SoD Aktif: Segregation of Duties enforcement
- β Approval Flow: Multi-level approval (L1, L2)
- β Department-based: Role per departemen
- β Audit Trail: Lengkap untuk semua transaksi
π§© L3 β Holding
π― Fokus: Multi-entitas, multi-currency, intercompany πΌ Contoh Bisnis: Grup usaha dengan beberapa anak perusahaanHolding-Level Roles (9 total)
Domain Architecture
Karakteristik
- β Domain Isolation: Role terisolasi per entitas
- β Intercompany: Support transaksi antar entitas
- β Consolidation: Laporan konsolidasi grup
- β Multi-Currency: Support mata uang berbeda
π§© L4 β Corporate / MNC
π― Fokus: Multi-country, regulatory compliance, SSO, OPA πΌ Contoh Bisnis: Grup lintas negara, public companyGlobal Roles (15 total)
Integration Stack
Identity & Access
- SSO (SAML, OAuth2)
- LDAP/Active Directory
- MFA enforcement
Policy Engine
- OPA (Open Policy Agent)
- Casbin multi-domain
- Redis Watcher (real-time sync)
Compliance
- SOX compliance
- ISO 27001
- GDPR ready
Monitoring
- Audit log central
- SIEM integration
- Anomaly detection
Karakteristik
- β Global Compliance: SOX, ISO, GDPR
- β SSO Integration: Single sign-on
- β Zero-Trust: OPA policy enforcement
- β Real-time Sync: Redis watcher untuk policy
- β Multi-Region: Support deployment global
π Upgrade Path
Evolusi Natural
Migration Strategy
1
L0 β L1
Trigger: Staff bertambah > 3 orangAction:
- Tambah role FIN-MGR, INV-MGR, HR-MGR
- Pisahkan owner dari operator
- Setup basic audit (role AUD)
2
L1 β L2
Trigger: Multi-department atau staff > 20 orangAction:
- Aktifkan SoD rules
- Split admin (ADM-BIZ vs ADM-SYS)
- Implementasi approval flow (APV-L1, APV-L2)
- Pisah finance (FIN-AP, FIN-AR, FIN-CASH)
3
L2 β L3
Trigger: Multi-entity atau holding structureAction:
- Aktifkan domain isolation
- Setup consolidation (CONS-MGR)
- Tambah entity-level roles (@ENT-xx)
- Implementasi intercompany transactions
4
L3 β L4
Trigger: Multi-country atau go publicAction:
- Integrasikan SSO (SAML/OAuth2)
- Deploy OPA untuk global policy
- Setup compliance (GOV-COMP)
- Aktifkan Redis watcher
π οΈ Implementasi Teknis
Database Schema
Backend (Go/Fiber)
Casbin Policy
π Best Practices
1. Role Assignment
2. Segregation of Duties
3. Upgrade Timing
π§ͺ Testing & Validation
Role Validation Script
Casbin Policy Test
π Related Documentation
Bruno API Collections
API V2 collections organized by role
UI/UX by Level
UI/UX specifications for each business level
Approval Flow
Multi-level approval workflow
Audit Logs
Tracking aktivitas user per role
User Management
Cara assign role ke user
Security Best Practices
Panduan keamanan sistem
π Example Scenarios
Scenario 1: Toko Retail (L1)
Setup:- 1 Owner (L1_OWN-MGR)
- 1 Kasir (L1_CSH)
- 1 Admin Stok (L1_INV-MGR)
- 1 Keuangan part-time (L1_FIN-MGR)
- Owner merangkap HR-MGR (aman karena L1 belum strict SoD)
- Kasir merangkap VWR untuk lihat laporan (aman)
Scenario 2: Manufaktur (L2)
Setup:- 1 Owner (L2_OWN-MGR)
- 2 Admin (L2_ADM-BIZ, L2_ADM-SYS) β harus pisah!
- Finance team: L2_FIN-AP, L2_FIN-AR, L2_ACC-MGR β tidak boleh rangkap!
- Operations: L2_INV-MGR, L2_PRC-MGR, L2_SL-MGR
- Approvers: L2_APV-L1, L2_APV-L2
- L2_FIN-AP β L2_ACC-MGR (tidak boleh self-approve)
- L2_ADM-SYS β L2_FIN.* (system admin tidak boleh edit keuangan)
Scenario 3: Holding Group (L3)
Setup:- HOLDING: L3_CONS-MGR, L3_AUD-GRP, L3_APV-L3
- ENT-01 (Trading): L3_FIN-MGR@ENT-01, L3_INV-MGR@ENT-01
- ENT-02 (Manufacturing): L3_FIN-MGR@ENT-02, L3_INV-MGR@ENT-02
- L3_FIN-MGR@ENT-01 hanya akses data ENT-01
- L3_CONS-MGR@HOLDING bisa akses semua entity
π Support
Jika ada pertanyaan tentang multi-level RBAC atau butuh konsultasi untuk upgrade level, hubungi tim development. Tags:rbac, multi-level, security, scalability, casbin, enterprise, architecture, roles