多租户 Algolia 指数
Multi-tenant Algolia index
我想通过我的用户的数据为他们提供全文搜索 - 并确保他们只能访问他们拥有的数据。是否有任何模式允许在 Algolia 上执行此操作? None 我考虑过的解决方案似乎很合适,所以我想知道我是否忽略了其他一些选择。
我们可以将每个用户的数据托管在一个单独的 Algolia 应用程序中,这样每个 API 密钥只能访问相关数据,但这很快就会变得难以承受,因为许多人会达到 10000 条记录的限制.
我们可以将每个用户的数据托管在单独的索引中并使用团队索引限制,但似乎没有 API 来管理这些数据,而且无论如何都需要为每个客户创建一个 Algolia 帐户,这似乎是对服务的滥用(例如,我们可以在我们的域名中生成电子邮件地址)。
最后,我们可以使用某些 userId 过滤查询以仅检索相关数据,但这并不安全,因为有人可以在没有过滤器的情况下使用 apikey 查询 algolia。
我们可以代理 algolia 调用来注入过滤器和 api 键——但性能损失可能会很高。
还有其他建议吗?谢谢!
我从 Algolia 的 rayrutjes 那里得到了很好的回答,所以我把它粘贴在这里以防万一:
The best approach for your use case is to use what we call generated API keys. Here is the documentation for the JavaScript client: https://www.algolia.com/doc/api-client/javascript/api-keys/#generate-key
The usage is fairly simple, you generate an API key on the fly based on your search API key + some additional query params.
The resulting API key can be used like a standard search API key, with the difference that it can be scoped on a given set of parameters.
Note that the generation of such a scoped API key does not require an actual call to the API.
Also be sure to generate those scoped API keys in the backend as in that case you don't want to expose the search API key you use for their generation.
我想通过我的用户的数据为他们提供全文搜索 - 并确保他们只能访问他们拥有的数据。是否有任何模式允许在 Algolia 上执行此操作? None 我考虑过的解决方案似乎很合适,所以我想知道我是否忽略了其他一些选择。
我们可以将每个用户的数据托管在一个单独的 Algolia 应用程序中,这样每个 API 密钥只能访问相关数据,但这很快就会变得难以承受,因为许多人会达到 10000 条记录的限制.
我们可以将每个用户的数据托管在单独的索引中并使用团队索引限制,但似乎没有 API 来管理这些数据,而且无论如何都需要为每个客户创建一个 Algolia 帐户,这似乎是对服务的滥用(例如,我们可以在我们的域名中生成电子邮件地址)。
最后,我们可以使用某些 userId 过滤查询以仅检索相关数据,但这并不安全,因为有人可以在没有过滤器的情况下使用 apikey 查询 algolia。 我们可以代理 algolia 调用来注入过滤器和 api 键——但性能损失可能会很高。
还有其他建议吗?谢谢!
我从 Algolia 的 rayrutjes 那里得到了很好的回答,所以我把它粘贴在这里以防万一:
The best approach for your use case is to use what we call generated API keys. Here is the documentation for the JavaScript client: https://www.algolia.com/doc/api-client/javascript/api-keys/#generate-key
The usage is fairly simple, you generate an API key on the fly based on your search API key + some additional query params.
The resulting API key can be used like a standard search API key, with the difference that it can be scoped on a given set of parameters.
Note that the generation of such a scoped API key does not require an actual call to the API.
Also be sure to generate those scoped API keys in the backend as in that case you don't want to expose the search API key you use for their generation.