5.0 Prinsip & lapisan keamanan
Chapter ini mendefinisikan apa yang user lihat dan boleh lakukan. Penegakan tetap tiga lapis (Data Model v1.5): Cloak (kerahasiaan at-rest) + Ash.Policy.Authorizer (kewenangan aksi: role × resource × action) + konfigurasi workspace (visibilitas UI). Ingat: hide UI bukan mekanisme keamanan — menyembunyikan menu tidak menghalangi akses API; yang menghalangi adalah policy.
5.1 Model modul
Ash.Domain (konsisten Chapter 3 §1).5.2 Definisi resmi workspace
| # | Workspace | Flyout: Transactions / Masters / Reports | Visibilitas default |
|---|---|---|---|
| 1 | Accounting | JE, Payment Entry, SI, PI · Account, Cost Center, Fiscal Year, Accounting Period · GL, Trial Balance, BS, P&L, Cash Flow, AR/AP Aging | Owner/Finance |
| 2 | Sales | SO, DN, SI · Customer, Customer Group, Sales Person · Sales Analytics, Customer Ledger, Batch-wise Sales History, Sales Person Wise, Marketplace Settlement (Gross Profit = Owner/Finance saja) | Owner/Finance, Sales |
| 3 | Purchase | MR, PO, PR, PI · Supplier, Supplier Group · PO Analysis, Item-wise Purchase History, Supplier Ledger | Owner/Finance, Warehouse/Purchasing |
| 4 | Manufacturing | Work Order, Stock Entry (Manufacture) · BOM, Operation · Production Analytics, BOM Explorer, Batch Traceability, BOM Stock Report | Owner, Production/R&D |
| 5 | Inventory | Stock Entry, Stock Reconciliation, Stock Reservation · Item, Item Group, Warehouse, UOM, Batch · Stock Balance, Stock Ledger, FEFO/Batch Expiry | Owner, Warehouse, Production |
| 6 | Quality | Quality Inspection, Non Conformance · Quality Template · Batch Quarantine Status, COA Attachment Log | Owner, Production/R&D, BPOM/QA |
| 7 | Asset | Asset Movement, Asset Repair · Asset, Asset Category · Depreciation Schedule | Owner/Finance, Production |
| 8 | HR | Attendance, Payroll Entry, Leave Application · Employee, Salary Structure · Payroll Register | Owner/Finance |
| 9 | Project/R&D | 👁️ Hide default; togglable | Owner, Production/R&D (bila aktif) |
| 10 | System & Utility | Access: User, Role, Permission · Communication: Notification Settings, Email Queue · System: Background Jobs (Oban), Error Log, Data Import/Export, Log Settings | IT |
| 11 | Administration | Policy per modul: Accounts/Stock/Selling/Buying/Manufacturing/HR/Asset/Quality Settings · Workspace Settings · Module enablement | Owner, IT |
| 12 | Organization | Company, Branch, Department, Letter Head · Global Defaults | Owner, IT |
Aturan: flyout bisnis memakai kosakata Transactions / Masters / Reports (v9 §4.4); isi flyout = irisan daftar Peta Menu Rev3 ∩ hak role peminta (policy memfilter, bukan flyout yang mengamankan).
5.3 Role & account model
| Role | Scope | Pembaca Cloak? |
|---|---|---|
| Owner/Finance | Bisnis & finansial penuh; pemegang kunci margin, payroll, bank | ✅ |
| Production/R&D | WO, BOM, batch, QC internal; R&D = pembaca twist_notes |
✅ resep saja |
| Warehouse/Purchasing | Stok, MR/PO/PR, terima/kirim; melihat rate beli (perlu untuk kerja), tidak melihat COGS/margin/harga jual | ❌ margin |
| Sales/Admin Channel | Rekap CSV, DN, SI; melihat harga jual, tidak melihat COGS/margin | ❌ margin |
| IT/System Admin | User, role, log, troubleshoot, import/export master; denied semua field Cloak & laporan finansial | ❌ total |
| BPOM/QA | Traceability (Batch Traceability, Batch-wise Sales History, Quarantine, COA) read-only; tanpa angka finansial | ❌ total |
Account model (konsisten Ch. 2.7): satu orang boleh punya lebih dari satu akun terpisah (budi.sales / budi.owner) — SoD sadar, bukan persona gabungan; Account Switcher menyimpan sesi per akun tanpa mencampur data; personalisasi tiga lapis: Permission (admin) → Role Default (template fungsi) → Personal (override individu, resettable).
5.4 Matriks Permission (lapis Ash.Policy.Authorizer)
Legenda: F = Full (Read+Create+Write+Submit+Cancel+Export) · S = Submit (Read+Create+Write+Submit, tanpa Cancel) · W = Draft saja (Read+Create+Write) · R = Read+Export · R• = Read dengan penolakan field (lihat 5.5) · o = record milik sendiri saja · – = tidak ada.
Aturan governance: Cancel hanya F (Owner/Finance) — cancel = baris pembalik di ledger, harus di bawah pengawasan finance.
| Resource | Owner/Fin | Prod/R&D | Wh/Purch | Sales | IT | BPOM/QA |
|---|---|---|---|---|---|---|
| Sales | ||||||
| SalesOrder (+items+fees) | F | – | – | S | R• | – |
| DeliveryNote | F | – | S | R | R• | R |
| SalesInvoice (+items) | F | – | – | R | – | – |
| Customer / CustomerGroup | F | – | – | R | R• | – |
| SalesPerson | F | – | – | R | R• | – |
| Inventory | ||||||
| Item / ItemGroup / UOM | F | R | R | R | R• | R |
| Warehouse | F | R | S | R | R• | R |
| Batch | F | R | R | R | R• | S |
| StockEntry | F | S | S | – | – | R |
| StockReconciliation | F | – | S | – | – | – |
| Purchase | ||||||
| MaterialRequest | F | S | S | – | – | – |
| PurchaseOrder | F | – | S | – | R• | – |
| PurchaseReceipt | F | – | S | – | R• | R |
| PurchaseInvoice | F | – | W | – | – | – |
| Supplier / SupplierGroup | F | – | S | – | R• | – |
| LandedCostVoucher | F | – | W | – | – | – |
| Manufacturing | ||||||
| BOM (+items) | F | F | R• | – | R• | R• |
| WorkOrder | F | S | R | – | R• | R |
| ProductionPlan / Operation | F | S | R | – | – | – |
| Quality | ||||||
| QualityInspection | F | S | W | – | – | S |
| NonConformance | F | S | R | – | – | S |
| QualityTemplate | F | S | R | – | – | S |
| Laporan Quality (Quarantine, COA log) | F | R | R | R | – | R |
| Accounting | ||||||
| JournalEntry | F | – | – | – | – | – |
| PaymentEntry (+deductions+references) | F | – | – | – | – | – |
| Account/CoA, CostCenter, FiscalYear, Period | F | – | – | – | R• | – |
| Budget (+items+distribution; 👁️ default) | F | – | – | – | – | – |
| Bank / BankAccount / BankTransaction | F | – | – | – | – | – |
| Taxes template / Withholding | F | – | W | – | – | – |
| Laporan finansial (GL, TB, BS, P&L, CF, AR/AP) | F | – | – | – | – | – |
| Laporan margin (Gross Profit, margin Analytics) | F | – | – | – | – | – |
| Marketplace Settlement Report | F | – | – | R | – | – |
| Laporan Sales non-margin (Analytics qty/amount, Item Sales, SP Wise, Batch-wise Sales) | F | – | R | R | – | R |
| HR | ||||||
| Employee | F | o | o | o | R• | – |
| Attendance / Leave | F | o | o | o | – | – |
| SalaryStructure / SalarySlip / Payroll | F | o | o | o | – | – |
| Asset | ||||||
| Asset (+schedule/movement/repair) | F | R | S | – | R• | – |
| System | ||||||
| User / Role / Permission | F | – | – | – | F | – |
| AccessLog / Settings / Workspace / Log | F | – | – | – | F | – |
| DataImport / DataExport | F | – | – | S (rekap CSV) | R (master saja) | – |
Cakupan penolakan R• per role (server-side, bukan sekadar UI):
rate/amount/cogs/valuation di dokumen bisnis + seluruh grup Cloak A–E; yang terlihat = struktur, kode, status, jumlah baris, log. BOM = kode internal saja.valuation_rate stok), B, C, D; rate beli terlihat (itu pekerjaannya), rate jual di DN terlihat (harga publik marketplace).bpom_license read-only.5.5 Registry Cloak (lapis enkripsi at-rest + pembaca runtime)
| Grup | Field | Pembaca runtime |
|---|---|---|
| A — Margin/COGS | sales_invoice_items.cogs/gross_profit; stock_ledger_entries.valuation_rate; bins.valuation_rate |
Owner/Finance |
| B — Resep | boms.twist_notes, boms.formulation_code, bom_items.qty, bom_items.rate |
Owner, Prod/R&D |
| C — Payroll/PII | employees.{email,phone,bank_account,bank_name,tax_id,address}; salary_structures.components; salary_slips.* |
Owner/Finance |
| D — Bank | bank_accounts.account_number; bank_transactions.* |
Owner/Finance |
| E — Rahasia entitas | companies.tax_id, companies.bpom_license; batches.supplier_drum_code; purchase_receipt_items.supplier_drum_code |
tax_id: Owner/Finance · bpom_license: +BPOM/QA · drum_code: Owner, Prod/R&D, Wh/Purch |
Aturan penegakan (konvensi implementasi)
permissions (role, resource_type, action, conditions). o (own-record) diwujudkan via conditions (employee.user_id = current_user).Export, tombol xlsx/csv tidak render dan endpoint diblokir; export role R• men-strip kolom yang ditolak.access_logs + Ledger Health + Oban Web — bukan tabel bisnis. Akses darurat (break-glass) wajib persetujuan Owner dan tercatat di access_logs.5.6 Setting Hub - satu permukaan untuk semua policy
5.6.1 Definisi & batas Settings Hub adalah satu-satunya permukaan tempat seluruh policy, switch, dan konfigurasi global bermuara, terstruktur per fungsi (Temuan UX #4). Ia adalah halaman Overview workspace Administration (tingkat 1): klik label "Administration" di rail = mendarat di Settings Hub; flyout Administration = jalan pintas per tab. Batas tegas — Settings Hub bukan:
5.6.2 Struktur halaman
Home / Administration; page-head 48; tanpa launcher grid.5.6.3 Isi per tab
| Tab | Policy doctype yang dihuni |
|---|---|
| Accounting | Accounts Settings (frozen date + role pengecualian, kopel stok–ledger, panjar); Accounting Period 👁️; Chart of Accounts Importer (alat setup); Account Category 👁️ |
| Inventory | Stock Settings (negative stock OFF, valuasi default, auto-batch) |
| Sales | Selling Settings (same-rate ON, allowance 0, reason code retur, toggle reservasi) |
| Purchase | Buying Settings (policy PO wajib, same-rate simetris, allowance over-receipt) |
| Manufacturing | Manufacturing Settings (backflush, batch generation, ambang soft-gate maturing) |
| Quality | Quality Settings (template default, aturan quarantine) |
| HR | HR Settings (default absensi, pembulatan payroll) |
| Asset | Asset Settings (default depresiasi, ambang kapitalisasi repair) |
| Access | User, Role, Permission Matrix editor (visualisasi matriks 5.4), User Permission |
| System | Workspace Settings, Notification Settings, Module Enablement, Numbering Series, Print Format Builder 👁️, Log Settings |
5.6.4 Perilaku form & perubahan
allow_zero_valuation_rate) = modal konfirmasi konsekuen, bukan "Apakah Anda yakin?".Home / Administration / Selling Settings) — breadcrumb = konfirmasi rumah (Temuan #5).5.6.5 Hide/enable & progressive module enablement
5.6.6 Keamanan & audit
F hanya untuk Owner/IT.5.6.7 Konvensi developer (rujukan Chapter 4)
settings.@moduledoc tiap policy merujuk bab Settings modul referensi (mis. Selling Settings = Sales Chapter C).5.6.8 Log keputusan