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
+41-38Lines changed: 41 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: Authentication and Authorization
3
-
description: Find out 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.
2
+
title: Authentication and Authorization in Azure App Service and Azure Functions
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.
Azure App Service provides built-in authentication and authorization capabilities (sometimes called *Easy Auth*), so you can 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.
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).
17
17
18
-
## Reasons to use built-in authentication
18
+
This article describes how App Service helps simplify authentication and authorization for your app.
19
19
20
-
You're not required to use the built-in authentication and authorization. You can use the bundled security features in your web framework of choice, or you can write your own utilities.
20
+
## Reasons to use built-in authentication
21
21
22
-
However, implementing a secure solution for authentication (signing in users) and authorization (providing access to secure data) 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.
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 utilities. 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
23
24
24
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
25
26
-
With Azure 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 even any code. You can integrate it with multiple login providers, such as Microsoft Entra, Facebook, Google, and X.
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 even any code. You can integrate it with multiple login providers, such as Microsoft Entra, Facebook, Google, and X.
27
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
29
@@ -33,12 +33,12 @@ App Service uses [federated identity](https://en.wikipedia.org/wiki/Federated_id
33
33
34
34
| Provider | Sign-in endpoint | How-to guidance |
35
35
| - | - | - |
36
-
|[Microsoft Entra](/entra/index)|`/.auth/login/aad`|[App Service Microsoft Entra platform login](configure-authentication-provider-aad.md)|
36
+
|[Microsoft Entra](/entra/index)|`/.auth/login/aad`|[App Service Microsoft Entra platform sign-in](configure-authentication-provider-aad.md)|
37
37
|[Facebook](https://developers.facebook.com/docs/facebook-login)|`/.auth/login/facebook`|[App Service Facebook login](configure-authentication-provider-facebook.md)|
38
-
|[Google](https://developers.google.com/identity/choose-auth)|`/.auth/login/google`|[App Service Google login](configure-authentication-provider-google.md)|
38
+
|[Google](https://developers.google.com/identity/choose-auth)|`/.auth/login/google`|[App Service Google sign-in](configure-authentication-provider-google.md)|
39
39
|[X](https://developer.x.com/en/docs/basics/authentication)|`/.auth/login/x`|[App Service X login](configure-authentication-provider-twitter.md)|
40
-
|[GitHub](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)|`/.auth/login/github`|[App Service GitHub login](configure-authentication-provider-github.md)|
41
-
|[Apple](https://developer.apple.com/sign-in-with-apple/)|`/.auth/login/apple`|[App Service sign-in with Apple login (preview)](configure-authentication-provider-apple.md)|
40
+
|[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
+
|[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
42
| Any [OpenID Connect](https://openid.net/connect/) provider |`/.auth/login/<providerName>`|[App Service OpenID Connect sign-in](configure-authentication-provider-openid-connect.md)|
43
43
44
44
When you configure this feature with one of these providers, its sign-in endpoint is available for user authentication and for validation of authentication tokens from the provider. You can provide your users with any number of these sign-in options.
@@ -78,7 +78,7 @@ The authentication and authorization module runs as a native [IIS module](/iis/g
78
78
79
79
#### Feature architecture on Linux and containers
80
80
81
-
The authentication and authorization module runs in a separate container, isolated from your application code. By using the [Ambassador pattern](/azure/architecture/patterns/ambassador), it 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.
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 inprocess, no direct integration with specific language frameworks is possible. However, the relevant information that your app needs is passed through via request headers.
82
82
83
83
### Authentication flow
84
84
@@ -100,7 +100,7 @@ The following table shows the steps of the authentication flow.
100
100
| 1. Sign in the user | Provider redirects the client to `/.auth/login/<provider>`. | Client code signs in the user directly with the provider's SDK and receives an authentication token. For more information, see the provider's documentation. |
101
101
| 2. Conduct post-authentication | Provider redirects the client to `/.auth/login/<provider>/callback`. | Client code [posts the token from the provider](configure-authentication-customize-sign-in-out.md#client-directed-sign-in) to `/.auth/login/<provider>` for validation. |
102
102
| 3. Establish an authenticated session | App Service adds an authenticated cookie to the response. | App Service returns its own authentication token to the client code. |
103
-
| 4. Serve authenticated content | Client includes an authentication cookie in subsequent requests (automatically handled by browser). | Client code presents the authentication token in the `X-ZUMO-AUTH` header. |
103
+
| 4. Serve authenticated content | Client includes an authentication cookie in subsequent requests (automatically handled by the browser). | Client code presents the authentication token in the `X-ZUMO-AUTH` header. |
104
104
105
105
For client browsers, App Service can automatically direct all unauthenticated users to `/.auth/login/<provider>`. You can also present users with one or more `/.auth/login/<provider>` links to sign in to your app by using their provider of choice.
106
106
@@ -144,7 +144,7 @@ If your application code needs to access data from these providers on the user's
144
144
- Post to the authenticated user's Facebook timeline.
145
145
- Read the user's corporate data by using the Microsoft Graph API.
146
146
147
-
But with the token store, you just [retrieve the tokens](configure-authentication-oauth-tokens.md#retrieve-tokens-in-app-code) when you need them and [tell App Service to refresh them](configure-authentication-oauth-tokens.md#refresh-auth-tokens) when they become invalid.
147
+
With the token store, you just [retrieve the tokens](configure-authentication-oauth-tokens.md#retrieve-tokens-in-app-code) when you need them and [tell App Service to refresh them](configure-authentication-oauth-tokens.md#refresh-auth-tokens) when they become invalid.
148
148
149
149
The ID tokens, access tokens, and refresh tokens are cached for the authenticated session. Only the associated user can access them.
150
150
@@ -156,36 +156,36 @@ If you [enable application logging](troubleshoot-diagnostic-logs.md), authentica
156
156
157
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`.
158
158
159
-
### Cross-site request forgery mitigation
159
+
### Mitigation of cross-site request forgery
160
160
161
-
App Service authentication mitigates CSRF by inspecting client requests for the following conditions:
161
+
App Service authentication mitigates cross-site request forgery by inspecting client requests for the following conditions:
162
162
163
-
- It's a `POST` request that authenticated using a session cookie.
164
-
- The request came from a known browser (as determined by the HTTP `User-Agent` header).
163
+
- It's a `POST` request that authenticated through a session cookie.
164
+
- The request came from a known browser, as determined by the HTTP `User-Agent` header.
165
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 CORS origins.
166
+
- The HTTP `Origin` header is missing or is not in the configured list of cross-origin resource sharing (CORS) origins.
167
167
168
-
When a request fulfills all these conditions, App Service authentication automatically rejects it. You can workaround this mitigation logic by adding your external domain to the redirect list to**Authentication** > **Edit authentication settings** > **Allowed external redirect URLs**.
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**.
169
169
170
170
## Considerations for using Azure Front Door
171
171
172
-
When you're using Azure App Service with authentication behind Azure Front Door or other reverse proxies, a few additional things have to be taken into consideration.
172
+
When you're using Azure App Service with authentication behind Azure Front Door or other reverse proxies, consider the following actions.
173
173
174
174
### Disable Azure Front Door caching
175
175
176
176
Disable [Azure Front Door caching](../frontdoor/front-door-caching.md) for the authentication workflow.
177
177
178
178
### Use the Azure Front Door endpoint for redirects
179
179
180
-
App Service is usually not accessible directly when exposed via Azure Front Door. This can be prevented, for example, by exposing App Service via Private Link in Azure Front Door Premium. To prevent the authentication workflow to redirect 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`.
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`.
181
181
182
182
### Ensure that App Service is using the right redirect URI
183
183
184
-
In some configurations, App Service is using the App Service FQDN as the redirect URI instead of the Azure Front Door FQDN. This configuration causes a problem when the client is being 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 set by Azure Front Door.
184
+
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
185
186
-
Other reverse proxies like Azure Application Gateway or 3rd-party products might use different headers and need a different forwardProxy setting.
186
+
Other reverse proxies, like Azure Application Gateway or non-Microsoft products, might use different headers and need a different `forwardProxy` setting.
187
187
188
-
This configuration cannot be done via the Azure portal today and needs to be done via`az rest`.
188
+
You can't change the `forwardProxy` configuration via the Azure portal. You need to use`az rest`.
189
189
190
190
#### Export settings
191
191
@@ -203,22 +203,25 @@ Search for:
203
203
}
204
204
```
205
205
206
-
Ensure that `convention` is set to `Standard` to respect the `X-Forwarded-Host` header used by Azure Front Door.
206
+
Ensure that `convention` is set to `Standard` to respect the `X-Forwarded-Host` header that Azure Front Door uses.
207
207
208
208
#### Import settings
209
209
210
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`
211
211
212
212
## Related content
213
213
214
-
-[How-To: Configure your App Service or Azure Functions app to use Microsoft Entra login](configure-authentication-provider-aad.md)
215
-
-[Customize sign-ins and sign-outs](configure-authentication-customize-sign-in-out.md)
216
-
-[Work with OAuth tokens and sessions](configure-authentication-oauth-tokens.md)
217
-
-[Access user and application claims](configure-authentication-user-identities.md)
-[Getting Azure App Service authentication working with .NET Core](https://github.com/kirkone/KK.AspNetCore.EasyAuthAuthentication) (non-Microsoft GitHub content)
0 commit comments