Skip to content

Commit 5929a31

Browse files
committed
update read perm
1 parent 3a8cef4 commit 5929a31

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

articles/cosmos-db/secure-access-to-data.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,15 @@ user.CreatePermissionAsync(
129129
resourcePartitionKey: new PartitionKey("012345")));
130130
```
131131

132-
### Code sample to read permissions for user
132+
### Code sample to read permission for user
133133

134-
To easily obtain all permission resources associated with a particular user, Cosmos DB makes available a permission feed for each user object. The following code snippet shows how to retrieve the permission associated with the user created above, construct a permission list, and instantiate a new CosmosClient on behalf of the user.
134+
The following code snippet shows how to retrieve the permission associated with the user created above and instantiate a new CosmosClient on behalf of the user, scoped to a single partition key.
135135

136136
```csharp
137-
//Read a permission feed.
138-
List<PermissionProperties> user1Permissions = new List<PermissionProperties>();
139-
FeedIterator<PermissionProperties> feedIterator = user1.GetPermissionQueryIterator<PermissionProperties>();
140-
while (feedIterator.HasMoreResults)
141-
{
142-
FeedResponse<PermissionProperties> permissions = await feedIterator.ReadNextAsync();
143-
user1Permissions.AddRange(permissions);
144-
}
145-
146-
CosmosClient client = new CosmosClient(accountEndpoint: "MyEndpoint", authKeyOrResourceToken: user1Permissions.ToString());
137+
//Read a permission, create user client session.
138+
PermissionProperties permissionProperties = await user.GetPermission("permissionUser1Orders")
139+
140+
CosmosClient client = new CosmosClient(accountEndpoint: "MyEndpoint", authKeyOrResourceToken: permissionProperties.Token);
147141
```
148142

149143
## Add users and assign roles

0 commit comments

Comments
 (0)