Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/dron/dron-permissions.schema.json
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 19 minutes ago History
dron-permissions.schema.json · 8.3 KB · 173 lines
1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "DRON permissions",
4 "description": "DRON (Data Rules Object Notation) is a portable, declarative description of an application's data and the rules over it. This file validates a package's permission rules: who (a principal) may do what (actions) to which collection or object, optionally only for some rows and some fields. It validates one packages/<id>/permissions/rules.json. Explicit denies are checked before allows; a request matching no rule falls back to the row's owner. DRON 0.2.",
5 "type": "object",
6 "required": [
7 "rules"
8 ],
9 "additionalProperties": false,
10 "properties": {
11 "$schema": {
12 "description": "Optional pointer to this file so an editor can offer completion and flag mistakes. The engine ignores it.",
13 "type": "string"
14 },
15 "rules": {
16 "description": "The rules this package ships. On install they are merged into the deployment's policy, tagged with the package id, skipping any rule that is already there. Changing or deleting a rule here withdraws the old one on the next upgrade of a box that recorded it; for older boxes also list the old rule in retracted.",
17 "type": "array",
18 "items": {
19 "$ref": "#/$defs/rule"
20 }
21 },
22 "retracted": {
23 "description": "Rules this package once shipped and no longer does, in the same shape as rules, so every older install finds out and removes them. When you delete or tighten a shipped rule, copy the old rule here in the same commit and give a reason saying why it was withdrawn. A rule may not be in both rules and retracted (the install is refused). Only a rule tagged as this package's and identical to the entry is removed.",
24 "type": "array",
25 "items": {
26 "$ref": "#/$defs/rule"
27 }
28 }
29 },
30 "$defs": {
31 "rule": {
32 "title": "DRON permission rule",
33 "description": "One allow or deny. A rule applies when the viewer matches principal, the request is one of actions, and it concerns the named collection or object (a rule naming neither applies to everything, which is almost never what you want). A rule with a row_filter applies only to rows matching it.",
34 "type": "object",
35 "required": [
36 "effect",
37 "principal",
38 "actions"
39 ],
40 "additionalProperties": false,
41 "properties": {
42 "effect": {
43 "description": "allow grants the actions; deny refuses them and beats any allow. Example: \"allow\".",
44 "enum": [
45 "allow",
46 "deny"
47 ]
48 },
49 "principal": {
50 "description": "Who the rule is about: public (anyone, signed in or not), registered (any signed-in user), owner (whoever the row's owner_id, user_id or created_by names), role:<name> (holders of a role), user:<id>, account:<id>, subscription:<plan>, or owner_fallback (a DENY-only marker that switches the owner fallback off for these actions and resource, so owners cannot update or delete rows the rules leave unmentioned). Example: \"role:manager\".",
51 "type": "string",
52 "pattern": "^(public|registered|owner|owner_fallback|(role|user|account|subscription):.+)$"
53 },
54 "actions": {
55 "description": "What the rule covers. read, create, update, delete: records. execute: run an object or page. source, state, logs, files, versions: an object's internals. share: share a record. admin: administer. \"*\": every action. Example: [\"read\", \"update\"].",
56 "type": "array",
57 "minItems": 1,
58 "uniqueItems": true,
59 "items": {
60 "enum": [
61 "read",
62 "create",
63 "update",
64 "delete",
65 "execute",
66 "source",
67 "state",
68 "logs",
69 "files",
70 "versions",
71 "share",
72 "admin",
73 "*"
74 ]
75 }
76 },
77 "collection": {
78 "description": "The collection the rule is about. Omit it only for a rule about objects. Example: \"invoices\".",
79 "$ref": "dron-common.schema.json#/$defs/collectionName"
80 },
81 "object_id": {
82 "description": "The object (page, action, system pass) the rule is about, with execute and the other object actions. Example: \"site_invoices\".",
83 "$ref": "dron-common.schema.json#/$defs/collectionName"
84 },
85 "row_filter": {
86 "description": "Limits the rule to rows matching this filter. An allow with a filter grants only those rows; a deny with a filter hides only those rows (a list stays allowed, the matching rows vanish). Example: {\"owner_id\": \"$user_id\"} gives each viewer their own rows.",
87 "$ref": "dron-common.schema.json#/$defs/rowFilter"
88 },
89 "fields": {
90 "description": "Allow-list: the viewer sees only these fields of a covered row. Omit for all fields. Example: [\"id\", \"status\"].",
91 "type": "array",
92 "items": {
93 "$ref": "dron-common.schema.json#/$defs/fieldName"
94 }
95 },
96 "denied_fields": {
97 "description": "Fields hidden from the viewer on a covered row, even if fields would show them. Example: [\"internal_notes\"].",
98 "type": "array",
99 "items": {
100 "$ref": "dron-common.schema.json#/$defs/fieldName"
101 }
102 },
103 "valid_from": {
104 "description": "ISO-8601 timestamp before which the rule is inactive. An unparseable value makes the rule never apply. Example: \"2026-01-01T00:00:00Z\".",
105 "type": "string",
106 "pattern": "^\\d{4}-\\d{2}-\\d{2}"
107 },
108 "expires_at": {
109 "description": "ISO-8601 timestamp from which the rule is inactive. An unparseable value makes the rule never apply.",
110 "type": "string",
111 "pattern": "^\\d{4}-\\d{2}-\\d{2}"
112 },
113 "on_behalf": {
114 "description": "true lets the principal create rows whose owner_id names ANOTHER user: staff entering a donation for a donor or an appointment for a patient. Without it a signed-in create owns its row itself: owner_id left out is filled with the caller's id, and owner_id naming someone else is refused with 403 (never rewritten). Valid only on an allow that names a collection and covers create, for a role:<name> or user:<id> principal; the rule's row_filter still has to match the record as sent, and an explicit deny still wins. Example: true.",
115 "type": "boolean"
116 },
117 "reason": {
118 "description": "Why the rule exists, in a sentence a reviewer can judge. Shown in audit and in explanations of a refusal. Every shipped rule carries one; for a retracted rule it says why the rule was withdrawn.",
119 "type": "string"
120 },
121 "package": {
122 "description": "Provenance tag the installer writes (the shipping package's id). You do not set it; it is overwritten on install.",
123 "$ref": "dron-common.schema.json#/$defs/packageId"
124 }
125 },
126 "allOf": [
127 {
128 "description": "owner_fallback only switches the fallback off, so it is valid on a deny alone; on an allow it would read as a grant and grant nothing.",
129 "if": {
130 "properties": {
131 "principal": {
132 "const": "owner_fallback"
133 }
134 }
135 },
136 "then": {
137 "properties": {
138 "effect": {
139 "const": "deny"
140 }
141 }
142 }
143 },
144 {
145 "description": "on_behalf hands somebody else a row, so it is a staff grant: an allow, on a named collection, covering create, for a role or one user. The engine also requires create (or \"*\") among the actions, and refuses any other shape as an invalid policy.",
146 "if": {
147 "required": [
148 "on_behalf"
149 ],
150 "properties": {
151 "on_behalf": {
152 "const": true
153 }
154 }
155 },
156 "then": {
157 "required": [
158 "collection"
159 ],
160 "properties": {
161 "effect": {
162 "const": "allow"
163 },
164 "principal": {
165 "pattern": "^(role|user):.+$"
166 }
167 }
168 }
169 }
170 ]
171 }
172 }
173}