field-and-document-access-control.asciidoc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. [role="xpack"]
  2. [[field-and-document-access-control]]
  3. === Setting up field and document level security
  4. You can control access to data within a data stream or index by adding field and document level
  5. security permissions to a role.
  6. <<field-level-security,Field level security permissions>> restrict access to
  7. particular fields within a document.
  8. <<document-level-security,Document level security permissions>> restrict access
  9. to particular documents.
  10. NOTE: Document and field level security is currently meant to operate with
  11. read-only privileged accounts. Users with document and field level
  12. security enabled for a data stream or index should not perform write operations.
  13. A role can define both field and document level permissions on a per-index basis.
  14. A role that doesn’t specify field level permissions grants access to ALL fields.
  15. Similarly, a role that doesn't specify document level permissions grants access
  16. to ALL documents in the index.
  17. [IMPORTANT]
  18. =====================================================================
  19. When assigning users multiple roles, be careful that you don't inadvertently
  20. grant wider access than intended. Each user has a single set of field level and
  21. document level permissions per data stream or index. See <<multiple-roles-dls-fls>>.
  22. =====================================================================
  23. [[multiple-roles-dls-fls]]
  24. ==== Multiple roles with document and field level security
  25. A user can have many roles and each role can define different permissions on the
  26. same data stream or index. It is important to understand the behavior of document and field
  27. level security in this scenario.
  28. Document level security takes into account each role held by the user and
  29. combines each document level security query for a given data stream or index with an "OR". This
  30. means that only one of the role queries must match for a document to be returned.
  31. For example, if a role grants access to an index without document level security
  32. and another grants access with document level security, document level security
  33. is not applied; the user with both roles has access to all of the documents in
  34. the index.
  35. Field level security takes into account each role the user has and combines
  36. all of the fields listed into a single set for each data stream or index. For example, if a
  37. role grants access to an index without field level security and another grants
  38. access with field level security, field level security is not be applied for
  39. that index; the user with both roles has access to all of the fields in the
  40. index.
  41. For example, let's say `role_a` grants access to only the `address` field of the
  42. documents in `index1`; it doesn't specify any document restrictions. Conversely,
  43. `role_b` limits access to a subset of the documents in `index1`; it doesn't
  44. specify any field restrictions. If you assign a user both roles, `role_a` gives
  45. the user access to all documents and `role_b` gives the user access to all
  46. fields.
  47. If you need to restrict access to both documents and fields, consider splitting
  48. documents by index instead.
  49. include::role-templates.asciidoc[]
  50. include::set-security-user.asciidoc[]