Skip to content

Commit 193962d

Browse files
authored
add pre-checks and better docs (#2386)
1 parent 31ea846 commit 193962d

File tree

3 files changed

+100
-10
lines changed

3 files changed

+100
-10
lines changed

docs/login_and_acl.md

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,68 @@ Two Microsoft Entra applications must be registered in order to make the optiona
5959

6060
The easiest way to setup the two apps is to use the `azd` CLI. We've written scripts that will automatically create the two apps and configure them for use with the sample. To trigger the automatic setup, run the following commands:
6161

62-
1. Run `azd env set AZURE_USE_AUTHENTICATION true` to enable the login UI and use App Service authentication by default.
63-
1. Ensure access control is enabled on your search index. If your index doesn't exist yet, run prepdocs with `AZURE_USE_AUTHENTICATION` set to `true`. If your index already exists, run `python ./scripts/manageacl.py --acl-action enable_acls`.
64-
1. (Optional) To require access control when using the app, run `azd env set AZURE_ENFORCE_ACCESS_CONTROL true`. Authentication is always required to search on documents with access control assigned, regardless of if unauthenticated access is enabled or not.
65-
1. (Optional) To allow authenticated users to search on documents that have no access controls assigned, even when access control is required, run `azd env set AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS true`.
66-
1. (Optional) To allow unauthenticated users to use the app, even when access control is enforced, run `azd env set AZURE_ENABLE_UNAUTHENTICATED_ACCESS true`. `AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS` should also be set to true if you want unauthenticated users to be able to search on documents with no access control.
67-
1. Run `azd env set AZURE_AUTH_TENANT_ID <YOUR-TENANT-ID>` to set the tenant ID associated with authentication.
68-
1. If your auth tenant ID is different from your currently logged in tenant ID, run `azd auth login --tenant-id <YOUR-TENANT-ID>` to login to the authentication tenant simultaneously.
69-
1. Run `azd up` to deploy the app.
62+
1. **Enable authentication for the app**
63+
Run the following command to show the login UI and use Entra authentication by default:
64+
65+
```shell
66+
azd env set AZURE_USE_AUTHENTICATION true
67+
```
68+
69+
1. **Enable access control on your search index**
70+
71+
- **If the index does not exist yet:**
72+
Run the `prepdocs` script.
73+
74+
- **If the index already exists:**
75+
Execute this command to enable ACLs:
76+
77+
```shell
78+
python ./scripts/manageacl.py --acl-action enable_acls
79+
```
80+
81+
1. (Optional) **Enforce access control**
82+
To ensure that the app restricts search results to only documents that the user has access to, run the following command:
83+
84+
```shell
85+
azd env set AZURE_ENFORCE_ACCESS_CONTROL true
86+
```
87+
88+
1. (Optional) **Allow global document access**
89+
To allow users to search on documents that have no access controls assigned, even when access control is required, run the following command:
90+
91+
```shell
92+
azd env set AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS true
93+
```
94+
95+
1. (Optional) **Allow unauthenticated access**
96+
To allow unauthenticated users to use the app, even when access control is enforced, run the following command:
97+
98+
```shell
99+
azd env set AZURE_ENABLE_UNAUTHENTICATED_ACCESS true
100+
```
101+
102+
Note: These users will not be able to search on documents that have access control assigned, so `AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS` should also be set to true to give them access to the remaining documents.
103+
104+
1. **Set the authentication tenant ID**
105+
Specify the tenant ID associated with authentication by running:
106+
107+
```shell
108+
azd env set AZURE_AUTH_TENANT_ID <YOUR-TENANT-ID>
109+
```
110+
111+
1. **Login to the authentication tenant (if needed)**
112+
If your auth tenant ID is different from your currently logged in tenant ID, run:
113+
114+
```shell
115+
azd auth login --tenant-id <YOUR-TENANT-ID>
116+
```
117+
118+
1. **Deploy the app**
119+
Finally, run the following command to provision and deploy the app:
120+
121+
```shell
122+
azd up
123+
```
70124

71125
### Manual Setup
72126

@@ -221,7 +275,7 @@ The script supports the following commands. All commands support `-v` for verbos
221275
python ./scripts/manageacl.py -v --acl-type groups --acl-action view --url https://st12345.blob.core.windows.net/content/Benefit_Options.pdf
222276
```
223277
224-
- `python ./scripts/manageacl.py --acl-type [oids or groups]--acl-action add --acl [ID of group or user] --url [https://url.pdf]`: Adds an access control value associated with either User IDs or Group IDs for the document at the specified URL.
278+
- `python ./scripts/manageacl.py --acl-type [oids or groups] --acl-action add --acl [ID of group or user] --url [https://url.pdf]`: Adds an access control value associated with either User IDs or Group IDs for the document at the specified URL.
225279
226280
Example to add a Group ID:
227281

scripts/auth_init.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
Write-Host "Checking if authentication should be setup..."
22

33
$AZURE_USE_AUTHENTICATION = (azd env get-value AZURE_USE_AUTHENTICATION)
4+
$AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS = (azd env get-value AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS)
5+
$AZURE_ENFORCE_ACCESS_CONTROL = (azd env get-value AZURE_ENFORCE_ACCESS_CONTROL)
6+
$USE_CHAT_HISTORY_COSMOS = (azd env get-value USE_CHAT_HISTORY_COSMOS)
7+
8+
if ($AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS -eq "true") {
9+
if ($AZURE_ENFORCE_ACCESS_CONTROL -ne "true") {
10+
Write-Host "AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS is set to true, but AZURE_ENFORCE_ACCESS_CONTROL is not set to true. Please set it and retry."
11+
Exit 1
12+
}
13+
}
14+
15+
if ($USE_CHAT_HISTORY_COSMOS -eq "true") {
16+
if ($AZURE_USE_AUTHENTICATION -ne "true") {
17+
Write-Host "AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS, AZURE_ENFORCE_ACCESS_CONTROL, or USE_CHAT_HISTORY_COSMOS is set to true, but AZURE_USE_AUTHENTICATION is not set to true. Please set and retry."
18+
Exit 1
19+
}
20+
}
21+
422
if ($AZURE_USE_AUTHENTICATION -ne "true") {
523
Write-Host "AZURE_USE_AUTHENTICATION is not set, skipping authentication setup."
624
Exit 0

scripts/auth_init.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
#!/bin/sh
1+
#!/bin/sh
22

33
echo "Checking if authentication should be setup..."
44

55
AZURE_USE_AUTHENTICATION=$(azd env get-value AZURE_USE_AUTHENTICATION)
6+
AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS=$(azd env get-value AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS)
7+
AZURE_ENFORCE_ACCESS_CONTROL=$(azd env get-value AZURE_ENFORCE_ACCESS_CONTROL)
8+
USE_CHAT_HISTORY_COSMOS=$(azd env get-value USE_CHAT_HISTORY_COSMOS)
9+
10+
if [ "$AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS" = "true" ]; then
11+
if [ "$AZURE_ENFORCE_ACCESS_CONTROL" != "true" ]; then
12+
echo "AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS is set to true, but AZURE_ENFORCE_ACCESS_CONTROL is not set to true. Please set and retry."
13+
exit 1
14+
fi
15+
fi
16+
17+
if [ "$USE_CHAT_HISTORY_COSMOS" = "true" ]; then
18+
if [ "$AZURE_USE_AUTHENTICATION" != "true" ]; then
19+
echo "USE_CHAT_HISTORY_COSMOS is set to true, but AZURE_USE_AUTHENTICATION is not set to true. Please set and retry."
20+
exit 1
21+
fi
22+
fi
23+
624
if [ "$AZURE_USE_AUTHENTICATION" != "true" ]; then
725
echo "AZURE_USE_AUTHENTICATION is not set, skipping authentication setup."
826
exit 0

0 commit comments

Comments
 (0)