Skip to content

Commit f5a116d

Browse files
authored
Merge pull request #87241 from cephalin/master
aad/google freshness
2 parents 94a46bb + 9c3c1f4 commit f5a116d

8 files changed

+142
-91
lines changed

articles/app-service/app-service-authentication-how-to.md

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ description: Shows how to customize authentication and authorization in App Serv
44
services: app-service
55
documentationcenter: ''
66
author: cephalin
7-
manager: cfowler
7+
manager: gwallace
88
editor: ''
99

1010
ms.service: app-service
1111
ms.workload: mobile
1212
ms.tgt_pltfrm: na
1313
ms.topic: article
14-
ms.date: 11/08/2018
14+
ms.date: 09/02/2019
1515
ms.author: cephalin
1616
ms.custom: seodec18
1717
---
@@ -126,7 +126,7 @@ When using fully qualified URLs, the URL must be either hosted in the same domai
126126
GET /.auth/logout?post_logout_redirect_uri=https%3A%2F%2Fmyexternalurl.com
127127
```
128128

129-
You must run the following command in the [Azure Cloud Shell](../cloud-shell/quickstart.md):
129+
Run the following command in the [Azure Cloud Shell](../cloud-shell/quickstart.md):
130130

131131
```azurecli-interactive
132132
az webapp auth update --name <app_name> --resource-group <group_name> --allowed-external-redirect-urls "https://myexternalurl.com"
@@ -193,7 +193,7 @@ When your provider's access token (not the [session token](#extend-session-token
193193

194194
Once your provider is configured, you can [find the refresh token and the expiration time for the access token](#retrieve-tokens-in-app-code) in the token store.
195195

196-
To refresh your access token at anytime, just call `/.auth/refresh` in any language. The following snippet uses jQuery to refresh your access tokens from a JavaScript client.
196+
To refresh your access token at any time, just call `/.auth/refresh` in any language. The following snippet uses jQuery to refresh your access tokens from a JavaScript client.
197197

198198
```JavaScript
199199
function refreshTokens() {
@@ -226,7 +226,7 @@ az webapp auth update --resource-group <group_name> --name <app_name> --token-re
226226
227227
## Limit the domain of sign-in accounts
228228

229-
Both Microsoft Account and Azure Active Directory lets you sign in from multiple domains. For example, Microsoft Account allows _outlook.com_, _live.com_, and _hotmail.com_ accounts. Azure Active Directory allows any number of custom domains for the sign-in accounts. This behavior may be undesirable for an internal app, which you don't want anyone with an _outlook.com_ account to access. To limit the domain name of the sign-in accounts, follow these steps.
229+
Both Microsoft Account and Azure Active Directory lets you sign in from multiple domains. For example, Microsoft Account allows _outlook.com_, _live.com_, and _hotmail.com_ accounts. Azure AD allows any number of custom domains for the sign-in accounts. However, you may want to accelerate your users straight to your own branded Azure AD sign-in page (such as `contoso.com`). To suggest the domain name of the sign-in accounts, follow these steps.
230230

231231
In [https://resources.azure.com](https://resources.azure.com), navigate to **subscriptions** > **_\<subscription\_name_** > **resourceGroups** > **_\<resource\_group\_name>_** > **providers** > **Microsoft.Web** > **sites** > **_\<app\_name>_** > **config** > **authsettings**.
232232

@@ -235,6 +235,54 @@ Click **Edit**, modify the following property, and then click **Put**. Be sure t
235235
```json
236236
"additionalLoginParams": ["domain_hint=<domain_name>"]
237237
```
238+
239+
This setting appends the `domain_hint` query string parameter to the login redirect URL.
240+
241+
> [!IMPORTANT]
242+
> It's possible for the client to remove the `domain_hint` parameter after receiving the redirect URL, and then login with a different domain. So while this function is convenient, it's not a security feature.
243+
>
244+
245+
## Authorize or deny users
246+
247+
While App Service takes care of the simplest authorization case (i.e. reject unauthenticated requests), your app may require more fine-grained authorization behavior, such as limiting access to only a specific group of users. In certain cases, you need to write custom application code to allow or deny access to the signed-in user. In other cases, App Service or your identity provider may be able to help without requiring code changes.
248+
249+
- [Server level](#server-level-windows-apps-only)
250+
- [Identity provider level](#identity-provider-level)
251+
- [Application level](#application-level)
252+
253+
### Server level (Windows apps only)
254+
255+
For any Windows app, you can define authorization behavior of the IIS web server, by editing the *Web.config* file. Linux apps don't use IIS and can't be configured through *Web.config*.
256+
257+
1. Navigate to `https://<app-name>.scm.azurewebsites.net/DebugConsole`
258+
259+
1. In the browser explorer of your App Service files, navigate to *site/wwwroot*. If a *Web.config* doesn't exist, create it by selecting **+** > **New File**.
260+
261+
1. Select the pencil for *Web.config* to edit it. Add the following configuration code and click **Save**. If *Web.config* already exists, just add the `<authorization>` element with everything in it. Add the accounts you want to allow in the `<allow>` element.
262+
263+
```xml
264+
<?xml version="1.0" encoding="utf-8"?>
265+
<configuration>
266+
<system.web>
267+
<authorization>
268+
269+
<deny users="*"/>
270+
</authorization>
271+
</system.web>
272+
</configuration>
273+
```
274+
275+
### Identity provider level
276+
277+
The identity provider may provide certain turn-key authorization. For example:
278+
279+
- For [Azure App Service](configure-authentication-provider-aad.md), you can [manage enterprise-level access](../active-directory/manage-apps/what-is-access-management.md) directly in Azure AD. For instructions, see [How to remove a user's access to an application](../active-directory/manage-apps/methods-for-removing-user-access.md).
280+
- For [Google](configure-authentication-provider-google.md), Google API projects that belong to an [organization](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy#organizations) can be configured to allow access only to users in your organization (see [Google's **Setting up OAuth 2.0** support page](https://support.google.com/cloud/answer/6158849?hl=en)).
281+
282+
### Application level
283+
284+
If either of the other levels don't provide the authorization you need, or if your platform or identity provider isn't supported, you must write custom code to authorize users based on the [user claims](#access-user-claims).
285+
238286
## Next steps
239287

240288
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)