Skip to content

Commit 385742e

Browse files
authored
Merge pull request #228428 from MicrosoftDocs/release-ga-apim-authorizations
[APIM] Authorizations GA release content
2 parents d9cab34 + cebbf4c commit 385742e

File tree

48 files changed

+683
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+683
-390
lines changed

.openpublishing.redirection.api-management.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@
149149
"source_path_from_root": "/articles/api-management/validation-policies.md",
150150
"redirect_url": "/azure/api-management/api-management-policies#validation-policies",
151151
"redirect_document_id": false
152+
},
153+
{
154+
"source_path_from_root": "/articles/api-management/authorizations-how-to.md",
155+
"redirect_url": "/azure/api-management/authorizations-how-to-github",
156+
"redirect_document_id": false
157+
},
158+
{
159+
"source_path_from_root": "/articles/api-management/authorizations-reference.md",
160+
"redirect_url": "/azure/api-management/authorizations-configure-common-providers",
161+
"redirect_document_id": false
152162
}
153163
]
154164
}

articles/api-management/TOC.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@
8383
href: ./security-controls-policy.md
8484
- name: Security baseline
8585
href: /security/benchmark/azure/baselines/api-management-security-baseline?toc=/azure/api-management/&bc=/azure/api-management/breadcrumb/toc.json
86-
- name: Authentication and authorization
86+
- name: Authentication and authorization options
8787
href: authentication-authorization-overview.md
88+
- name: API authorizations
89+
href: authorizations-overview.md
90+
displayName: OAuth
8891
- name: Observability
8992
href: observability.md
9093
displayName: monitoring
@@ -289,12 +292,16 @@
289292
- name: Mitigate OWASP API threats
290293
href: mitigate-owasp-api-threats.md
291294
displayName: OWASP top 10, vulnerability, vulnerabilities
292-
- name: Manage API authorizations
295+
- name: Configure API authorizations for OAuth 2.0 backends
293296
items:
294-
- name: Authorizations overview
295-
href: authorizations-overview.md
296-
- name: Configure and use authorization
297-
href: authorizations-how-to.md
297+
- name: Configure common authorization providers
298+
href: authorizations-configure-common-providers.md
299+
- name: Configure and use authorization - Azure AD
300+
href: authorizations-how-to-azure-ad.md
301+
- name: Configure and use authorization - GitHub
302+
href: authorizations-how-to-github.md
303+
- name: Configure multiple authorization connections
304+
href: configure-authorization-connection.md
298305
- name: Set up backend authentication
299306
items:
300307
- name: Mutual certificate authentication
@@ -530,8 +537,6 @@
530537
href: xml-to-json-policy.md
531538
- name: xsl-transform
532539
href: xsl-transform-policy.md
533-
- name: Authorizations - identity providers
534-
href: authorizations-reference.md
535540
- name: Azure Policy built-ins
536541
displayName: samples, policies, definitions
537542
href: ./policy-reference.md

articles/api-management/api-management-gateways-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Managed and self-hosted gateways support all available [policies](api-management
106106
| Policy | Managed (Dedicated) | Managed (Consumption) | Self-hosted<sup>1</sup> |
107107
| --- | ----- | ----- | ---------- |
108108
| [Dapr integration](api-management-policies.md#dapr-integration-policies) ||| ✔️ |
109-
| [Get authorization context](get-authorization-context-policy.md) | ✔️ | ||
109+
| [Get authorization context](get-authorization-context-policy.md) | ✔️ | ✔️ ||
110110
| [Quota and rate limit](api-management-policies.md#access-restriction-policies) | ✔️ | ✔️<sup>2</sup> | ✔️<sup>3</sup>
111111
| [Set GraphQL resolver](set-graphql-resolver-policy.md) | ✔️ |||
112112

articles/api-management/authentication-authorization-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ There are different reasons for wanting to do this. For example:
8585

8686
### Token management by API Management
8787

88-
API Management also supports acquisition and secure storage of OAuth 2.0 tokens for certain downstream services using the [authorizations](authorizations-overview.md) (preview) feature, including through use of custom policies and caching.
88+
API Management also supports acquisition and secure storage of OAuth 2.0 tokens for certain downstream services using the [authorizations](authorizations-overview.md) feature, including through use of custom policies and caching.
8989

90-
With authorizations, API Management manages the tokens for access to OAuth 2.0 backends, simplifying the development of client apps that access APIs.
90+
With authorizations, API Management manages the tokens for access to OAuth 2.0 backends, allowing you to delegate authentication to your API Management instance to simplify access by client apps to a given backend service or SaaS platform.
9191

9292
### Other options
9393

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Configure authorization providers - Azure API Management | Microsoft Docs
3+
description: Learn how to configure common identity providers for authorizations in Azure API Management. Example providers are Azure Active Directory and a generic OAuth 2.0 provider. An authorization manages authorization tokens to an OAuth 2.0 backend service.
4+
services: api-management
5+
author: dlepow
6+
ms.service: api-management
7+
ms.topic: how-to
8+
ms.date: 02/07/2023
9+
ms.author: danlep
10+
---
11+
12+
# Configure identity providers for API authorizations
13+
14+
In this article, you learn about configuring identity providers for [authorizations](authorizations-overview.md) in your API Management instance. Settings for the following common providers are shown:
15+
16+
* Azure AD provider
17+
* Generic OAuth 2.0 provider
18+
19+
You add identity provider settings when configuring an authorization in your API Management instance. For a step-by-step example of configuring an Azure AD provider and authorization, see:
20+
21+
* [Create an authorization with the Microsoft Graph API](authorizations-how-to-azure-ad.md)
22+
23+
## Prerequisites
24+
25+
To configure any of the supported providers in API Management, first configure an OAuth 2.0 app in the identity provider that will be used to authorize API access. For configuration details, see the provider's developer documentation.
26+
27+
* If you're creating an authorization that uses the authorization code grant type, configure a **Redirect URL** (sometimes called Authorization Callback URL or a similar name) in the app. For the value, enter `https://authorization-manager.consent.azure-apim.net/redirect/apim/<YOUR-APIM-SERVICENAME>`.
28+
29+
* Depending on your scenario, configure app settings such as scopes (API permissions).
30+
31+
* Minimally, retrieve the following app credentials that will be configured in API Management: the app's **client id** and **client secret**.
32+
33+
* Depending on the provider and your scenario, you might need to retrieve other settings such as authorization endpoint URLs or scopes.
34+
35+
## Azure AD provider
36+
37+
Authorizations support the Azure AD identity provider, which is the identity service in Microsoft Azure that provides identity management and access control capabilities. It allows users to securely sign in using industry-standard protocols.
38+
39+
* **Supported grant types**: authorization code, client credentials
40+
41+
> [!NOTE]
42+
> Currently, the Azure AD authorization provider supports only the Azure AD v1.0 endpoints.
43+
44+
45+
### Azure AD provider settings
46+
47+
[!INCLUDE [api-management-authorization-azure-ad-provider](../../includes/api-management-authorization-azure-ad-provider.md)]
48+
49+
50+
## Generic OAuth 2.0 providers
51+
52+
Authorizations support two generic providers:
53+
* Generic OAuth 2.0
54+
* Generic OAuth 2.0 with PKCE
55+
56+
A generic provider allows you to use your own OAuth 2.0 identity provider based on your specific needs.
57+
58+
> [!NOTE]
59+
> We recommend using the generic OAuth 2.0 with PKCE provider for improved security if your identity provider supports it. [Learn more](https://oauth.net/2/pkce/)
60+
61+
* **Supported grant types**: authorization code, client credentials
62+
63+
### Generic authorization provider settings
64+
65+
[!INCLUDE [api-management-authorization-generic-provider](../../includes/api-management-authorization-generic-provider.md)]
66+
67+
## Other identity providers
68+
69+
API Management supports several providers for popular SaaS offerings, such as GitHub. You can select from a list of these providers in the Azure portal when you create an authorization.
70+
71+
:::image type="content" source="media/authorizations-configure-common-providers/saas-providers.png" alt-text="Screenshot of identity providers listed in the portal.":::
72+
73+
**Supported grant types**: authorization code, client credentials (depends on provider)
74+
75+
Required settings for these providers differ from provider to provider but are similar to those for the [generic OAuth 2.0 providers](#generic-oauth-20-providers). Consult the developer documentation for each provider.
76+
77+
## Next steps
78+
79+
* Learn more about [authorizations](authorizations-overview.md) in API Management.
80+
* Create an authorization for [Azure AD](authorizations-how-to-azure-ad.md) or [GitHub](authorizations-how-to-github.md).
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: Create authorization with Microsoft Graph API - Azure API Management | Microsoft Docs
3+
description: Learn how to create and use an authorization to the Microsoft Graph API in Azure API Management. An authorization manages authorization tokens to an OAuth 2.0 backend service.
4+
services: api-management
5+
author: dlepow
6+
ms.service: api-management
7+
ms.topic: how-to
8+
ms.date: 04/10/2023
9+
ms.author: danlep
10+
---
11+
12+
# Create an authorization with the Microsoft Graph API
13+
14+
This article guides you through the steps required to create an [authorization](authorizations-overview.md) with the Microsoft Graph API within Azure API Management. The authorization code grant type is used in this example.
15+
16+
You learn how to:
17+
18+
> [!div class="checklist"]
19+
> * Create an Azure AD application
20+
> * Create and configure an authorization in API Management
21+
> * Configure an access policy
22+
> * Create a Microsoft Graph API in API Management and configure a policy
23+
> * Test your Microsoft Graph API in API Management
24+
25+
## Prerequisites
26+
27+
- Access to an Azure Active Directory (Azure AD) tenant where you have permissions to create an app registration and to grant admin consent for the app's permissions. [Learn more](../active-directory/roles/delegate-app-roles.md#restrict-who-can-create-applications)
28+
29+
If you want to create your own developer tenant, you can sign up for the [Microsoft 365 Developer Program](https://developer.microsoft.com/microsoft-365/dev-program).
30+
- A running API Management instance. If you need to, [create an Azure API Management instance](get-started-create-service-instance.md).
31+
- Enable a [system-assigned managed identity](api-management-howto-use-managed-service-identity.md) for API Management in the API Management instance.
32+
33+
## Step 1: Create an Azure AD application
34+
35+
Create an Azure AD application for the API and give it the appropriate permissions for the requests that you want to call.
36+
37+
1. Sign into the [Azure portal](https://portal.azure.com/) with an account with sufficient permissions in the tenant.
38+
1. Under **Azure Services**, search for **Azure Active Directory**.
39+
1. On the left menu, select **App registrations**, and then select **+ New registration**.
40+
:::image type="content" source="media/authorizations-how-to-azure-ad/create-registration.png" alt-text="Screenshot of creating an Azure AD app registration in the portal.":::
41+
42+
1. On the **Register an application** page, enter your application registration settings:
43+
1. In **Name**, enter a meaningful name that will be displayed to users of the app, such as *MicrosoftGraphAuth*.
44+
1. In **Supported account types**, select an option that suits your scenario, for example, **Accounts in this organizational directory only (Single tenant)**.
45+
1. Set the **Redirect URI** to **Web**, and enter `https://authorization-manager.consent.azure-apim.net/redirect/apim/<YOUR-APIM-SERVICENAME>`, substituting the name of the API Management service where you will configure the authorization provider.
46+
1. Select **Register**.
47+
1. On the left menu, select **API permissions**, and then select **+ Add a permission**.
48+
:::image type="content" source="./media/authorizations-how-to-azure-ad/add-permission.png" alt-text="Screenshot of adding an API permission in the portal.":::
49+
50+
1. Select **Microsoft Graph**, and then select **Delegated permissions**.
51+
> [!NOTE]
52+
> Make sure the permission **User.Read** with the type **Delegated** has already been added.
53+
1. Type **Team**, expand the **Team** options, and then select **Team.ReadBasic.All**. Select **Add permissions**.
54+
1. Next, select **Grant admin consent for Default Directory**. The status of the permissions will change to **Granted for Default Directory**.
55+
1. On the left menu, select **Overview**. On the **Overview** page, find the **Application (client) ID** value and record it for use in Step 2.
56+
1. On the left menu, select **Certificates & secrets**, and then select **+ New client secret**.
57+
:::image type="content" source="media/authorizations-how-to-azure-ad/create-secret.png" alt-text="Screenshot of creating an app secret in the portal.":::
58+
59+
1. Enter a **Description**.
60+
1. Select any option for **Expires**.
61+
1. Select **Add**.
62+
1. Copy the client secret's **Value** before leaving the page. You will need it in Step 2.
63+
64+
## Step 2: Configure an authorization in API Management
65+
66+
1. Sign into the [portal](https://portal.azure.com) and go to your API Management instance.
67+
1. On the left menu, select **Authorizations**, and then select **+ Create**.
68+
:::image type="content" source="media/authorizations-how-to-azure-ad/create-authorization.png" alt-text="Screenshot of creating an API authorization in the portal.":::
69+
1. On the **Create authorization** page, enter the following settings, and select **Create**:
70+
71+
|Settings |Value |
72+
|---------|---------|
73+
|**Provider name** | A name of your choice, such as *aad-01* |
74+
|**Identity provider** | Select **Azure Active Directory v1** |
75+
|**Grant type** | Select **Authorization code** |
76+
|**Client id** | Paste the value you copied earlier from the app registration |
77+
|**Client secret** | Paste the value you copied earlier from the app registration |
78+
|**Resource URL** | `https://graph.microsoft.com` |
79+
|**Tenant ID** | Optional for Azure AD identity provider. Default is *Common* |
80+
|**Scopes** | Optional for Azure AD identity provider. Automatically configured from AD app's API permissions. |
81+
|**Authorization name** | A name of your choice, such as *aad-auth-01* |
82+
83+
1. After the authorization provider and authorization are created, select **Next**.
84+
85+
## Step 3: Authorize with Azure AD and configure an access policy
86+
87+
1. On the **Login** tab, select **Login with Azure Active Directory**. Before the authorization will work, it needs to be authorized.
88+
:::image type="content" source="media/authorizations-how-to-azure-ad/login-azure-ad.png" alt-text="Screenshot of login with Azure AD in the portal.":::
89+
90+
1. When prompted, sign in to your organizational account.
91+
1. On the confirmation page, select **Allow access**.
92+
1. After successful authorization, the browser is redirected to API Management and the window is closed. In API Management, select **Next**.
93+
1. On the **Access policy** page, create an access policy so that API Management has access to use the authorization. Ensure that a managed identity is configured for API Management. [Learn more about managed identities in API Management](api-management-howto-use-managed-service-identity.md#create-a-system-assigned-managed-identity).
94+
1. For this example, select **API Management service `<service name>`**.
95+
96+
:::image type="content" source="media/authorizations-how-to-azure-ad/create-access-policy.png" alt-text="Screenshot of selecting a managed identity to use the authorization.":::
97+
98+
1. Select **Complete**.
99+
100+
> [!NOTE]
101+
> If you update your Microsoft Graph permissions after this step, you will have to repeat Steps 2 and 3.
102+
103+
## Step 4: Create a Microsoft Graph API in API Management and configure a policy
104+
105+
1. Sign into the [portal](https://portal.azure.com) and go to your API Management instance.
106+
1. On the left menu, select **APIs > + Add API**.
107+
1. Select **HTTP** and enter the following settings. Then select **Create**.
108+
109+
|Setting |Value |
110+
|---------|---------|
111+
|**Display name** | *msgraph* |
112+
|**Web service URL** | `https://graph.microsoft.com/v1.0` |
113+
|**API URL suffix** | *msgraph* |
114+
115+
1. Navigate to the newly created API and select **Add Operation**. Enter the following settings and select **Save**.
116+
117+
|Setting |Value |
118+
|---------|---------|
119+
|**Display name** | *getprofile* |
120+
|**URL** for GET | /me |
121+
122+
1. Follow the preceding steps to add another operation with the following settings.
123+
124+
|Setting |Value |
125+
|---------|---------|
126+
|**Display name** | *getJoinedTeams* |
127+
|**URL** for GET | /me/joinedTeams |
128+
129+
1. Select **All operations**. In the **Inbound processing** section, select the (**</>**) (code editor) icon.
130+
1. Copy the following, and paste in the policy editor. Make sure the `provider-id` and `authorization-id` correspond to the values you configured in Step 2. Select **Save**.
131+
132+
```xml
133+
<policies>
134+
<inbound>
135+
<base />
136+
<get-authorization-context provider-id="aad-01" authorization-id="aad-auth-01" context-variable-name="auth-context" identity-type="managed" ignore-error="false" />
137+
<set-header name="authorization" exists-action="override">
138+
<value>@("Bearer " + ((Authorization)context.Variables.GetValueOrDefault("auth-context"))?.AccessToken)</value>
139+
</set-header>
140+
</inbound>
141+
<backend>
142+
<base />
143+
</backend>
144+
<outbound>
145+
<base />
146+
</outbound>
147+
<on-error>
148+
<base />
149+
</on-error>
150+
</policies>
151+
```
152+
The preceding policy definition consists of two parts:
153+
154+
* The [get-authorization-context](get-authorization-context-policy.md) policy fetches an authorization token by referencing the authorization provider and authorization that were created earlier.
155+
* The [set-header](set-header-policy.md) policy creates an HTTP header with the fetched authorization token.
156+
157+
## Step 5: Test the API
158+
1. On the **Test** tab, select one operation that you configured.
159+
1. Select **Send**.
160+
161+
:::image type="content" source="media/authorizations-how-to-azure-ad/graph-api-response.png" alt-text="Screenshot of testing the Graph API in the portal.":::
162+
163+
A successful response returns user data from the Microsoft Graph.
164+
165+
## Next steps
166+
167+
* Learn more about [access restriction policies](api-management-access-restriction-policies.md)
168+
* Learn more about [scopes and permissions](../active-directory/develop/scopes-oidc.md) in Azure AD.

0 commit comments

Comments
 (0)