Skip to content

Commit b8ca140

Browse files
authored
Merge pull request #120138 from jordanbean-msft/patch-2
Update tutorial-auth-aad.md with additional authSettings
2 parents 0a8fbf6 + 249f3b6 commit b8ca140

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

articles/app-service/tutorial-auth-aad.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,27 @@ Your apps are now configured. The frontend is now ready to access the backend wi
249249

250250
For information on how to configure the access token for other providers, see [Refresh identity provider tokens](configure-authentication-oauth-tokens.md#refresh-auth-tokens).
251251

252-
## 6. Frontend calls the authenticated backend
252+
## 6. Configure backend App Service to accept a token only from the frontend App Service
253+
254+
You should also configure the backend App Service to only accept a token from the frontend App Service. Not doing this may result in a "403: Forbidden error" when you pass the token from the frontend to the backend.
255+
256+
You can set this via the same Azure CLI process you used in the previous step.
257+
258+
1. Get the `appId` of the frontend App Service (you can get this on the "Authentication" blade of the frontend App Service).
259+
260+
1. Run the following Azure CLI, substituting the `<back-end-app-name>` and `<front-end-app-id>`.
261+
262+
```azurecli-interactive
263+
authSettings=$(az webapp auth show -g myAuthResourceGroup -n <back-end-app-name>)
264+
authSettings=$(echo "$authSettings" | jq '.properties' | jq '.identityProviders.azureActiveDirectory.validation.defaultAuthorizationPolicy.allowedApplications += ["<front-end-app-id>"]')
265+
az webapp auth set --resource-group myAuthResourceGroup --name <back-end-app-name> --body "$authSettings"
266+
267+
authSettings=$(az webapp auth show -g myAuthResourceGroup -n <back-end-app-name>)
268+
authSettings=$(echo "$authSettings" | jq '.properties' | jq '.identityProviders.azureActiveDirectory.validation.jwtClaimChecks += { "allowedClientApplications": ["<front-end-app-id>"]}')
269+
az webapp auth set --resource-group myAuthResourceGroup --name <back-end-app-name> --body "$authSettings"
270+
```
271+
272+
## 7. Frontend calls the authenticated backend
253273

254274
The frontend app needs to pass the user's authentication with the correct `user_impersonation` scope to the backend. The following steps review the code provided in the sample for this functionality.
255275

0 commit comments

Comments
 (0)