Elasticsearch:私有用户文档

Elasticsearch: private user documents

我们正在考虑使用 Elasticsearch for our webservice. Since ES operates at a low level, for authentication and authorization there has to be some layer above it. I see Shields,它显然可以在基于角色的级别上控制 useradmindeveloper 等可以做什么在搜索索引中。然而,我找不到的是如何在用户级别控制数据访问:每个用户都必须有权访问所有 public 文档以及 his/her 私人文档。

是否有处理此问题的 ES plugin/paradigm?

Shield 的想法是在索引文档中有一个用户组:

{
  "text":"Document 1 is public",
  "user_group": ["public"]
}
{
  "text":"Document 2 is restricted",
  "user_group": ["restricted"]
}

然后您可以强制为指定的用户组应用过滤器

# For users in group public
{"term" : {"user_group" : "public"}}

# For users in group restricted (can see public as well)
{"terms" : {"user_group" : ["public","restricted"]}}

Elasticsearch 2.0 / Shield 2.0 已改进 Document level security. Prior to that 您被迫使用索引别名。

SearchGuard(Shield 替代方案)的行为类似于 Shield:dlsfilter 将用户组与过滤器绑定。

在这两种情况下,将用户绑定到文档可能是一项困难(不可能?)的任务,因为一切都基于用户 groups/roles,而不是个人用户。不过,您可以为每个用户生成一个特定的组。每次添加用户时,它都会强制您添加一个用户组,并配置其特定的授权。