Skip to content

Commit 9c264fa

Browse files
committed
policy update + merge docs
1 parent 36ada20 commit 9c264fa

File tree

3 files changed

+77
-132
lines changed

3 files changed

+77
-132
lines changed

articles/active-directory-b2c/TOC.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@
310310
- name: Migrate web API to b2clogin.com
311311
href: multiple-token-endpoints.md
312312
displayName: migrate, b2clogin, owin
313-
- name: Migrate APIM API to b2clogin.com
314-
href: multiple-token-endpoints-apim.md
315-
displayName: migrate, b2clogin, apim, api management
316313
- name: Automation
317314
items:
318315
- name: Export usage report
@@ -321,6 +318,9 @@
321318
href: active-directory-b2c-devquickstarts-graph-dotnet.md
322319
- name: Audit logs
323320
href: active-directory-b2c-reference-audit-logs.md
321+
- name: Secure API Management API
322+
href: secure-api-management.md
323+
displayName: apim, api management, migrate, b2clogin.com
324324
- name: Compliance
325325
items:
326326
- name: User access

articles/active-directory-b2c/multiple-token-endpoints-apim.md

Lines changed: 0 additions & 105 deletions
This file was deleted.

articles/active-directory-b2c/secure-api-management.md

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: celestedg
88
ms.service: active-directory
99
ms.workload: identity
1010
ms.topic: conceptual
11-
ms.date: 08/28/2019
11+
ms.date: 08/31/2019
1212
ms.author: marsma
1313
ms.subservice: B2C
1414
---
@@ -61,9 +61,9 @@ https://yourb2ctenant.b2clogin.com/yourb2ctenant.onmicrosoft.com/v2.0/.well-know
6161
https://yourb2ctenant.b2clogin.com/99999999-0000-0000-0000-999999999999/v2.0/
6262
```
6363

64-
## Configure claims validation in Azure API Management
64+
## Configure inbound policy in Azure API Management
6565

66-
You're now ready to add the inbound policy in Azure API Management that validates API calls. By adding an inbound policy that verifies the audience and issuer claims in an access token, you can ensure that only API calls with a valid token are accepted.
66+
You're now ready to add the inbound policy in Azure API Management that validates API calls. By adding a [JWT validation](../api-management/api-management-access-restriction-policies.md#ValidateJWT) policy that verifies the audience and issuer in an access token, you can ensure that only API calls with a valid token are accepted.
6767

6868
1. Browse to your Azure API Management instance in the [Azure portal](https://portal.azure.com)
6969
1. Select **APIs**
@@ -72,23 +72,21 @@ You're now ready to add the inbound policy in Azure API Management that validate
7272
1. Under **Inbound processing**, select **\</\>** to open the policy code editor
7373
1. Place the following `<validate-jwt>` tag inside the `<inbound>` policy.
7474

75-
1. Update the `url` value in the `<openid-config>` tag with your policy's well-known configuration URL.
76-
1. Update the `aud` value with Application ID of the application you created previously in your B2C tenant (for example, *webapp1*).
77-
1. Update the `iss` value with the token issuer endpoint you recorded earlier.
75+
1. Update the `url` value in the `<openid-config>` element with your policy's well-known configuration URL.
76+
1. Update the `<audience>` element with Application ID of the application you created previously in your B2C tenant (for example, *webapp1*).
77+
1. Update the `<issuer>` element with the token issuer endpoint you recorded earlier.
7878

7979
```xml
8080
<policies>
8181
<inbound>
8282
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
8383
<openid-config url="https://yourb2ctenant.b2clogin.com/yourb2ctenant.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_signupsignin1" />
84-
<required-claims>
85-
<claim name="aud">
86-
<value>44444444-0000-0000-0000-444444444444</value>
87-
</claim>
88-
<claim name="iss">
89-
<value>https://yourb2ctenant.b2clogin.com/99999999-0000-0000-0000-999999999999/v2.0/</value>
90-
</claim>
91-
</required-claims>
84+
<audiences>
85+
<audience>44444444-0000-0000-0000-444444444444</audience>
86+
</audiences>
87+
<issuers>
88+
<issuer>https://yourb2ctenant.b2clogin.com/99999999-0000-0000-0000-999999999999/v2.0/</issuer>
89+
</issuers>
9290
</validate-jwt>
9391
<base />
9492
</inbound>
@@ -124,12 +122,12 @@ You first need a token issued by Azure AD B2C to use in the `Authorization` head
124122

125123
### Get API subscription key
126124

127-
A client application (in this case, Postman) that calls a published API must include a valid API Management subscription key in its HTTP requests. To get a subscription key to include in your Postman HTTP request:
125+
A client application (in this case, Postman) that calls a published API must include a valid API Management subscription key in its HTTP requests to the API. To get a subscription key to include in your Postman HTTP request:
128126

129127
1. Browse to your Azure API Management service instance in the [Azure portal](https://portal.azure.com)
130128
1. Select **Subscriptions**
131129
1. Select the ellipsis for **Product: Unlimited**, then select **Show/hide keys**
132-
1. Record the **PRIMARY KEY** for the product. You use this for the `Ocp-Apim-Subscription-Key` header in your HTTP request in Postman.
130+
1. Record the **PRIMARY KEY** for the product. You use this key for the `Ocp-Apim-Subscription-Key` header in your HTTP request in Postman.
133131

134132
![Subscription key page with Show/hide keys selected in Azure portal](media/secure-apim-with-b2c-token/portal-04-api-subscription-key.png)
135133

@@ -139,9 +137,7 @@ With the access token and APIM subscription key recorded, you're now ready to te
139137

140138
1. Create a new `GET` request in [Postman](https://www.getpostman.com/). For the request URL, specify the speakers list endpoint of the API you published as one of the prerequisites. For example:
141139

142-
```
143-
https://contosoapim.azure-api.net/conference/speakers
144-
```
140+
`https://contosoapim.azure-api.net/conference/speakers`
145141

146142
1. Next, add the following headers:
147143

@@ -198,12 +194,66 @@ Now that you've made a successful request, test the failure case to ensure that
198194
}
199195
```
200196

201-
Congratulations! You've just verified that only callers with a valid access token issued by Azure AD B2C can make successful requests to your Azure API Management API.
197+
Congratulations! You've verified that only callers with a valid access token issued by Azure AD B2C can make successful requests to your Azure API Management API.
202198

203-
## Next steps
199+
## Support multiple applications and issuers
200+
201+
Several applications typically interact with a single REST API. To allow multiple applications to call your API, add their application IDs to the `<audiences>` element in the APIM inbound policy.
202+
203+
```XML
204+
<!-- Accept requests from multiple applications -->
205+
<audiences>
206+
<audience>44444444-0000-0000-0000-444444444444</audience>
207+
<audience>66666666-0000-0000-0000-666666666666</audience>
208+
</audiences>
209+
```
204210

205-
### Migrate APIM APIs to b2clogin.com
211+
Similarly, to support multiple token issuers, add their endpoint URIs to the `<audiences>` element in the APIM inbound policy.
212+
213+
```XML
214+
<!-- Accept tokens from multiple issuers -->
215+
<issuers>
216+
<issuer>https://yourb2ctenant.b2clogin.com/99999999-0000-0000-0000-999999999999/v2.0/</issuer>
217+
<issuer>https://login.microsoftonline.com/99999999-0000-0000-0000-999999999999/v2.0/</issuer>
218+
</issuers>
219+
```
220+
221+
## Migrate to b2clogin.com
222+
223+
If you have an APIM API that validates tokens issued by the legacy `login.microsoftonline.com` endpoint, you should migrate the API and the applications that call it to use tokens issued by [b2clogin.com](b2clogin.md).
224+
225+
You can follow this general process to perform a staged migration:
226+
227+
1. Add support in your APIM inbound policy for tokens issued by both b2clogin.com and login.microsoftonline.com.
228+
1. Update your applications one at a time to obtain tokens from the b2clogin.com endpoint.
229+
1. Once all of your applications are correctly obtaining tokens from b2clogin.com, remove support for login.microsoftonline.com-issued tokens from the API.
230+
231+
The following example APIM inbound policy illustrates how to accept tokens issued by both b2clogin.com login.microsoftonline.com. Additionally, it supports API requests from two applications.
232+
233+
```XML
234+
<policies>
235+
<inbound>
236+
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
237+
<openid-config url="https://yourb2ctenant.b2clogin.com/yourb2ctenant.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_signupsignin1" />
238+
<audiences>
239+
<audience>44444444-0000-0000-0000-444444444444</audience>
240+
<audience>66666666-0000-0000-0000-666666666666</audience>
241+
</audiences>
242+
<issuers>
243+
<issuer>https://login.microsoftonline.com/99999999-0000-0000-0000-999999999999/v2.0/</issuer>
244+
<issuer>https://yourb2ctenant.b2clogin.com/99999999-0000-0000-0000-999999999999/v2.0/</issuer>
245+
</issuers>
246+
</validate-jwt>
247+
<base />
248+
</inbound>
249+
<backend> <base /> </backend>
250+
<outbound> <base /> </outbound>
251+
<on-error> <base /> </on-error>
252+
</policies>
253+
```
254+
255+
## Next steps
206256

207-
If you have a currently deployed API in Azure API Management that's configured with a secure access policy accepting tokens from the legacy `login.microsoftonline.com` issuer endpoint, you should migrate the API and its client applications to use the recommended `b2clogin.com` issuer. During such a migration, you might need to support tokens issued by both endpoints to allow for a staged migration of your client applications to `b2clogin.com`.
257+
For additional details on Azure API Management policies, see the [APIM policy reference index](../api-management/api-management-policies.md).
208258

209-
[Migrate an Azure API Management API to b2clogin.com](multiple-token-endpoints-apim.md)
259+
You can find information about migrating OWIN-based web APIs and their applications to b2clogin.com in [Migrate an OWIN-based web API to b2clogin.com](multiple-token-endpoints.md).

0 commit comments

Comments
 (0)