- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Description
Existing Index privilege names fail to convey the meaning properly and a few like create have their own unexpected semantics (it allows indexing document only via Index API). Since we are adding a new create_doc privilege, we want to take this opportunity to clean up the existing privileges and either provide replica privilege if the semantics are correct or provide an alternative that is semantically correct. Also, the naming can be explicit about the operation that is performed.
Following are the existing Index privileges related to documents indexing lifecycle:
create: The privilege allows for indexing documents but only via Index/Bulk API but no update via Update API. It also allows update mapping actions. This one does not prevent document updates when using Index APIs.
index: The privilege allows indexing documents via Index/Bulk API, also allows for update action and mapping actions.
delete: The privilege allows deletion of documents
write: This privilege allows all write operations (index, deletes, updates) along with update mapping actions.
read: Read-only access to actions like count, explain, get, mget, get indexed scripts, etc.
Following are the proposed new Index privileges:
-  create_doc: This one is with changed semantics, allowing only indexing new documents but no updates. Plus this one removes the unexpected semantics of restricting this operation via Index API only. This will allow indexing new documents via Index/Bulk API and allows update mapping action. Add 'create_doc' index privilege #45806
-  index_doc: This will be similar toindexprivilege.
-  delete_doc: This will be similar todeleteprivilege.
-  write_doc: This will be similar towriteprivilege.
-  read_doc: This will be similar toreadprivilege.
| Privilege ▼ Actions ► | Index new document | Update document | Delete document | Update mapping | Read actions (search, count etc.) | 
|---|---|---|---|---|---|
| create_doc | Allow | Deny | Deny | Allow | Deny | 
| index_doc | Allow | Allow | Deny | Allow | Deny | 
| delete_doc | Deny | Deny | Allow | Deny | Deny | 
| write_doc | Allow | Allow | Allow | Allow | Deny | 
| read_doc | Deny | Deny | Deny | Deny | Allow | 
Additional considerations:
- 
During the discussion of naming of create_docwe had a proposal to split theindexprivilege into:
 index_doc: Privilege to index documents. It also includescreate_docprivilege.
 I think this would be a breaking change but adding it to discuss this.
 update_doc: Privilege to update documents. Not sure how this would work, for example, an upsert case allows update of an existing document or index new document if it does not exist.
 If we want to support this splitting ofindexprivilege into two with above semantics then it would be a breaking change and might not be possible other than to modify the index engine to handle it.
- 
read_docprivilege: We could consider some more granular approach. I see an enhancement request: https://github.com/elastic/enhancements/issues/5470 which talks about providing a way to restrict users to certain search types?
Proposed path forward:
- When do we introduce these new Index privilege changes and deprecate old?
 Introduce these new index privileges in v8.0.0 and start logging deprecated warnings.
- When do we remove the usage of old Index privileges? v9.0.0
- Can we provide some migration tool/upgrade assistance?
 We have an issue opened to discuss this possibility to enhance the deprecation info API Allow Deprecation Info API to check for deprecated security configuration #47714
 We could consider providing a tool for migration but it might not be possible to migrate all the role descriptors using the deprecated privilege names.
 The problem exists for the privilege which does not have the exact alternative or would change the behavior if we use the alternative, eg.createwith possible alternativecreate_doc.- There are different places where the index privilege is used during role definition:
- file (roles.yml).(If an alternative exists for the privilege we can update the role definitions in the file. This option is less likely as we would want to avoid file mutations)
- built-in roles (If an alternative exists for the privilege we can update the role definitions)
- role definitions indexed in security index via API (If an alternative exists for the privilege we can update the role definitions)
- dynamic role definitions - custom roles provider extension (This is a custom security extension and will require users to update the extension).
 
- file (
 
- There are different places where the index privilege is used during role definition:
- Do we want to consider the additional changes like splitting the indexprivilege or more granular privileges forread?
This issue exists to gather feedback on the path forward and comments around introducing/removing/updating index privileges in relation to indexing documents.