Skip to content

Commit 9677ef6

Browse files
author
gitName
committed
back out changes
1 parent e1bd2c1 commit 9677ef6

File tree

1 file changed

+29
-37
lines changed

1 file changed

+29
-37
lines changed
Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Protect API in API Management - OAuth 2.0 and Microsoft Entra ID
2+
title: Protect API in API Management using OAuth 2.0 and Microsoft Entra ID
33
titleSuffix: Azure API Management
44
description: Learn how to secure user access to an API in Azure API Management with OAuth 2.0 user authorization and Microsoft Entra ID.
55
services: api-management
66
author: dlepow
77
ms.service: azure-api-management
88
ms.topic: how-to
9-
ms.date: 02/20/2025
9+
ms.date: 04/27/2022
1010
ms.author: danlep
1111
---
1212

@@ -16,82 +16,74 @@ ms.author: danlep
1616

1717
In this article, you'll learn high level steps to configure your [Azure API Management](api-management-key-concepts.md) instance to protect an API, by using the [OAuth 2.0 protocol with Microsoft Entra ID](../active-directory/develop/active-directory-v2-protocols.md).
1818

19-
For a conceptual overview of API authorization options in API Management, see [Authentication and authorization to APIs in API Management](authentication-authorization-overview.md).
19+
For a conceptual overview of API authorization, see [Authentication and authorization to APIs in API Management](authentication-authorization-overview.md).
2020

2121
## Prerequisites
2222

2323
Prior to following the steps in this article, you must have:
2424

2525
- An API Management instance
2626
- A published API using the API Management instance
27-
- A Microsoft Entra tenant where you have permissions to create an app regisgtration
27+
- A Microsoft Entra tenant
2828

2929
## Overview
3030

3131
Follow these steps to protect an API in API Management, using OAuth 2.0 authorization with Microsoft Entra ID.
3232

33-
1. Register an application (called *backend-app* in this article) in Microsoft Entra ID to represent the API.
34-
1. Register an application to represent the client app that calls the API and that obtains tokens from Microsoft Entra ID. This step is not covered in this article because the configuration is dependent on the
35-
1. Configure the [validate-azure-ad-token](validate-azure-ad-token-policy.md) policy in API Management to validate the OAuth token presented in each incoming API request. Requests with valid tokens are passed to the backend API. Depending on your scenario, your backend API could independently validate the token.
33+
1. Register an application (called *backend-app* in this article) in Microsoft Entra ID to protect access to the API.
34+
35+
To access the API, users or applications will acquire and present a valid OAuth token granting access to this app with each API request.
36+
37+
1. Configure the [validate-jwt](validate-jwt-policy.md) policy in API Management to validate the OAuth token presented in each incoming API request. Valid requests can be passed to the API.
38+
39+
Details about OAuth authorization flows and how to generate the required OAuth tokens are beyond the scope of this article. Typically, a separate client app is used to acquire tokens from Microsoft Entra ID that authorize access to the API. For links to more information, see the [Next steps](#next-steps).
40+
41+
<a name='register-an-application-in-azure-ad-to-represent-the-api'></a>
3642

3743
## Register an application in Microsoft Entra ID to represent the API
3844

39-
Using the Azure portal, first register an application that represents the API.
45+
Using the Azure portal, protect an API with Microsoft Entra ID by first registering an application that represents the API.
4046

41-
For details about app registration, see [Quickstart: Configure an application to expose a web API](/entra/identity-platform/quickstart-configure-app-expose-web-apis).
47+
For details about app registration, see [Quickstart: Configure an application to expose a web API](../active-directory/develop/quickstart-configure-app-expose-web-apis.md).
4248

4349
1. In the [Azure portal](https://portal.azure.com), search for and select **App registrations**.
4450

45-
1. Select **+ New registration**.
51+
1. Select **New registration**.
4652

47-
1. On the **Register an application** page, enter your application's registration information:
53+
1. When the **Register an application page** appears, enter your application's registration information:
4854

49-
- In the **Name** section, enter a meaningful application name that is displayed to users of the app, such as *backend-app*.
55+
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, such as *backend-app*.
5056
- In the **Supported account types** section, select an option that suits your scenario.
5157

52-
1. Leave the [**Redirect URI**](/entra/identity-platform/reply-url) section empty.
58+
1. Leave the [**Redirect URI**](../active-directory/develop/reply-url.md) section empty.
5359

5460
1. Select **Register** to create the application.
5561

5662
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later.
5763

58-
1. Under the **Manage** section of the side menu, select **Expose an API**. **Add** the **Application ID URI** with the default value. Record this value for later.
64+
1. Under the **Manage** section of the side menu, select **Expose an API** and set the **Application ID URI** with the default value. If you're developing a separate client app to obtain OAuth 2.0 tokens for access to the backend-app, record this value for later.
5965

60-
1. On the **Expose an API** page, select **+ Add a scope** to display the **Add a scope** page.
61-
1. Enter a new **Scope name** for a scope that's supported by the API (for example, **Files.Read**).
62-
1. In **Who can consent?**, make a selection for your scenario, such as **Admins and users**. Select **Admins only** for higher privileged environments.
63-
1. Enter **Admin consent display name** and **Admin consent description**.
66+
1. Select the **Add a scope** button to display the **Add a scope** page:
67+
1. Enter a new **Scope name**, **Admin consent display name**, and **Admin consent description**.
6468
1. Make sure the **Enabled** scope state is selected.
65-
1. Select **Add scope** to create the scope.
66-
67-
1. Repeat the previous step to add all scopes supported by your API.
68-
69-
1. Once the scopes are created, make a note of them for use later.
7069

70+
1. Select the **Add scope** button to create the scope.
7171

72-
## Register an application in Microsoft Entra ID to represent the client app
73-
74-
While not shown in this article, in most scenarios you would register a second application in Microsoft Entra ID (*client-app*) to represent a client application that calls the API. The app registration must have permissions to call the backend app. Details about app registration are specific to your scenario.
75-
76-
Configure the client application to use Microsoft Entra ID to request valid OAuth tokens granting access to the API. Present the token in the request to API Management (for example, in an Authorization header).
77-
78-
Development of a client application that uses Microsoft Entra ID to request valid OAuth tokens is beyond the scope of this article and specific to your scenario. For examples and guidance, see [Microsoft identity platform code samples](entra/identity-platform/sample-v2-code).
72+
1. Repeat the previous two steps to add all scopes supported by your API.
7973

74+
1. Once the scopes are created, make a note of them for use later.
8075

81-
## Configure a token validation policy to preauthorize requests
76+
## Configure a JWT validation policy to pre-authorize requests
8277

8378
[!INCLUDE [api-management-configure-validate-jwt](../../includes/api-management-configure-validate-jwt.md)]
8479

85-
8680
## Authorization workflow
8781

88-
THe following steps make up a typical authorization workflow for an API in API Management that uses OAuth 2.0 authorization with Microsoft Entra ID.
89-
90-
1. A user or application acquires a token from Microsoft Entra ID with permissions that grant access to the backend-app. If you use the v2 endpoint, ensure that the accessTokenAcceptedVersion property is set to 2 in the application manifest of the backend-app and any client app that you configure.
82+
1. A user or application acquires a token from Microsoft Entra ID with permissions that grant access to the backend-app. If you use the v2 endpoint, ensure that the accessTokenAcceptedVersion property is set to 2 in the application manifest of the back end app and any client app that you configure.
9183

9284
1. The token is added in the Authorization header of API requests to API Management.
9385

94-
1. API Management validates the token by using the `validate-azure-ad-token` policy.
86+
1. API Management validates the token by using the `validate-jwt` policy.
9587

9688
* If a request doesn't have a valid token, API Management blocks it.
9789

@@ -105,4 +97,4 @@ THe following steps make up a typical authorization workflow for an API in API M
10597

10698
- Learn more about [Microsoft Entra ID and OAuth2.0](../active-directory/develop/authentication-vs-authorization.md).
10799

108-
- Learn more about [authentication and authorization options](authentication-authorization-overview.md) in API Management.
100+
- For other ways to secure your back-end service, see [Mutual certificate authentication](./api-management-howto-mutual-certificates.md).

0 commit comments

Comments
 (0)