Skip to content

Commit 13ac21f

Browse files
committed
reverted security-trimming-aad article, we're archiving it instead
1 parent 5470df1 commit 13ac21f

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

articles/search/TOC.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,9 @@
466466
href: search-security-get-encryption-keys.md
467467
- name: Document-level security
468468
items:
469-
- name: Security filters
469+
- name: Security filter pattern
470470
href: search-security-trimming-for-azure-search.md
471-
- name: Security filters with Microsoft Entra ID
471+
- name: Set up a security filter using Microsoft Entra ID
472472
href: search-security-trimming-for-azure-search-with-aad.md
473473
- name: Development
474474
items:

articles/search/search-security-trimming-for-azure-search.md

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Security filters for trimming results
2+
title: Security filter pattern
33
titleSuffix: Azure AI Search
44
description: Learn how to implement security privileges at the document level for Azure AI Search search results, using security filters and user identities.
55

@@ -10,48 +10,50 @@ ms.service: cognitive-search
1010
ms.custom:
1111
- ignite-2023
1212
ms.topic: how-to
13-
ms.date: 01/10/2024
13+
ms.date: 06/20/2024
1414
---
1515

1616
# Security filters for trimming results in Azure AI Search
1717

18-
Azure AI Search doesn't provide document-level permissions and can't vary search results from within the same index by user permissions. As a workaround, you can create a filter that trims search results based on a string containing a group or user identity.
18+
Azure AI Search doesn't provide native document-level permissions and can't vary search results from within the same index by user permissions. As a workaround, you can create a filter that trims search results based on a string containing a group or user identity.
1919

20-
This article describes a pattern for security filtering that includes following steps:
20+
This article describes a pattern for security filtering having the following steps:
2121

2222
> [!div class="checklist"]
2323
> * Assemble source documents with the required content
2424
> * Create a field for the principal identifiers
2525
> * Push the documents to the search index for indexing
2626
> * Query the index with the `search.in` filter function
2727
28+
It concludes with links to demos and examples that provide hands-on learning. We recommend reviewing this article first to understand the pattern.
29+
2830
## About the security filter pattern
2931

30-
Although Azure AI Search doesn't integrate with security subsystems for access to content within an index, many customers who have document-level security requirements have found that filters can meet their needs.
32+
Although Azure AI Search doesn't integrate with security subsystems for access to content within an index, many customers who have document-level security requirements find that filters can meet their needs.
3133

32-
In Azure AI Search, a security filter is a regular OData filter that includes or excludes a search result based on a matching value, except that in a security filter, the criteria is a string consisting of a security principal. There's no authentication or authorization through the security principal. The principal is just a string, used in a filter expression, to include or exclude a document from the search results.
34+
In Azure AI Search, a security filter is a regular OData filter that includes or excludes a search result based on a string consisting of a security principal. There's no authentication or authorization through the security principal. The principal is just a string, used in a filter expression, to include or exclude a document from the search results.
3335

3436
There are several ways to achieve security filtering. One way is through a complicated disjunction of equality expressions: for example, `Id eq 'id1' or Id eq 'id2'`, and so forth. This approach is error-prone, difficult to maintain, and in cases where the list contains hundreds or thousands of values, slows down query response time by many seconds.
3537

3638
A better solution is using the `search.in` function for security filters, as described in this article. If you use `search.in(Id, 'id1, id2, ...')` instead of an equality expression, you can expect subsecond response times.
3739

3840
## Prerequisites
3941

40-
* The field containing group or user identity must be a string with the filterable attribute. It should be a collection. It shouldn't allow nulls.
42+
* A string field containing a group or user identity. It must have the filterable attribute. It should be a collection. It shouldn't allow nulls.
4143

42-
* Other fields in the same document should provide the content that's accessible to that group or user. In the following JSON documents, the "security_id" fields contain identities used in a security filter, and the name, salary, and marital status will be included if the identity of the caller matches the "security_id" of the document.
44+
* Other fields in the same document should provide the content that's accessible to that group or user. In the following JSON documents, the "security_id" fields contain identities used in a security filter, and the name, salary, and marital status are included if the identity of the caller matches the "security_id" of the document.
4345

4446
```json
4547
{
4648
"Employee-1": {
47-
"id": "100-1000-10-1-10000-1",
49+
"employee_id": "100-1000-10-1-10000-1",
4850
"name": "Abram",
4951
"salary": 75000,
5052
"married": true,
5153
"security_id": "10011"
5254
},
5355
"Employee-2": {
54-
"id": "200-2000-20-2-20000-2",
56+
"employee_id": "200-2000-20-2-20000-2",
5557
"name": "Adams",
5658
"salary": 75000,
5759
"married": true,
@@ -60,18 +62,19 @@ A better solution is using the `search.in` function for security filters, as des
6062
}
6163
```
6264

63-
>[!NOTE]
64-
> The process of retrieving the principal identifiers and injecting those strings into source documents that can be indexed by Azure AI Search isn't covered in this article. Refer to the documentation of your identity service provider for help with obtaining identifiers.
65-
6665
## Create security field
6766

68-
In the search index, within the field collection, you need one field that contains the group or user identity, similar to the fictitious "security_id" field in the previous example.
67+
In the search index, within the fields collection, you need one field that contains the group or user identity, similar to the fictitious "security_id" field in the previous example.
68+
69+
1. Add a security field as a `Collection(Edm.String)`. Make sure it has a `filterable` attribute set to `true`. In this example, the security field is `group_ids`. It's populated with the string `["group_id1, group_id2"]`.
70+
71+
1. Set the field's `retrievable` attribute to `false` so that it isn't returned as part of the search request.
6972

70-
1. Add a security field as a `Collection(Edm.String)`. Make sure it has a `filterable` attribute set to `true` so that search results are filtered based on the access the user has. For example, if you set the `group_ids` field to `["group_id1, group_id2"]` for the document with `file_name` "secured_file_b", only users that belong to group IDs "group_id1" or "group_id2" have read access to the file.
73+
1. Indexes require a document key. The "file_id" field satisfies that requirement.
7174

72-
Set the field's `retrievable` attribute to `false` so that it isn't returned as part of the search request.
75+
1. Indexes should also contain searchable and retrievable content. The "file_name" and "file_description" fields represent that in this example.
7376

74-
1. Indexes require a document key. The "file_id" field satisfies that requirement. Indexes should also contain searchable content. The "file_name" and "file_description" fields represent that in this example.
77+
The following index schema satisfies the field requirements. Documents that you index on Azure AI Search should have values for all of these fields, including the "group_ids". For the document with `file_name` "secured_file_b", only users that belong to group IDs "group_id1" or "group_id2" have read access to the file.
7578

7679
```https
7780
POST https://[search service].search.windows.net/indexes/securedfiles/docs/index?api-version=2023-11-01
@@ -87,23 +90,25 @@ In the search index, within the field collection, you need one field that contai
8790
```
8891

8992
## Push data into your index using the REST API
90-
91-
Send an HTTP POST request to the docs collection of your index's URL endpoint (see [Documents - Index](/rest/api/searchservice/documents/)). The body of the HTTP request is a JSON rendering of the documents to be indexed:
9293

93-
```http
94-
POST https://[search service].search.windows.net/indexes/securedfiles/docs/index?api-version=2023-11-01
95-
```
94+
Populate your search index with documents that provide values for each field in the fields collection, including values for the security field. Azure AI Search doesn't provide APIs or features for populating the security field specifically. However, several of the examples listed at the end of this article explain techniques for populating this field.
9695

97-
In the request body, specify the content of your documents:
96+
In Azure AI Search, the approaches for loading data are:
9897

99-
```JSON
98+
* A single push or pull (indexer) operation that imports documents populated with all fields
99+
* Multiple push or pull operations. As long as secondary import operations target the right document identifier, you can load fields individually through multiple imports.
100+
101+
The following example shows a single HTTP POST request to the docs collection of your index's URL endpoint (see [Documents - Index](/rest/api/searchservice/documents/)). The body of the HTTP request is a JSON rendering of the documents to be indexed:
102+
103+
```http
104+
POST https://[search service].search.windows.net/indexes/securedfiles/docs/index?api-version=2023-11-01
100105
{
101106
"value": [
102107
{
103108
"@search.action": "upload",
104109
"file_id": "1",
105110
"file_name": "secured_file_a",
106-
"file_description": "File access is restricted to the Human Resources.",
111+
"file_description": "File access is restricted to Human Resources.",
107112
"group_ids": ["group_id1"]
108113
},
109114
{
@@ -147,17 +152,11 @@ For full details on searching documents using Azure AI Search, you can read [Sea
147152

148153
This sample shows how to set up query using a POST request.
149154

150-
Issue the HTTP POST request:
155+
Issue the HTTP POST request, specifying the filter in the request body:
151156

152157
```http
153-
POST https://[service name].search.windows.net/indexes/securedfiles/docs/search?api-version=2020-06-30
154-
Content-Type: application/json
155-
api-key: [admin or query key]
156-
```
157-
158-
Specify the filter in the request body:
158+
POST https://[service name].search.windows.net/indexes/securedfiles/docs/search?api-version=2023-11-01
159159
160-
```JSON
161160
{
162161
"filter":"group_ids/any(g:search.in(g, 'group_id1, group_id2'))"
163162
}
@@ -186,7 +185,9 @@ You should get the documents back where `group_ids` contains either "group_id1"
186185

187186
This article describes a pattern for filtering results based on user identity and the `search.in()` function. You can use this function to pass in principal identifiers for the requesting user to match against principal identifiers associated with each target document. When a search request is handled, the `search.in` function filters out search results for which none of the user's principals have read access. The principal identifiers can represent things like security groups, roles, or even the user's own identity.
188187

189-
For an alternative pattern based on Microsoft Entra ID, or to revisit other security features, see the following links.
188+
For more examples, demos, and videos:
190189

191-
* [Security filters for trimming results using Microsoft Entra ID identities](search-security-trimming-for-azure-search-with-aad.md)
192-
* [Security in Azure AI Search](search-security-overview.md)
190+
* [Configure document security for a chat app in Python](/azure/developer/python/get-started-app-chat-document-security-trim)
191+
* [Set up a security filter using Microsoft Entra ID](search-security-trimming-for-azure-search-with-aad.md)
192+
* [Set up optional sign in and document level access control (modifications to the AzureOpenAIDemo app)](https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/docs/login_and_acl.md)
193+
* [Video: Secure your Intelligent Applications with Microsoft Entra](https://build.microsoft.com/en-US/sessions/b5636ca7-64c2-493c-9b30-4a35852acfbe?source=/speakers/cc9b56a0-4af0-4b60-a2f3-8312c5b35ca2)

0 commit comments

Comments
 (0)