Document-level security or field-level security

Now that we know how to create a new user, create a new role, and assign roles to a user, let's explore how security can be imposed on documents and fields for a given index/document.

The sample data that we imported previously, at the beginning of this chapter, contained two indexes: employee and department. Let's use these indexes and understand the document-level security with two use cases.

Use case 1: When a user searches for employee details, the user should not be able to find the salary/address details contained in the documents belonging to the employee index.

This is where field-level security helps. Let's create a new role (employee_read) with read index privileges on the employee ...

Get Learning Elastic Stack 7.0 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.