askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
rules.json · 6.4 KB · 56 lines
| 1 | { |
| 2 | "retracted": [ |
| 3 | {"effect": "allow", "principal": "registered", "actions": ["execute"], "object_id": "action_exchange_send", |
| 4 | "reason": "0.2.0 let any signed-in user run it; a plain registered user is a customer, who owns the orders and invoices checkout raises for them, and must not send documents in the business's name (0.2.1)"}, |
| 5 | {"effect": "allow", "principal": "registered", "actions": ["execute"], "object_id": "action_exchange_confirm_remittance", |
| 6 | "reason": "0.2.0 let any signed-in user run it; confirming records a payment, which is staff's since app-payments 0.8.0 (0.2.1)"} |
| 7 | ], |
| 8 | "rules": [ |
| 9 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "webhook_exchange", |
| 10 | "reason": "the exchange endpoint: another company's server delivers here with no session; authenticity is the document's signature against keys pinned for a connected partner (object_exchange_box.inbound), checked before anything is stored"}, |
| 11 | {"effect": "allow", "principal": "public", "actions": ["execute"], "object_id": "site_exchange_profile", |
| 12 | "reason": "the public profile at /.well-known/dbbasic: domain, company, endpoint and PUBLIC keys, which partners must be able to fetch before they trust us; it carries no secret"}, |
| 13 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_exchange_admin", |
| 14 | "reason": "the business's owner manages trading partners and keys (admins always may); the object checks the role again because every write it makes is a trusted storage-level write"}, |
| 15 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_exchange_send", |
| 16 | "reason": "staff send an order, confirmation, invoice, remittance or receipt to a connected partner; the object checks the staff role again and asks object_access for update on the record being sent, so staff send only what they could change"}, |
| 17 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_exchange_send", |
| 18 | "reason": "the business's owner sends documents in its name, under the same object checks as staff"}, |
| 19 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_exchange_confirm_remittance", |
| 20 | "reason": "staff record a partner's remittance as a payment once the money is seen in the bank; the object asks object_access for update on every invoice and for create on every payment before writing any"}, |
| 21 | {"effect": "allow", "principal": "role:manager", "actions": ["execute"], "object_id": "action_exchange_resolve", |
| 22 | "reason": "staff decide on a supplier's confirmation that differs from our purchase order: accept it (our order is changed to match, each line write under their name) or reject it; the object checks the staff role again and asks object_access for update on the order"}, |
| 23 | {"effect": "allow", "principal": "role:owner", "actions": ["execute"], "object_id": "action_exchange_resolve", |
| 24 | "reason": "the business's owner decides on a supplier's confirmation, under the same object checks as staff"}, |
| 25 | {"effect": "allow", "principal": "role:exchange_partner", "actions": ["create"], "collection": "orders", |
| 26 | "reason": "a partner's purchase order becomes a DRAFT sale order in the receiving owner's books; the exchange asks this as the synthetic subject exchange-partner:<domain>, so what a partner can cause here is this list and nothing more. No read, update or delete: the partner principal cannot see or change anything that exists. Do not give this role to a person"}, |
| 27 | {"effect": "allow", "principal": "role:exchange_partner", "actions": ["create"], "collection": "order_lines", |
| 28 | "reason": "the lines of that draft sale order, as the purchase order stated them"}, |
| 29 | {"effect": "allow", "principal": "role:exchange_partner", "actions": ["create"], "collection": "supplier_bills", |
| 30 | "reason": "a partner's invoice or credit note becomes a supplier bill in `received`, waiting for a person; nothing pays it"}, |
| 31 | {"effect": "allow", "principal": "role:exchange_partner", "actions": ["create"], "collection": "supplier_bill_lines", |
| 32 | "reason": "the lines of that supplier bill, as the supplier wrote them"}, |
| 33 | {"effect": "allow", "principal": "role:exchange_partner", "actions": ["create"], "collection": "supplier_bill_credits", |
| 34 | "reason": "a partner's credit note is applied as its signed document says (to the bill it credits, or on account) in the same act that records it, so it never reads as money we owe"}, |
| 35 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "trading_partners", |
| 36 | "reason": "the owner sees who the business trades with; nobody edits a partner through the record API (the exchange writes it)"}, |
| 37 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "exchange_identity", |
| 38 | "reason": "the owner sees the box's exchange identity; it is set by action_exchange_admin"}, |
| 39 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "exchange_keys", |
| 40 | "reason": "public keys only (the private halves are never records); rotation is action_exchange_admin"}, |
| 41 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "exchange_inbox", |
| 42 | "reason": "the owner reads every document received and what became of it; the rows are frozen evidence"}, |
| 43 | {"effect": "allow", "principal": "role:owner", "actions": ["read"], "collection": "exchange_outbox", |
| 44 | "reason": "the owner reads every document sent and its receipt"}, |
| 45 | {"effect": "allow", "principal": "registered", "actions": ["read"], "collection": "exchange_outbox", |
| 46 | "row_filter": {"owner_id": "$user_id"}, |
| 47 | "reason": "a person sees whether what they sent was delivered"}, |
| 48 | {"effect": "allow", "principal": "registered", "actions": ["read"], "collection": "exchange_inbox", |
| 49 | "row_filter": {"owner_id": "$user_id"}, |
| 50 | "reason": "the person whose books a partner's documents land in reads them"}, |
| 51 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "exchange_inbox", |
| 52 | "reason": "a received document is evidence, kept as it arrived (locked_when freezes it for every writer as well); its owner reads it and never edits or removes it"}, |
| 53 | {"effect": "deny", "principal": "owner_fallback", "actions": ["update", "delete"], "collection": "exchange_outbox", |
| 54 | "reason": "a signed document and the partner's receipt are evidence; only the exchange updates its delivery state"} |
| 55 | ] |
| 56 | } |