Elastic search per user access control to document

风流意气都作罢 提交于 2020-01-06 05:35:11

问题


I'm using ElasticSearch 7.1.1 as a full-text search engine. At the beginning all the documents are accessible to every user. I want to give users the possibility to edit documents. The modified version of the document will be accessible only to the editor and everyone else will only be able to see the default document.

To do this I will add two array to every document:

  • An array of users excluded from seeing the doc
  • An array with the only user that can see the this doc

Every time someone edit a document I will:

  • Add to the excluded users list the user that made the edit
  • Create document containing the edit available only to that user.

This way in the index I'll have three types of documents:

  1. Documents accessible to everyone
  2. Documents accessible to everyone except some users
  3. Documents accessible only to a specific users

I use ElasticSearch not only to fetch documents but also to calculate live aggregations (e.g. sums of some field) so query-time I will be able to fetch user specific documents.

I don't expect a lot of edits, less than 1% of the total documents.

Is there a smarter, and less query intensive, way to obtain the same results?


回答1:


You could implement a document level security.

With that you can define roles that restrict the read-access to certain documents that match a query (e.g. you could use the id of the document).

So instead of updating the documents each time via your proposed array-solution, you would instead update the role respectively granting the roles to the particular users. This would of course require that every user has an elasticsearch user.

This feature is the only workaround to fulfill your requirements that Elasticsearch brings on the table "out of the box" as far as I know.

I hope I could help you.



来源:https://stackoverflow.com/questions/57976234/elastic-search-per-user-access-control-to-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!