4
0

acl.adoc 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. [#acls]
  2. = Access Control Lists
  3. OliveTin uses Access Control Lists (ACLs) to implement it's security model, which allows you to have fine-grained control over indivividual actions or groups of actions. This can be used to implement role based access control (RBAC), or other security models that you may need.
  4. ACLs are built up of the following set of rules;
  5. * `name` - The name of the ACL. This is used to identify the ACL in the configuration file.
  6. * `matchUsergroups` - A list of usergroups that this ACL applies to. This is used to match users that are in the specified usergroup.
  7. * `matchUserNames` - A list of usernames that this ACL applies to. This is used to match users that are in the specified usergroup.
  8. * `permissions` - A set of permissions which are used with **actions**. eg: `view`, `exec`, `logs`, etc.
  9. ** `addToEveryAction` - A boolean value that indicates if this ACL should be added to every action. This is useful if you want to apply the same ACL to all actions, without having to manually add it to each action.
  10. * `policy` - A policy is a set of rules that affect the **whole of OliveTin**.
  11. == ACLs and Policies (global)
  12. [mermaid, "sample", png]
  13. ....
  14. graph TD
  15. A[ACL] --> B[Policy]
  16. A -->|User/UserGroup| C[User/UserGroup]
  17. ....
  18. **Policies** are a set of rules that apply to the whole of OliveTin ("global"), and not just to individual actions (like permissions are).
  19. The **defaultPolicy** is special, in that all values are set to true by default. This means that if you do not set a `defaultPolicy`, then all policies will be set to `true` by default. This is effectively what the `defaultPolicy` is set to;
  20. [source,yaml]
  21. ----
  22. defaultPolicy:
  23. showDiagnostics: true
  24. showLogList: true
  25. ----
  26. You can override defaults using an ACL, like this;
  27. [source,yaml]
  28. ----
  29. accessControlLists:
  30. - name: admins
  31. matchUsergroups:
  32. - admins
  33. policy:
  34. showDiagnostics: true
  35. showLogList: true
  36. defaultPolicy:
  37. showDiagnostics: false
  38. showLogList: false
  39. ----
  40. == ACLs and Permissions (for Actions)
  41. [mermaid, "sample", png]
  42. ....
  43. graph TD
  44. A[Action] -->|ACL| B[ACL]
  45. B -->|User/UserGroup| C[User/UserGroup]
  46. B -->|Permissions| D[Permissions]
  47. ....
  48. An action always starts with `defaultPermissions` (see below), and then then have one or more ACLs applied to it. This means that you can for example have an action that is only available to a certain group of users, or only to a single user.
  49. Let's say you have a user `james` and a usergroup `admins`. You can then create an ACL that only allows `james` and users in the `admins` group to view and execute an action.
  50. You can specify default permissions for all actions by changing the `defaultPermissions` like this;
  51. [source,yaml]
  52. .`config.yaml`
  53. ----
  54. defaultPermissions:
  55. view: false
  56. exec: false
  57. logs: true
  58. ----
  59. In the example above, all users will start off with the permissions to only see action logs - but will not be able to view or execute actions.
  60. It is then possible to add an "admins" ACL on top of every action. In the example below, we define one extra ACL called "admins", which matches any users with the usergroup also called "admins". This ACL will then be applied to all actions, and will allow users in the "admins" usergroup to view and execute the action.
  61. [source,yaml]
  62. .`config.yaml`
  63. ----
  64. defaultPermissions:
  65. view: false
  66. exec: false
  67. accessControlLists:
  68. - name: admins
  69. matchUsergroups:
  70. - admins
  71. permissions:
  72. view: true
  73. exec: true
  74. actions:
  75. - title: Shutdown Reactor
  76. acls:
  77. - admins
  78. ----
  79. === Add an ACL to every action
  80. Sometimes you want to define an ACL that applies to all actions. It can be tedious and error prone to manually add the ACL under the "acls" list for every action, if you have several actions. Instead, there is a shortcut to add an ACL to all actions - `addToEveryAction: true`.
  81. [source,yaml]
  82. .`config.yaml`
  83. ```yaml
  84. accessControlLists:
  85. - name: admins
  86. matchUsergroups:
  87. - admins
  88. permissions:
  89. view: true
  90. exec: true
  91. addToEveryAction: true
  92. ```
  93. [#acls-for-triggers]
  94. === ACLs for triggers (startup, cron, webhooks)
  95. Actions started by a trigger, such as `execOnStartup`, `execOnCron`, `execOnCalendarFile`, `execOnFileCreatedInDir` or `execOnWebhook`, run as a user in the `system` usergroup, and the same ACL checks apply. If you set `defaultPermissions.exec` to `false`, give the `system` usergroup `exec`, or your triggered actions will be blocked:
  96. [source,yaml]
  97. .`config.yaml`
  98. ```yaml
  99. accessControlLists:
  100. - name: system_triggers
  101. matchUsergroups:
  102. - system
  103. permissions:
  104. exec: true
  105. addToEveryAction: true
  106. ```
  107. Triggers only start the actions that you configured them on, so adding this ACL to every action does not let anyone else run those actions.
  108. == ACLs and Dashboards
  109. Root dashboards can also list `acls`. This controls whether the **whole dashboard page** is visible (including `display` widgets and entity fieldsets), not just action buttons.
  110. * If a dashboard has **no** `acls` (or an empty list), it is unrestricted — anyone can see it in the side menu (subject to the usual “empty dashboard” hiding).
  111. * If a dashboard lists one or more `acls`, access uses the same allow-list rules as actions: a matching ACL that grants `view`, otherwise `defaultPermissions.view`.
  112. * `addToEveryAction` does **not** apply to dashboards. List the ACL on the dashboard explicitly when you want to restrict it.
  113. * Nested fieldsets and directories do not have their own `acls`; the root dashboard decision covers the whole page.
  114. Action `acls` still control individual buttons. Use dashboard `acls` when you need to hide a page that contains status or other non-action content from some users.
  115. [source,yaml]
  116. .`config.yaml`
  117. ----
  118. defaultPermissions:
  119. view: false
  120. exec: false
  121. accessControlLists:
  122. - name: admins
  123. matchUsergroups:
  124. - admins
  125. permissions:
  126. view: true
  127. exec: true
  128. dashboards:
  129. - title: Public tools
  130. contents:
  131. - title: Welcome
  132. type: display
  133. - title: Services
  134. acls:
  135. - admins
  136. contents:
  137. - title: 'Status: running'
  138. type: display
  139. ----
  140. In the example above, guests can open **Public tools**, but **Services** is hidden from the side menu and cannot be loaded by deep link.
  141. NOTE: Action `hidden: true` is not part of the ACL model. It only controls dashboard listing. Restrict who can see or run actions with the permissions above; see xref:action_customization/hidden.adoc[Hidden actions].
  142. == ACLs and Entities
  143. Entity types (entries under `entities` in configuration) can also list `acls`. This controls whether users may see that type in the Entities page, entity details, search hints, dashboard entity fieldsets, and entity-driven argument choices.
  144. * If an entity type has **no** `acls` (or an empty list), it is unrestricted — same as root dashboards without ACLs.
  145. * If an entity type lists one or more `acls`, access uses the same allow-list rules as actions and dashboards: a matching ACL that grants `view`, otherwise `defaultPermissions.view`.
  146. * Only **view** applies to entity types. `exec`, `logs`, and `kill` remain action permissions.
  147. * `addToEveryAction` does **not** apply to entities. List the ACL on the entity definition explicitly when you want to restrict it.
  148. * Access is per **entity type**, not per instance. All instances of a restricted type are hidden together.
  149. * Entity types loaded at runtime without a matching `entities:` entry stay unrestricted for ACL purposes, but Diagnostics reports a configuration warning.
  150. * Arguments that expand choices from an entity type must define **exactly one** choice template. Combining `entity` with multiple static choices is invalid and rejected on startup.
  151. Entity-related actions stay dual-gated:
  152. * Viewing the entity type requires entity `view`.
  153. * Seeing or running a related action still requires that action’s own ACLs (`view` / `exec`).
  154. * Search and dashboards do not show entity-bound actions for types the user cannot view, even if the action ACL alone would allow it.
  155. [source,yaml]
  156. .`config.yaml`
  157. ----
  158. defaultPermissions:
  159. view: false
  160. exec: false
  161. accessControlLists:
  162. - name: ops
  163. matchUsergroups:
  164. - ops
  165. permissions:
  166. view: true
  167. exec: true
  168. entities:
  169. - name: printers
  170. file: entities/printers.yaml
  171. - name: servers
  172. file: entities/servers.yaml
  173. acls:
  174. - ops
  175. actions:
  176. - title: Restart {{ name }}
  177. entity: servers
  178. shell: echo restart
  179. acls:
  180. - ops
  181. ----
  182. In the example above, guests can see **printers** (unrestricted) but not **servers**. Users in the `ops` group can see **servers** and the Restart actions bound to them.
  183. == ACL Matching - usernames and usergroups.
  184. You can match users based on their usergroup which is the most common, but it is also possible to match based on the user's username.
  185. [source,yaml]
  186. .`config.yaml`
  187. ```yaml
  188. accessControlLists:
  189. - name: admins
  190. matchUsergroups:
  191. - admins
  192. permissions:
  193. view: true
  194. exec: true
  195. - name: james
  196. matchUserNames:
  197. - james
  198. permissions:
  199. view: true
  200. exec: true
  201. ```
  202. == What's Next?
  203. Now that you understand ACLs, here's how to implement them:
  204. * xref:security/examples.adoc[View security examples] - See complete ACL configurations
  205. * xref:security/example_login_required.adoc[Example: Login required] - Configure login requirements
  206. * xref:security/example_some_admin_actions.adoc[Example: Admin-only actions] - Restrict actions to admins
  207. * xref:security/local.adoc[Set up local users] - Create users for ACL matching
  208. * xref:security/oauth2.adoc[Configure OAuth2] - Set up OAuth2 for user groups
  209. * xref:security/design_choices.adoc[Security design recommendations] - Learn best practices for ACL design