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.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
rules.json · 3.3 KB · 100 lines
| 1 | { |
| 2 | "rules": [ |
| 3 | { |
| 4 | "effect": "allow", |
| 5 | "principal": "registered", |
| 6 | "actions": [ |
| 7 | "read" |
| 8 | ], |
| 9 | "collection": "wallets", |
| 10 | "row_filter": { |
| 11 | "owner_id": "$user_id" |
| 12 | }, |
| 13 | "reason": "a customer may always see their own balance and how it got there; they may not WRITE it -- the balance is a rollup, and the settings that drive auto top-up are changed through an owner-gated form, not by editing a number" |
| 14 | }, |
| 15 | { |
| 16 | "effect": "allow", |
| 17 | "principal": "registered", |
| 18 | "actions": [ |
| 19 | "update" |
| 20 | ], |
| 21 | "collection": "wallets", |
| 22 | "row_filter": { |
| 23 | "owner_id": "$user_id" |
| 24 | }, |
| 25 | "reason": "owners tune their own auto top-up threshold, amount and cap; balance_minor is computed and refused by the write path regardless" |
| 26 | }, |
| 27 | { |
| 28 | "effect": "allow", |
| 29 | "principal": "registered", |
| 30 | "actions": [ |
| 31 | "read" |
| 32 | ], |
| 33 | "collection": "wallet_entries", |
| 34 | "row_filter": { |
| 35 | "owner_id": "$user_id" |
| 36 | }, |
| 37 | "reason": "every customer can see exactly why their balance is what it is -- the statement is the ledger, not a summary of it. No create/update/delete: entries are written server-side by the metering, top-up and refund paths, and a client that could append its own credit could print money" |
| 38 | }, |
| 39 | { |
| 40 | "effect": "allow", |
| 41 | "principal": "registered", |
| 42 | "actions": [ |
| 43 | "read" |
| 44 | ], |
| 45 | "collection": "billing_plans", |
| 46 | "reason": "prices are not a secret from the people paying them; a customer may read the plan they are on and the ones they could move to" |
| 47 | }, |
| 48 | { |
| 49 | "effect": "allow", |
| 50 | "principal": "role:admin", |
| 51 | "actions": [ |
| 52 | "create", |
| 53 | "update", |
| 54 | "delete" |
| 55 | ], |
| 56 | "collection": "billing_plans", |
| 57 | "reason": "the price book is an operator surface -- and edits are constrained by convention, not permission: changing a price means adding a row, because an old invoice must keep showing what it charged" |
| 58 | }, |
| 59 | { |
| 60 | "effect": "allow", |
| 61 | "principal": "registered", |
| 62 | "actions": [ |
| 63 | "create", |
| 64 | "read", |
| 65 | "update", |
| 66 | "delete" |
| 67 | ], |
| 68 | "collection": "subscriptions", |
| 69 | "row_filter": { |
| 70 | "owner_id": "$user_id" |
| 71 | }, |
| 72 | "reason": "a subscription is owned by the account that sells it; the status ladder is additionally constrained by declared transitions, so even its owner cannot skip from active straight to suspended without the daemon's reasons" |
| 73 | }, |
| 74 | { |
| 75 | "effect": "allow", |
| 76 | "principal": "registered", |
| 77 | "actions": [ |
| 78 | "create", |
| 79 | "read" |
| 80 | ], |
| 81 | "collection": "usage_events", |
| 82 | "row_filter": { |
| 83 | "owner_id": "$user_id" |
| 84 | }, |
| 85 | "reason": "the metered service records its own usage and the customer can read every event behind a bill; nobody updates or deletes one -- a measurement of something that happened is not editable, and a correction is a credit" |
| 86 | }, |
| 87 | { |
| 88 | "effect": "allow", |
| 89 | "principal": "registered", |
| 90 | "actions": [ |
| 91 | "read" |
| 92 | ], |
| 93 | "collection": "usage_summaries", |
| 94 | "row_filter": { |
| 95 | "owner_id": "$user_id" |
| 96 | }, |
| 97 | "reason": "the buckets a bill is computed from are readable by the person being billed; they are written by the rollup pass alone" |
| 98 | } |
| 99 | ] |
| 100 | } |