collections - DocumentDB 对集合的权限

标签 collections user-permissions azure-cosmosdb

在我的设计中,我想使用 DocumentDB 作为 Multi-Tenancy SAAS 应用程序的后端。 由于每个租户的数据可能 > 10GB,我想使用每个租户模型的集合。 需求是如何确保应用程序中的数据隔离。租户 1 不应该能够在代码中和 Azure 门户上查看租户 2 的数据。如何设置相同集合的权限?

最佳答案

I want to use a collection per tenant model

您可以尝试create DocumentDB users for each tenant and associate the permissions with the user控制用户对集合/文档的访问。

string documentCollectionlink = UriFactory.CreateDocumentCollectionUri("{database id}", "{collection id}").ToString();

string databaseLink = UriFactory.CreateDatabaseUri("{database id}").ToString();

Permission docPermission = new Permission
{
    PermissionMode = PermissionMode.All,
    ResourceLink = documentCollectionlink,
    Id = "tenant1perm"
};

await client.CreateUserAsync(databaseLink, new User { Id = "tuser" });

docPermission = await client.CreatePermissionAsync(UriFactory.CreateUserUri("{database id}", "tuser"), docPermission);

然后您可以读取DocumentDB用户的权限并根据租户获取访问 token ,并使用 token 创建一个新的DocumentClient实例来操作资源。

var qclient = new DocumentClient(new Uri(EndpointUri), token);

关于collections - DocumentDB 对集合的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43597690/

相关文章:

java - Java Collections API 上的依赖注入(inject)

ios - 在测试期间绕过或模拟 Apple 权限对话框

c# - Azure DocumentDB 偶尔抛出 SocketException/GoneException

azure - Cosmos dB 正在阻止更新插入请求,即使它具有所需的 RBAC 角色

azure - DocumentDB 使用 EnableCrossPartitionQuery 设置 True 对特定集合进行搜索?

collections - MVC 6 标签助手和 foreach

c# - 如何在 .NET 中创建值类型集合?

c# - C#中涉及集合、泛型和接口(interface)的设计问题

java - 有没有办法确保请求来自受信任的 UI 应用程序?

java - 在 webapp 中删除文件时 Tomcat 8.5.42 权限被拒绝