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 · 4.2 KB · 79 lines
| 1 | { |
| 2 | "rules": [ |
| 3 | { |
| 4 | "effect": "allow", |
| 5 | "principal": "registered", |
| 6 | "actions": ["create", "read", "update", "delete"], |
| 7 | "collection": "products", |
| 8 | "row_filter": {"owner_id": "$user_id"}, |
| 9 | "reason": "signed-in users manage the products they created. v1 keeps the catalog owner-scoped like app-invoices; a public read rule for a storefront view is deferred (see dbbasic-package.json)" |
| 10 | }, |
| 11 | { |
| 12 | "effect": "allow", |
| 13 | "principal": "registered", |
| 14 | "actions": ["create", "read", "update", "delete"], |
| 15 | "collection": "locations", |
| 16 | "row_filter": {"owner_id": "$user_id"}, |
| 17 | "reason": "signed-in users manage the warehouse/zone/aisle/shelf/bin (and virtual customer/supplier) locations they created, same owner-scoped posture as products" |
| 18 | }, |
| 19 | { |
| 20 | "effect": "allow", |
| 21 | "principal": "registered", |
| 22 | "actions": ["create", "read", "update", "delete"], |
| 23 | "collection": "stock_moves", |
| 24 | "row_filter": {"owner_id": "$user_id"}, |
| 25 | "reason": "signed-in users manage the stock moves they recorded. stock_moves is append-mode and immutable in spirit (see schemas/stock_moves.json) but this platform has no separate create-only permission action -- update/delete stay owner-scoped rather than granted to everyone, the same posture app-thread's append-mode thread_comments takes" |
| 26 | }, |
| 27 | { |
| 28 | "effect": "allow", |
| 29 | "principal": "registered", |
| 30 | "actions": ["create", "read", "update"], |
| 31 | "collection": "backorders", |
| 32 | "row_filter": {"owner_id": "$user_id"}, |
| 33 | "reason": "signed-in users manage the backorders raised against their own catalogue, same owner-scoped posture as products. No DELETE: a customer who waited and was let down is a fact the shop should still be able to find, and `cancelled` says that out loud where a missing row would say nothing at all" |
| 34 | }, |
| 35 | { |
| 36 | "effect": "allow", |
| 37 | "principal": "registered", |
| 38 | "actions": ["read", "update"], |
| 39 | "collection": "reorder_suggestions", |
| 40 | "row_filter": {"owner_id": "$user_id"}, |
| 41 | "reason": "a suggestion is written by system_reorder_check and ANSWERED by a human -- marked ordered when somebody bought some, dismissed when somebody looked and said no -- so read and update are the whole of what a person needs. No CREATE: a suggestion typed by hand is an observation of a shelf nobody looked at, and the nightly fold is the only thing here that has looked. No DELETE either: the pass keeps one open row per product and refreshes it, so there is nothing to tidy up, and a dismissed row is the record that somebody decided" |
| 42 | }, |
| 43 | { |
| 44 | "effect": "allow", |
| 45 | "principal": "registered", |
| 46 | "actions": ["execute"], |
| 47 | "object_id": "system_reorder_check", |
| 48 | "reason": "an operator who has just set a reorder point should be able to poke the nightly pass without an admin token. It is safe to run by hand for the same reason it is safe to retry: it writes SUGGESTIONS and never a purchase order, it keeps one open row per product and refreshes rather than appends, so the worst a signed-in person can do with it is learn today's answer a few hours early" |
| 49 | }, |
| 50 | { |
| 51 | "effect": "allow", |
| 52 | "principal": "public", |
| 53 | "actions": ["execute"], |
| 54 | "object_id": "site_products", |
| 55 | "reason": "the products page is public; it shows a sign-in prompt to visitors" |
| 56 | }, |
| 57 | { |
| 58 | "effect": "allow", |
| 59 | "principal": "public", |
| 60 | "actions": ["execute"], |
| 61 | "object_id": "site_locations", |
| 62 | "reason": "the locations page is public; it shows a sign-in prompt to visitors" |
| 63 | }, |
| 64 | { |
| 65 | "effect": "allow", |
| 66 | "principal": "public", |
| 67 | "actions": ["execute"], |
| 68 | "object_id": "site_stock", |
| 69 | "reason": "the stock levels page is public; it shows a sign-in prompt to visitors, and computes the owner-scoped summary itself once signed in (see objects/site/stock.py)" |
| 70 | }, |
| 71 | { |
| 72 | "effect": "allow", |
| 73 | "principal": "registered", |
| 74 | "actions": ["execute"], |
| 75 | "object_id": "action_apply_count", |
| 76 | "reason": "applying a physical count is an ordinary operator verb; the object requires a signed-in identity, stamps the caller as the move's owner, and writes only compensating adjustment moves (never edits)" |
| 77 | } |
| 78 | ] |
| 79 | } |