You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/overview-authentication-authorization.md
+32-26Lines changed: 32 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,42 +1,43 @@
1
1
---
2
2
title: Authentication and Authorization
3
-
description: Learn about the built-in authentication and authorization support in Azure App Service and Azure Functions, and how it can help secure your app against unauthorized access.
3
+
description: Learn about the built-in authentication and authorization support in Azure App Service and Azure Functions, and how it can help secure your app.
Azure App Service provides built-in authentication (signing in users) and authorization (providing access to secure data) capabilities. These capabilities are sometimes called *Easy Auth*. You can use them to sign in users and access data by writing little or no code in your web app, RESTful API, mobile server, and [functions](../azure-functions/functions-overview.md).
15
16
16
-
Azure App Service provides built-in authentication (signing in users) and authorization (providing access to secure data) capabilities. These capabilities are sometimes called *Easy Auth*. You can use them to sign in users and access data by writing minimal or no code in your web app, RESTful API, mobile back end, and [functions](../azure-functions/functions-overview.md).
This article describes how App Service helps simplify authentication and authorization for your app.
19
20
20
21
## Reasons to use built-in authentication
21
22
22
-
To implement authentication and authorization, you can use the bundled security features in your web framework of choice, or you can write your own tools. However, implementing a secure solution for authentication and authorization can take significant effort. You need to follow industry best practices and standards. You also need to ensure that your solution stays up to date with the latest security, protocol, and browser updates.
23
+
To implement authentication and authorization, you can use the bundled security features in your web framework of choice, or you can write your own tools. Implementing a secure solution for authentication and authorization can take significant effort. You need to follow industry best practices and standards. You also need to ensure that your solution stays up to date with the latest security, protocol, and browser updates.
23
24
24
25
The built-in capabilities of App Service and Azure Functions can save you time and effort by providing out-of-the-box authentication with federated identity providers, so you can focus on the rest of your application.
25
26
26
-
With App Service, you can integrate a variety of authentication capabilities into your web app or API without implementing them yourself. This feature is built directly into the platform and doesn't require any particular language, SDK, security expertise, or code. You can integrate it with multiple login providers, such as Microsoft Entra, Facebook, Google, and X.
27
+
With App Service, you can integrate authentication capabilities into your web app or API without implementing them yourself. This feature is built directly into the platform and doesn't require any particular language, SDK, security expertise, or code. You can integrate it with multiple sign-in providers, such as Microsoft Entra, Facebook, Google, and X.
27
28
28
-
Your app might need to support more complex scenarios, such as Visual Studio integration or incremental consent. Several authentication solutions are available to support these scenarios. To learn more, read[Authentication scenarios and recommendations](identity-scenarios.md).
29
+
Your app might need to support more complex scenarios, such as Visual Studio integration or incremental consent. Several authentication solutions are available to support these scenarios. To learn more, see[Authentication scenarios and recommendations](identity-scenarios.md).
29
30
30
31
## Identity providers
31
32
32
-
App Service uses [federated identity](https://en.wikipedia.org/wiki/Federated_identity), in which a third-party identity provider manages the user identities and authentication flow for you. The following identity providers are available by default:
33
+
App Service uses [federated identity](https://en.wikipedia.org/wiki/Federated_identity). A Microsoft or non-Microsoft identity provider manages the user identities and authentication flow for you. The following identity providers are available by default:
33
34
34
35
| Provider | Sign-in endpoint | How-to guidance |
35
-
|- |- |- |
36
+
|:- |:- |:- |
36
37
|[Microsoft Entra](/entra/index)|`/.auth/login/aad`|[App Service Microsoft Entra platform sign-in](configure-authentication-provider-aad.md)|
37
-
|[Facebook](https://developers.facebook.com/docs/facebook-login)|`/.auth/login/facebook`|[App Service Facebook login](configure-authentication-provider-facebook.md)|
38
+
|[Facebook](https://developers.facebook.com/docs/facebook-login)|`/.auth/login/facebook`|[App Service Facebook sign-in](configure-authentication-provider-facebook.md)|
38
39
|[Google](https://developers.google.com/identity/choose-auth)|`/.auth/login/google`|[App Service Google sign-in](configure-authentication-provider-google.md)|
39
-
|[X](https://developer.x.com/en/docs/basics/authentication)|`/.auth/login/x`|[App Service X login](configure-authentication-provider-twitter.md)|
40
+
|[X](https://developer.x.com/en/docs/basics/authentication)|`/.auth/login/x`|[App Service X sign-in](configure-authentication-provider-twitter.md)|
40
41
|[GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)|`/.auth/login/github`|[App Service GitHub sign-in](configure-authentication-provider-github.md)|
41
42
|[Apple](https://developer.apple.com/sign-in-with-apple/)|`/.auth/login/apple`|[App Service sign-in via Apple sign-in (preview)](configure-authentication-provider-apple.md)|
42
43
| Any [OpenID Connect](https://openid.net/connect/) provider |`/.auth/login/<providerName>`|[App Service OpenID Connect sign-in](configure-authentication-provider-openid-connect.md)|
@@ -47,7 +48,7 @@ When you configure this feature with one of these providers, its sign-in endpoin
47
48
48
49
Enabling built-in authentication causes all requests to your application to be automatically redirected to HTTPS, regardless of the App Service configuration setting to enforce HTTPS. You can disable this automatic redirection by using the `requireHttps` setting in the V2 configuration. However, we recommend that you keep using HTTPS and ensure that no security tokens are ever transmitted over nonsecure HTTP connections.
49
50
50
-
You can use App Service for authentication with or without restricting access to your site content and APIs. Set access restrictions in the **Authentication** > **Authentication settings** section of your web app:
51
+
You can use App Service for authentication with or without restricting access to your site content and APIs. Set access restrictions in the **Settings** > **Authentication** > **Authentication settings** section of your web app:
51
52
52
53
- To restrict app access to only authenticated users, set **Action to take when request is not authenticated** to sign in with one of the configured identity providers.
53
54
- To authenticate but not restrict access, set **Action to take when request is not authenticated** to **Allow anonymous requests (no action)**.
@@ -59,7 +60,7 @@ You can use App Service for authentication with or without restricting access to
59
60
60
61
### Feature architecture
61
62
62
-
The authentication and authorization middleware component is a feature of the platform that runs on the same virtual machine as your application. When it's enabled, every incoming HTTP request passes through it before your application handles it.
63
+
The authentication and authorization middleware component is a feature of the platform that runs on the same virtual machine as your application. When you enable it, every incoming HTTP request passes through that component before your application handles it.
63
64
64
65
:::image type="content" source="media/app-service-authentication-overview/architecture.png" alt-text="Architecture diagram that shows a process in the site sandbox interacting with identity providers before allowing traffic to the deployed site." lightbox="media/app-service-authentication-overview/architecture.png":::
65
66
@@ -74,20 +75,21 @@ The module runs separately from your application code. You can configure it by u
74
75
75
76
#### Feature architecture on Windows (non-container deployment)
76
77
77
-
The authentication and authorization module runs as a native [IIS module](/iis/get-started/introduction-to-iis/iis-modules-overview) in the same sandbox as your application. When it's enabled, every incoming HTTP request passes through it before your application handles it.
78
+
The authentication and authorization module runs as a native [IIS module](/iis/get-started/introduction-to-iis/iis-modules-overview) in the same sandbox as your application. When you enable it, every incoming HTTP request passes through it before your application handles it.
78
79
79
80
#### Feature architecture on Linux and containers
80
81
81
-
The authentication and authorization module runs in a separate container that's isolated from your application code. By using the [Ambassador pattern](/azure/architecture/patterns/ambassador), the module interacts with the incoming traffic to perform similar functionality as on Windows. Because it doesn't run in process, no direct integration with specific language frameworks is possible. However, the relevant information that your app needs is passed through via request headers.
82
+
The authentication and authorization module runs in a separate container that's isolated from your application code. The module uses the [Ambassador pattern](/azure/architecture/patterns/ambassador) to interact with the incoming traffic to perform similar functionality as on Windows. Because it doesn't run in process, no direct integration with specific language frameworks is possible. However, the relevant information that your app needs is passed through in request headers.
82
83
83
84
### Authentication flow
84
85
85
-
The authentication flow is the same for all providers, but it differs depending on whether you want to sign in with the provider's SDK:
86
+
The authentication flow is the same for all providers. It differs depending on whether you want to sign in with the provider's SDK:
86
87
87
88
-**Without provider SDK**: The application delegates federated sign-in to App Service. This delegation is typically the case with browser apps, which can present the provider's sign-in page to the user. The server code manages the sign-in process, so it's also called *server-directed flow* or *server flow*.
88
89
89
90
This case applies to browser apps and mobile apps that use an embedded browser for authentication.
90
-
-**With provider SDK**: The application signs in users to the provider manually, and then it submits the authentication token to App Service for validation. This process is typically the case with browserless apps, which can't present the provider's sign-in page to the user. The application code manages the sign-in process, so it's also called *client-directed flow* or *client flow*.
91
+
92
+
-**With provider SDK**: The application signs in users to the provider manually. Then it submits the authentication token to App Service for validation. This process is typically the case with browserless apps, which can't present the provider's sign-in page to the user. The application code manages the sign-in process, so it's also called *client-directed flow* or *client flow*.
91
93
92
94
This case applies to REST APIs, [Azure Functions](../azure-functions/functions-overview.md), and JavaScript browser clients, in addition to browser apps that need more flexibility in the sign-in process. It also applies to native mobile apps that sign in users by using the provider's SDK.
93
95
@@ -148,24 +150,24 @@ With the token store, you just [retrieve the tokens](configure-authentication-oa
148
150
149
151
The ID tokens, access tokens, and refresh tokens are cached for the authenticated session. Only the associated user can access them.
150
152
151
-
If you don't need to work with tokens in your app, you can disable the token store on your app's **Authentication**or**Authorization** page.
153
+
If you don't need to work with tokens in your app, you can disable the token store on your app's **Settings**>**Authentication** page.
152
154
153
155
### Logging and tracing
154
156
155
157
If you [enable application logging](troubleshoot-diagnostic-logs.md), authentication and authorization traces appear directly in your log files. If you see an authentication error that you didn't expect, you can conveniently find all the details by looking in your existing application logs.
156
158
157
-
If you enable [failed request tracing](troubleshoot-diagnostic-logs.md), you can see exactly what role the authentication and authorization module might have played in a failed request. In the trace logs, look for references to a module named `EasyAuthModule_32/64`.
159
+
If you enable [failed request tracing](troubleshoot-diagnostic-logs.md), you can see exactly what role the authentication and authorization module might play in a failed request. In the trace logs, look for references to a module named `EasyAuthModule_32/64`.
158
160
159
161
### Mitigation of cross-site request forgery
160
162
161
163
App Service authentication mitigates cross-site request forgery by inspecting client requests for the following conditions:
162
164
163
165
- It's a `POST` request that authenticated through a session cookie.
164
166
- The request came from a known browser, as determined by the HTTP `User-Agent` header.
165
-
- The HTTP `Origin` or HTTP `Referer` header is missing or is not in the configured list of approved external domains for redirection.
166
-
- The HTTP `Origin` header is missing or is not in the configured list of cross-origin resource sharing (CORS) origins.
167
+
- The HTTP `Origin` or HTTP `Referer` header is missing or isn't in the configured list of approved external domains for redirection.
168
+
- The HTTP `Origin` header is missing or isn't in the configured list of cross-origin resource sharing (CORS) origins.
167
169
168
-
When a request fulfills all these conditions, App Service authentication automatically rejects it. You can work around this mitigation logic by adding your external domain to the redirect list in **Authentication** > **Edit authentication settings** > **Allowed external redirect URLs**.
170
+
When a request fulfills all these conditions, App Service authentication automatically rejects it. You can work around this mitigation logic by adding your external domain to the redirect list in **Settings** > **Authentication** > **Edit authentication settings** > **Allowed external redirect URLs**.
169
171
170
172
## Considerations for using Azure Front Door
171
173
@@ -177,19 +179,21 @@ Disable [Azure Front Door caching](../frontdoor/front-door-caching.md) for the a
177
179
178
180
### Use the Azure Front Door endpoint for redirects
179
181
180
-
App Service is usually not accessible directly when it's exposed via Azure Front Door. You can prevent this behavior, for example, by exposing App Service via Azure Private Link in Azure Front Door Premium. To prevent the authentication workflow from redirecting traffic back to App Service directly, it's important to configure the application to redirect back to `https://<front-door-endpoint>/.auth/login/<provider>/callback`.
182
+
App Service is usually not accessible directly when it's exposed by Azure Front Door. You can prevent this behavior, for example, by exposing App Service by using Azure Private Link in Azure Front Door Premium. To prevent the authentication workflow from redirecting traffic back to App Service directly, it's important to configure the application to redirect back to `https://<front-door-endpoint>/.auth/login/<provider>/callback`.
181
183
182
184
### Ensure that App Service is using the right redirect URI
183
185
184
186
In some configurations, App Service uses its fully qualified domain name (FQDN) as the redirect URI, instead of the Azure Front Door FQDN. This configuration causes a problem when the client is redirected to App Service instead of Azure Front Door. To change it, set `forwardProxy` to `Standard` to make App Service respect the `X-Forwarded-Host` header that Azure Front Door set.
185
187
186
188
Other reverse proxies, like Azure Application Gateway or non-Microsoft products, might use different headers and need a different `forwardProxy` setting.
187
189
188
-
You can't change the `forwardProxy` configuration via the Azure portal. You need to use `az rest`.
190
+
You can't change the `forwardProxy` configuration by using the Azure portal. You need to use `az rest`.
189
191
190
192
#### Export settings
191
193
192
-
`az rest --uri /subscriptions/REPLACE-ME-SUBSCRIPTIONID/resourceGroups/REPLACE-ME-RESOURCEGROUP/providers/Microsoft.Web/sites/REPLACE-ME-APPNAME/config/authsettingsV2?api-version=2020-09-01 --method get > auth.json`
194
+
```bash
195
+
az rest --uri /subscriptions/REPLACE-ME-SUBSCRIPTIONID/resourceGroups/REPLACE-ME-RESOURCEGROUP/providers/Microsoft.Web/sites/REPLACE-ME-APPNAME/config/authsettingsV2?api-version=2020-09-01 --method get > auth.json
196
+
```
193
197
194
198
#### Update settings
195
199
@@ -207,7 +211,9 @@ Ensure that `convention` is set to `Standard` to respect the `X-Forwarded-Host`
207
211
208
212
#### Import settings
209
213
210
-
`az rest --uri /subscriptions/REPLACE-ME-SUBSCRIPTIONID/resourceGroups/REPLACE-ME-RESOURCEGROUP/providers/Microsoft.Web/sites/REPLACE-ME-APPNAME/config/authsettingsV2?api-version=2020-09-01 --method put --body @auth.json`
214
+
```bash
215
+
az rest --uri /subscriptions/REPLACE-ME-SUBSCRIPTIONID/resourceGroups/REPLACE-ME-RESOURCEGROUP/providers/Microsoft.Web/sites/REPLACE-ME-APPNAME/config/authsettingsV2?api-version=2020-09-01 --method put --body @auth.json
0 commit comments