|
| 1 | +# OpenBuilt RBAC — Per-Virtual-App Permissions |
| 2 | + |
| 3 | +OpenBuilt's per-virtual-app role-based access control (RBAC) layers on |
| 4 | +top of OpenRegister's organisation-scoping (ADR-022). Within an |
| 5 | +organisation, three roles partition who can do what with each |
| 6 | +Application: `owner`, `editor`, `viewer`. |
| 7 | + |
| 8 | +## Roles |
| 9 | + |
| 10 | +| Action | viewer | editor | owner | |
| 11 | +| ------------------------------------- | :----: | :----: | :---: | |
| 12 | +| Read manifest / browse Application | yes | yes | yes | |
| 13 | +| Save manifest draft | no | yes | yes | |
| 14 | +| Publish (`draft → published`) | no | no | yes | |
| 15 | +| Archive (`published → archived`) | no | no | yes | |
| 16 | +| Re-open (`archived → draft`) | no | no | yes | |
| 17 | +| Edit `permissions` | no | no | yes | |
| 18 | +| Transfer ownership | no | no | yes | |
| 19 | +| Delete Application | no | no | yes | |
| 20 | + |
| 21 | +Roles are keyed by Nextcloud group ID, stored declaratively on the |
| 22 | +Application schema: |
| 23 | + |
| 24 | +```json |
| 25 | +{ |
| 26 | + "permissions": { |
| 27 | + "owners": ["team-alpha"], |
| 28 | + "editors": ["team-alpha", "qa-shared"], |
| 29 | + "viewers": ["everyone"] |
| 30 | + } |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +A caller's effective role is computed by intersecting their Nextcloud |
| 35 | +group membership with the three buckets, taking the highest-privilege |
| 36 | +match. |
| 37 | + |
| 38 | +## Default on creation |
| 39 | + |
| 40 | +New Applications default `permissions.owners` to the **creator's |
| 41 | +primary Nextcloud group**; `editors` and `viewers` start empty. If the |
| 42 | +creator has no group memberships, `owners` falls back to `['admin']` |
| 43 | +so the Application is never orphaned (REQ-OBRBAC-001). |
| 44 | + |
| 45 | +## Manifest endpoint enforcement |
| 46 | + |
| 47 | +`GET /index.php/apps/openbuilt/api/applications/{slug}/manifest` |
| 48 | +deny-by-defaults to `403 Forbidden` when the caller has no group in |
| 49 | +the union of the three buckets (REQ-OBR-006, REQ-OBRBAC-002). The |
| 50 | +check runs before the manifest payload is emitted — the 403 body |
| 51 | +never leaks Application metadata. |
| 52 | + |
| 53 | +Error envelope: |
| 54 | + |
| 55 | +```json |
| 56 | +{ "error": "forbidden", "code": "openbuilt.rbac.no_role" } |
| 57 | +``` |
| 58 | + |
| 59 | +## Admin bypass (audited) |
| 60 | + |
| 61 | +A user in the Nextcloud `admin` group can read any Application's |
| 62 | +manifest as an incident-response escape hatch. Every exercise of the |
| 63 | +bypass writes an audit-trail event with shape: |
| 64 | + |
| 65 | +``` |
| 66 | +event: rbac.admin_bypass |
| 67 | +actor: <admin uid> |
| 68 | +slug: <application slug> |
| 69 | +ts: <ISO 8601 timestamp> |
| 70 | +``` |
| 71 | + |
| 72 | +The bypass: |
| 73 | + |
| 74 | +- Runs **only** in `ApplicationsController::getManifest`. The frontend |
| 75 | + list filter does **not** include admins automatically. |
| 76 | +- Is logged at `info` level on the OpenBuilt PSR logger (where OR's |
| 77 | + audit-trail will pick it up via Nextcloud's logging pipeline). |
| 78 | +- Is narrow by design — sustained bypass volume from one admin is a |
| 79 | + signal to grant them an explicit role on the affected Applications. |
| 80 | + |
| 81 | +## List filter |
| 82 | + |
| 83 | +The OpenBuilt shell's Application list (`ApplicationEditor.vue`) |
| 84 | +filters out Applications on which the caller has no role |
| 85 | +(REQ-OBR-007). The filter runs client-side using |
| 86 | +`loadState('openbuilt', 'currentUserGroups')` (no DOM data-attribute |
| 87 | +reads — ADR-004 hard rule `gate-initial-state`). |
| 88 | + |
| 89 | +A future enhancement (DQ-1, see below) will move the filter to |
| 90 | +OR-side once `x-openregister-authorization` supports group-membership |
| 91 | +predicates. |
| 92 | + |
| 93 | +## Permissions modal |
| 94 | + |
| 95 | +Owner-only modal at `src/modals/PermissionsModal.vue` (per ADR-004 |
| 96 | +`gate-modal-isolation`). Three NcSelect group pickers, all carrying |
| 97 | +the required `input-label` prop (ADR-004 `gate-nc-input-labels`). |
| 98 | +Frontend rejects an `owners = []` save before sending — orphan-check |
| 99 | +guard per REQ-OBRBAC-005. |
| 100 | + |
| 101 | +## Transfer ownership |
| 102 | + |
| 103 | +A transfer is a single PUT to the Application's `permissions.owners` |
| 104 | +array. No dedicated endpoint, no `TransferOwnershipService`. OR's |
| 105 | +per-object audit trail records the before / after values |
| 106 | +automatically. |
| 107 | + |
| 108 | +## openbuilt.use navigation gate |
| 109 | + |
| 110 | +Nextcloud's per-app group restriction (Apps → OpenBuilt → Restrict to |
| 111 | +groups) gates visibility of the OpenBuilt top-bar entry. Default is |
| 112 | +no restriction (all authenticated users see it); admins can narrow it |
| 113 | +via the standard Apps panel or OCC: |
| 114 | + |
| 115 | +```bash |
| 116 | +occ app:enable openbuilt --groups digital-team |
| 117 | +``` |
| 118 | + |
| 119 | +This is coarse on/off visibility; the load-bearing security boundary |
| 120 | +is the per-Application `permissions` enforced server-side. |
| 121 | + |
| 122 | +## Operational caveats |
| 123 | + |
| 124 | +### Group renames |
| 125 | + |
| 126 | +If a Nextcloud admin renames a group, every Application whose |
| 127 | +`permissions` array references the old `gid` loses or gains rows |
| 128 | +without a permission-history audit event scoped to OpenBuilt. We do |
| 129 | +not (currently) ship a group-rename listener. If a rename breaks |
| 130 | +access: |
| 131 | + |
| 132 | +1. Edit the affected Application's `permissions` via the Permissions |
| 133 | + modal (as owner). |
| 134 | +2. Replace the stale group references with the new GID. |
| 135 | + |
| 136 | +Tracked as design.md OQ-2; revisit if customers report breakage. |
| 137 | + |
| 138 | +### Post-deploy "ACTION REQUIRED: re-grant access" |
| 139 | + |
| 140 | +After upgrading to this version every pre-existing Application is |
| 141 | +patched to `permissions.owners = ['admin']` so it is only readable by |
| 142 | +the `admin` group. Operators MUST re-grant access for non-admin teams |
| 143 | +via the Permissions modal: |
| 144 | + |
| 145 | +1. Sign in as an admin user. |
| 146 | +2. Navigate to OpenBuilt → Applications. |
| 147 | +3. For each Application that should be broadly accessible, open the |
| 148 | + Permissions modal and add the relevant Nextcloud groups to |
| 149 | + `owners`, `editors`, or `viewers`. |
| 150 | + |
| 151 | +The `hello-world` demo follows the same default (admin-only). Grant |
| 152 | +`viewers = ['users']` to restore broad visibility for the demo. |
| 153 | + |
| 154 | +## Deferred Questions |
| 155 | + |
| 156 | +- **DQ-1 — OR `x-openregister-authorization` group-membership predicate.** |
| 157 | + Investigated 2026-05-11; the current OpenRegister REST API does |
| 158 | + **not** expose a `groupIn` / `groupMember` predicate that can be |
| 159 | + parameterised by a pointer into the object's own `permissions` |
| 160 | + block. Until OR ships it, the frontend list filter remains the |
| 161 | + fallback path; the controller's 403 check is the load-bearing |
| 162 | + enforcement. Tracked as design.md OQ-1. |
| 163 | +- **DQ-2 — Group rename listener.** Punted; documented above. |
| 164 | +- **DQ-3 — Permission-history retention.** Defer to OR-register-level |
| 165 | + retention configuration (Conduction's compliance baseline pins this |
| 166 | + at the OR-register level). |
0 commit comments