overview.asciidoc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. [role="xpack"]
  2. [[authorization]]
  3. == Configuring role-based access control
  4. {security} introduces the concept of _authorization_ to {es}.
  5. Authorization is the process of determining whether the user behind an incoming
  6. request is allowed to execute it. This process takes place once a request is
  7. successfully authenticated and the user behind the request is identified.
  8. [[roles]]
  9. [float]
  10. === Roles, permissions, and privileges
  11. The authorization process revolves around the following 5 constructs:
  12. _Secured Resource_::
  13. A resource to which access is restricted. Indices/aliases, documents, fields,
  14. users and the {es} cluster itself are all examples of secured objects.
  15. _Privilege_::
  16. A named group representing one or more actions that a user may execute against a
  17. secured resource. Each secured resource has its own sets of available privileges.
  18. For example, `read` is an index privilege that represents all actions that enable
  19. reading the indexed/stored data. For a complete list of available privileges
  20. see <<security-privileges>>.
  21. _Permissions_::
  22. A set of one or more privileges against a secured resource. Permissions can
  23. easily be described in words, here are few examples:
  24. * `read` privilege on the `products` index
  25. * `manage` privilege on the cluster
  26. * `run_as` privilege on `john` user
  27. * `read` privilege on documents that match query X
  28. * `read` privilege on `credit_card` field
  29. _Role_::
  30. A named sets of permissions
  31. _User_::
  32. The authenticated user.
  33. A secure {es} cluster manages the privileges of users through _roles_.
  34. A role has a unique name and identifies a set of permissions that translate to
  35. privileges on resources. A user can be associated with an arbitrary number of
  36. roles. The total set of permissions that a user has is therefore defined by
  37. union of the permissions in all its roles.
  38. As an administrator, you will need to define the roles that you want to use,
  39. then assign users to the roles. These can be assigned to users in a number of
  40. ways depending on the realms by which the users are authenticated.
  41. [[built-in-roles]]
  42. === Built-in roles
  43. {security} applies a default role to all users, including
  44. <<anonymous-access, anonymous users>>. The default role enables users to access
  45. the authenticate endpoint, change their own passwords, and get information about
  46. themselves.
  47. {security} also provides a set of built-in roles you can explicitly assign
  48. to users. These roles have a fixed set of privileges and cannot be updated.
  49. [[built-in-roles-ingest-user]] `ingest_admin` ::
  50. Grants access to manage *all* index templates and *all* ingest pipeline configurations.
  51. +
  52. NOTE: This role does *not* provide the ability to create indices; those privileges
  53. must be defined in a separate role.
  54. [[built-in-roles-kibana-dashboard]] `kibana_dashboard_only_user` ::
  55. Grants access to the {kib} Dashboard and read-only permissions on the `.kibana`
  56. index. This role does not have access to editing tools in {kib}. For more
  57. information, see
  58. {kibana-ref}/xpack-dashboard-only-mode.html[{kib} Dashboard Only Mode].
  59. [[built-in-roles-kibana-system]] `kibana_system` ::
  60. Grants access necessary for the {kib} system user to read from and write to the
  61. {kib} indices, manage index templates, and check the availability of the {es} cluster.
  62. This role grants read access to the `.monitoring-*` indices and read and write access
  63. to the `.reporting-*` indices. For more information, see
  64. {kibana-ref}/using-kibana-with-security.html[Configuring Security in {kib}].
  65. +
  66. NOTE: This role should not be assigned to users as the granted permissions may
  67. change between releases.
  68. [[built-in-roles-kibana-user]] `kibana_user`::
  69. Grants the minimum privileges required for any user of {kib}. This role grants
  70. access to the {kib} indices and grants monitoring privileges for the cluster.
  71. [[built-in-roles-logstash-admin]] `logstash_admin` ::
  72. Grants access to the `.logstash*` indices for managing configurations.
  73. [[built-in-roles-logstash-system]] `logstash_system` ::
  74. Grants access necessary for the Logstash system user to send system-level data
  75. (such as monitoring) to {es}. For more information, see
  76. {logstash-ref}/ls-security.html[Configuring Security in Logstash].
  77. +
  78. NOTE: This role should not be assigned to users as the granted permissions may
  79. change between releases.
  80. +
  81. NOTE: This role does not provide access to the logstash indices and is not
  82. suitable for use within a Logstash pipeline.
  83. [[built-in-roles-beats-system]] `beats_system` ::
  84. Grants access necessary for the Beats system user to send system-level data
  85. (such as monitoring) to {es}.
  86. +
  87. NOTE: This role should not be assigned to users as the granted permissions may
  88. change between releases.
  89. +
  90. NOTE: This role does not provide access to the beats indices and is not
  91. suitable for writing beats output to {es}.
  92. [[built-in-roles-ml-admin]] `machine_learning_admin`::
  93. Grants `manage_ml` cluster privileges and read access to the `.ml-*` indices.
  94. [[built-in-roles-ml-user]] `machine_learning_user`::
  95. Grants the minimum privileges required to view {xpackml} configuration,
  96. status, and results. This role grants `monitor_ml` cluster privileges and
  97. read access to the `.ml-notifications` and `.ml-anomalies*` indices,
  98. which store {ml} results.
  99. [[built-in-roles-monitoring-user]] `monitoring_user`::
  100. Grants the minimum privileges required for any user of {monitoring} other than those
  101. required to use {kib}. This role grants access to the monitoring indices and grants
  102. privileges necessary for reading basic cluster information. Monitoring users should
  103. also be assigned the `kibana_user` role.
  104. [[built-in-roles-remote-monitoring-agent]] `remote_monitoring_agent`::
  105. Grants the minimum privileges required for a remote monitoring agent to write data
  106. into this cluster.
  107. [[built-in-roles-reporting-user]] `reporting_user`::
  108. Grants the specific privileges required for users of {reporting} other than those
  109. required to use {kib}. This role grants access to the reporting indices. Reporting
  110. users should also be assigned the `kibana_user` role and a role that grants them
  111. access to the data that will be used to generate reports with.
  112. [[built-in-roles-superuser]] `superuser`::
  113. Grants full access to the cluster, including all indices and data. A user with
  114. the `superuser` role can also manage users and roles and
  115. <<run-as-privilege, impersonate>> any other user in the system. Due to the
  116. permissive nature of this role, take extra care when assigning it to a user.
  117. [[built-in-roles-transport-client]] `transport_client`::
  118. Grants the privileges required to access the cluster through the Java Transport
  119. Client. The Java Transport Client fetches information about the nodes in the
  120. cluster using the _Node Liveness API_ and the _Cluster State API_ (when
  121. sniffing is enabled). Assign your users this role if they use the
  122. Transport Client.
  123. +
  124. NOTE: Using the Transport Client effectively means the users are granted access
  125. to the cluster state. This means users can view the metadata over all indices,
  126. index templates, mappings, node and basically everything about the cluster.
  127. However, this role does not grant permission to view the data in all indices.
  128. [[built-in-roles-watcher-admin]] `watcher_admin`::
  129. +
  130. Grants write access to the `.watches` index, read access to the watch history and
  131. the triggered watches index and allows to execute all watcher actions.
  132. [[built-in-roles-watcher-user]] `watcher_user`::
  133. +
  134. Grants read access to the `.watches` index, the get watch action and the watcher
  135. stats.
  136. [[defining-roles]]
  137. === Defining roles
  138. A role is defined by the following JSON structure:
  139. [source,js]
  140. -----
  141. {
  142. "run_as": [ ... ], <1>
  143. "cluster": [ ... ], <2>
  144. "indices": [ ... ] <3>
  145. }
  146. -----
  147. <1> A list of usernames the owners of this role can <<run-as-privilege, impersonate>>.
  148. <2> A list of cluster privileges. These privileges define the
  149. cluster level actions users with this role are able to execute. This field
  150. is optional (missing `cluster` privileges effectively mean no cluster level
  151. permissions).
  152. <3> A list of indices permissions entries. This field is optional (missing `indices`
  153. privileges effectively mean no index level permissions).
  154. [[valid-role-name]]
  155. NOTE: Role names must be at least 1 and no more than 1024 characters. They can
  156. contain alphanumeric characters (`a-z`, `A-Z`, `0-9`), spaces,
  157. punctuation, and printable symbols in the https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)[Basic Latin (ASCII) block].
  158. Leading or trailing whitespace is not allowed.
  159. The following describes the structure of an indices permissions entry:
  160. [source,js]
  161. -------
  162. {
  163. "names": [ ... ], <1>
  164. "privileges": [ ... ], <2>
  165. "field_security" : { ... }, <3>
  166. "query": "..." <4>
  167. }
  168. -------
  169. <1> A list of indices (or index name patterns) to which the permissions in this
  170. entry apply.
  171. <2> The index level privileges the owners of the role have on the associated
  172. indices (those indices that are specified in the `name` field)
  173. <3> Specification for document fields the owners of the role have read access to.
  174. See <<field-and-document-access-control>> for details.
  175. <4> A search query that defines the documents the owners of the role have read
  176. access to. A document within the associated indices must match this query
  177. in order for it to be accessible by the owners of the role.
  178. [TIP]
  179. ==============================================================================
  180. When specifying index names, you can use indices and aliases with their full
  181. names or regular expressions that refer to multiple indices.
  182. * Wildcard (default) - simple wildcard matching where `*` is a placeholder
  183. for zero or more characters, `?` is a placeholder for a single character
  184. and `\` may be used as an escape character.
  185. * Regular Expressions - A more powerful syntax for matching more complex
  186. patterns. This regular expression is based on Lucene's regexp automaton
  187. syntax. To enable this syntax, it must be wrapped within a pair of
  188. forward slashes (`/`). Any pattern starting with `/` and not ending with
  189. `/` is considered to be malformed.
  190. .Example Regular Expressions
  191. [source,yaml]
  192. ------------------------------------------------------------------------------
  193. "foo-bar": # match the literal `foo-bar`
  194. "foo-*": # match anything beginning with "foo-"
  195. "logstash-201?-*": # ? matches any one character
  196. "/.*-201[0-9]-.*/": # use a regex to match anything containing 2010-2019
  197. "/foo": # syntax error - missing final /
  198. ------------------------------------------------------------------------------
  199. ==============================================================================
  200. The following snippet shows an example definition of a `clicks_admin` role:
  201. [source,js]
  202. -----------
  203. {
  204. "run_as": [ "clicks_watcher_1" ]
  205. "cluster": [ "monitor" ],
  206. "indices": [
  207. {
  208. "names": [ "events-*" ],
  209. "privileges": [ "read" ],
  210. "field_security" : {
  211. "grant" : [ "category", "@timestamp", "message" ]
  212. },
  213. "query": "{\"match\": {\"category\": \"click\"}}"
  214. }
  215. ]
  216. }
  217. -----------
  218. Based on the above definition, users owning the `clicks_admin` role can:
  219. * Impersonate the `clicks_watcher_1` user and execute requests on its behalf.
  220. * Monitor the {es} cluster
  221. * Read data from all indices prefixed with `events-`
  222. * Within these indices, only read the events of the `click` category
  223. * Within these document, only read the `category`, `@timestamp` and `message`
  224. fields.
  225. TIP: For a complete list of available <<security-privileges, cluster and indices privileges>>
  226. There are two available mechanisms to define roles: using the _Role Management APIs_
  227. or in local files on the {es} nodes. {security} also supports implementing
  228. custom roles providers. If you need to integrate with another system to retrieve
  229. user roles, you can build a custom roles provider plugin. For more information,
  230. see <<custom-roles-provider, Custom Roles Provider Extension>>.
  231. [float]
  232. [[roles-management-ui]]
  233. === Role management UI
  234. {security} enables you to easily manage users and roles from within {kib}. To
  235. manage roles, log in to {kib} and go to *Management / Elasticsearch / Roles*.
  236. [float]
  237. [[roles-management-api]]
  238. === Role management API
  239. The _Role Management APIs_ enable you to add, update, remove and retrieve roles
  240. dynamically. When you use the APIs to manage roles in the `native` realm, the
  241. roles are stored in an internal {es} index. For more information and examples,
  242. see {ref}/security-api-roles.html[Role Management APIs].
  243. [float]
  244. [[roles-management-file]]
  245. === File-based role management
  246. Apart from the _Role Management APIs_, roles can also be defined in local
  247. `roles.yml` file located in `CONFIG_DIR`. This is a YAML file where each
  248. role definition is keyed by its name.
  249. [IMPORTANT]
  250. ==============================
  251. If the same role name is used in the `roles.yml` file and through the
  252. _Role Management APIs_, the role found in the file will be used.
  253. ==============================
  254. While the _Role Management APIs_ is the preferred mechanism to define roles,
  255. using the `roles.yml` file becomes useful if you want to define fixed roles that
  256. no one (beside an administrator having physical access to the {es} nodes)
  257. would be able to change.
  258. [IMPORTANT]
  259. ==============================
  260. The `roles.yml` file is managed locally by the node and is not globally by the
  261. cluster. This means that with a typical multi-node cluster, the exact same
  262. changes need to be applied on each and every node in the cluster.
  263. A safer approach would be to apply the change on one of the nodes and have the
  264. `roles.yml` distributed/copied to all other nodes in the cluster (either
  265. manually or using a configuration management system such as Puppet or Chef).
  266. ==============================
  267. The following snippet shows an example of the `roles.yml` file configuration:
  268. [source,yaml]
  269. -----------------------------------
  270. click_admins:
  271. run_as: [ 'clicks_watcher_1' ]
  272. cluster: [ 'monitor' ]
  273. indices:
  274. - names: [ 'events-*' ]
  275. privileges: [ 'read' ]
  276. field_security:
  277. grant: ['category', '@timestamp', 'message' ]
  278. query: '{"match": {"category": "click"}}'
  279. -----------------------------------
  280. {security} continuously monitors the `roles.yml` file and automatically picks
  281. up and applies any changes to it.
  282. include::alias-privileges.asciidoc[]
  283. include::mapping-roles.asciidoc[]
  284. include::field-and-document-access-control.asciidoc[]
  285. include::run-as-privilege.asciidoc[]
  286. include::custom-roles-provider.asciidoc[]