acl.adoc 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 and Dashboards
  94. 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.
  95. * 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).
  96. * 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`.
  97. * `addToEveryAction` does **not** apply to dashboards. List the ACL on the dashboard explicitly when you want to restrict it.
  98. * Nested fieldsets and directories do not have their own `acls`; the root dashboard decision covers the whole page.
  99. 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.
  100. [source,yaml]
  101. .`config.yaml`
  102. ----
  103. defaultPermissions:
  104. view: false
  105. exec: false
  106. accessControlLists:
  107. - name: admins
  108. matchUsergroups:
  109. - admins
  110. permissions:
  111. view: true
  112. exec: true
  113. dashboards:
  114. - title: Public tools
  115. contents:
  116. - title: Welcome
  117. type: display
  118. - title: Services
  119. acls:
  120. - admins
  121. contents:
  122. - title: 'Status: running'
  123. type: display
  124. ----
  125. In the example above, guests can open **Public tools**, but **Services** is hidden from the side menu and cannot be loaded by deep link.
  126. 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].
  127. == ACLs and Entities
  128. 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.
  129. * If an entity type has **no** `acls` (or an empty list), it is unrestricted — same as root dashboards without ACLs.
  130. * 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`.
  131. * Only **view** applies to entity types. `exec`, `logs`, and `kill` remain action permissions.
  132. * `addToEveryAction` does **not** apply to entities. List the ACL on the entity definition explicitly when you want to restrict it.
  133. * Access is per **entity type**, not per instance. All instances of a restricted type are hidden together.
  134. * Entity types loaded at runtime without a matching `entities:` entry stay unrestricted for ACL purposes, but Diagnostics reports a configuration warning.
  135. * 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.
  136. Entity-related actions stay dual-gated:
  137. * Viewing the entity type requires entity `view`.
  138. * Seeing or running a related action still requires that action’s own ACLs (`view` / `exec`).
  139. * Search and dashboards do not show entity-bound actions for types the user cannot view, even if the action ACL alone would allow it.
  140. [source,yaml]
  141. .`config.yaml`
  142. ----
  143. defaultPermissions:
  144. view: false
  145. exec: false
  146. accessControlLists:
  147. - name: ops
  148. matchUsergroups:
  149. - ops
  150. permissions:
  151. view: true
  152. exec: true
  153. entities:
  154. - name: printers
  155. file: entities/printers.yaml
  156. - name: servers
  157. file: entities/servers.yaml
  158. acls:
  159. - ops
  160. actions:
  161. - title: Restart {{ name }}
  162. entity: servers
  163. shell: echo restart
  164. acls:
  165. - ops
  166. ----
  167. 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.
  168. == ACL Matching - usernames and usergroups.
  169. 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.
  170. [source,yaml]
  171. .`config.yaml`
  172. ```yaml
  173. accessControlLists:
  174. - name: admins
  175. matchUsergroups:
  176. - admins
  177. permissions:
  178. view: true
  179. exec: true
  180. - name: james
  181. matchUserNames:
  182. - james
  183. permissions:
  184. view: true
  185. exec: true
  186. ```
  187. == What's Next?
  188. Now that you understand ACLs, here's how to implement them:
  189. * xref:security/examples.adoc[View security examples] - See complete ACL configurations
  190. * xref:security/example_login_required.adoc[Example: Login required] - Configure login requirements
  191. * xref:security/example_some_admin_actions.adoc[Example: Admin-only actions] - Restrict actions to admins
  192. * xref:security/local.adoc[Set up local users] - Create users for ACL matching
  193. * xref:security/oauth2.adoc[Configure OAuth2] - Set up OAuth2 for user groups
  194. * xref:security/design_choices.adoc[Security design recommendations] - Learn best practices for ACL design