Skip to content

Commit 169d34a

Browse files
authored
Update secure-rest-api.md
Merging @msmimart suggested changes
1 parent 9cb999e commit 169d34a

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ manager: celestedg
99
ms.service: active-directory
1010
ms.workload: identity
1111
ms.topic: conceptual
12-
ms.date: 03/25/2020
12+
ms.date: 03/26/2020
1313
ms.author: mimart
1414
ms.subservice: B2C
1515
---
@@ -20,7 +20,7 @@ ms.subservice: B2C
2020

2121
When integrating a REST API within an Azure AD B2C user journey, you must protect your REST API endpoint with authentication. This ensures that only services that have proper credentials, such as Azure AD B2C, can make calls to your REST API endpoint.
2222

23-
Learn how to integrate a REST API within your Azure AD B2C user journey in the [validate user input](custom-policy-rest-api-claims-validation.md), and [Add REST API claims exchanges to custom policies](custom-policy-rest-api-claims-exchange.md) articles.
23+
Learn how to integrate a REST API within your Azure AD B2C user journey in the [validate user input](custom-policy-rest-api-claims-validation.md) and [Add REST API claims exchanges to custom policies](custom-policy-rest-api-claims-exchange.md) articles.
2424

2525
This article will explore how to secure your REST API with either HTTP basic, client certificate or OAuth2 authentication.
2626

@@ -31,19 +31,19 @@ Complete the steps in one of the following 'How to' guides:
3131
- [Integrate REST API claims exchanges in your Azure AD B2C user journey to validate user input](custom-policy-rest-api-claims-validation.md).
3232
- [Add REST API claims exchanges to custom policies](custom-policy-rest-api-claims-exchange.md)
3333

34-
## HTTP Basic Authentication
34+
## HTTP basic authentication
3535

36-
HTTP Basic authentication is defined in [RFC 2617](https://tools.ietf.org/html/rfc2617). Basic authentication works as follows, Azure AD B2C sends an HTTP request, with the client credentials in the Authorization header. The credentials are formatted as the string "name:password", base64-encoded.
36+
HTTP basic authentication is defined in [RFC 2617](https://tools.ietf.org/html/rfc2617). Basic authentication works as follows: Azure AD B2C sends an HTTP request with the client credentials in the Authorization header. The credentials are formatted as the base64-encoded string "name:password".
3737

3838
### Add REST API username and password policy keys
3939

40-
To configure a REST API technical profile with HTTP Basic Authentication, create the following cryptographic keys to store the username and password:
40+
To configure a REST API technical profile with HTTP basic authentication, create the following cryptographic keys to store the username and password:
4141

4242
1. Sign in to the [Azure portal](https://portal.azure.com/).
4343
1. Make sure you're using the directory that contains your Azure AD B2C tenant. Select the **Directory + subscription** filter in the top menu and choose your Azure AD B2C directory.
4444
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
4545
1. On the Overview page, select **Identity Experience Framework**.
46-
1. Select **Policy Keys** and then select **Add**.
46+
1. Select **Policy Keys**, and then select **Add**.
4747
1. For **Options**, select **Manual**.
4848
1. For **Name**, type **RestApiUsername**.
4949
The prefix *B2C_1A_* might be added automatically.
@@ -103,7 +103,7 @@ The following is an example of a RESTful technical profile configured with HTTP
103103

104104
## HTTPS client certificate authentication
105105

106-
Client Certificate Authentication is a mutual certificate-based authentication, where the client, Azure AD B2C provides its Client Certificate to the Server to prove its identity. This happens as a part of the SSL Handshake. Only services that have proper certificates, such as Azure AD B2C, can access your REST API service. The Client Certificate is an X.509 digital certificate and must be signed by a Certificate Authority in Production.
106+
Client certificate authentication is a mutual certificate-based authentication, where the client, Azure AD B2C, provides its client certificate to the server to prove its identity. This happens as a part of the SSL handshake. Only services that have proper certificates, such as Azure AD B2C, can access your REST API service. The client certificate is an X.509 digital certificate. In production environments, it must be signed by a certificate authority.
107107

108108
### Prepare a self-signed certificate (optional)
109109

@@ -120,19 +120,19 @@ For non-production environments, if you don't already have a certificate, you ca
120120
-NotAfter (Get-Date).AddMonths(12) `
121121
-CertStoreLocation "Cert:\CurrentUser\My"
122122
```
123-
1. Open **Manage user certificates** > **Current User** > **Personal** > **Certificates** > *yourappname.yourtenant.onmicrosoft.com*
124-
1. Select the certificate > **Action** > **All Tasks** > **Export**
125-
1. Select **Yes** > **Next** > **Yes, export the private key** > **Next**
126-
1. Accept the defaults for **Export File Format**
127-
1. Provide a password for the certificate
123+
1. Open **Manage user certificates** > **Current User** > **Personal** > **Certificates** > *yourappname.yourtenant.onmicrosoft.com*.
124+
1. Select the certificate > **Action** > **All Tasks** > **Export**.
125+
1. Select **Yes** > **Next** > **Yes, export the private key** > **Next**.
126+
1. Accept the defaults for **Export File Format**.
127+
1. Provide a password for the certificate.
128128
129-
### Add client certificate policy key
129+
### Add a client certificate policy key
130130
131131
1. Sign in to the [Azure portal](https://portal.azure.com/).
132132
1. Make sure you're using the directory that contains your Azure AD B2C tenant. Select the **Directory + subscription** filter in the top menu and choose your Azure AD B2C directory.
133133
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
134134
1. On the Overview page, select **Identity Experience Framework**.
135-
1. Select **Policy Keys** and then select **Add**.
135+
1. Select **Policy Keys**, and then select **Add**.
136136
1. In the **Options** box, select **Upload**.
137137
1. In the **Name** box, type **RestApiClientCertificate**.
138138
The prefix *B2C_1A_* is added automatically.
@@ -156,7 +156,7 @@ After creating the necessary key, configure your REST API technical profile meta
156156
</CryptographicKeys>
157157
```
158158
159-
The following is an example of a RESTful technical profile configured with HTTP client certificate:
159+
The following is an example of a RESTful technical profile configured with an HTTP client certificate:
160160
161161
```xml
162162
<ClaimsProvider>
@@ -180,26 +180,26 @@ The following is an example of a RESTful technical profile configured with HTTP
180180
</ClaimsProvider>
181181
```
182182

183-
## OAuth2 Bearer authentication
183+
## OAuth2 bearer authentication
184184

185-
Bearer token authentication is defined in [OAuth2.0 Authorization Framework: Bearer Token Usage (RFC 6750)](https://www.rfc-editor.org/rfc/rfc6750.txt). Bearer token authentication works as follows, Azure AD B2C sends an HTTP request, with a token in the Authorization header.
185+
Bearer token authentication is defined in [OAuth2.0 Authorization Framework: Bearer Token Usage (RFC 6750)](https://www.rfc-editor.org/rfc/rfc6750.txt). In bearer token authentication, Azure AD B2C sends an HTTP request with a token in the authorization header.
186186

187187
```http
188188
Authorization: Bearer <token>
189189
```
190190

191-
A Bearer Token is an opaque string. It can be a JWT access token or any string the REST API expecting Azure AD B2C to send in the Authorization header. Azure AD B2C supports:
191+
A bearer token is an opaque string. It can be a JWT access token or any string that the REST API expects Azure AD B2C to send in the authorization header. Azure AD B2C supports the following types:
192192

193-
- A bearer token - To be able to send the bearer token in the Restful technical profile, your policy needs first to acquire the bearer token and then use it in the RESTful technical profile.
194-
- A static bearer token - Use this approach when your REST API issues a log term access token. To use a static bearer token, create a policy key and make a reference from the RESTful technical profile to your policy key.
193+
- **Bearer token**. To be able to send the bearer token in the Restful technical profile, your policy needs to first acquire the bearer token and then use it in the RESTful technical profile.
194+
- **Static bearer token**. Use this approach when your REST API issues a long-term access token. To use a static bearer token, create a policy key and make a reference from the RESTful technical profile to your policy key.
195195

196196
## Using OAuth2 Bearer
197197

198-
The following demonstrates how to use client credentials to obtain a bearer token and then pass this into the Authorization header of the REST API calls.
198+
The following steps demonstrate how to use client credentials to obtain a bearer token and pass it into the Authorization header of the REST API calls.
199199

200-
### Define a Claim to store the bearer token
200+
### Define a claim to store the bearer token
201201

202-
A claim provides a temporary storage of data during an Azure AD B2C policy execution. The [claims schema](claimsschema.md) is the place where you declare your claims. The access token must be stored in a claim to be used later.
202+
A claim provides temporary storage of data during an Azure AD B2C policy execution. The [claims schema](claimsschema.md) is the place where you declare your claims. The access token must be stored in a claim to be used later.
203203

204204
1. Open the extensions file of your policy. For example, <em>`SocialAndLocalAccounts/`**`TrustFrameworkExtensions.xml`**</em>.
205205
1. Search for the [BuildingBlocks](buildingblocks.md) element. If the element doesn't exist, add it.
@@ -215,9 +215,9 @@ A claim provides a temporary storage of data during an Azure AD B2C policy execu
215215

216216
### Acquiring an access token
217217

218-
You may obtain your access token from a federated identity provider, calling a REST API that returns an access token, or using client the credentials flow.
218+
You can obtain an access token from a federated identity provider by calling a REST API that returns an access token or by using the client credentials flow.
219219

220-
The following example uses a REST API Technical profile to make a request to the Azure AD Token endpoint using the client credentials passed as HTTP Basic authentication. To configure this in Azure AD, see [Microsoft identity platform and the OAuth 2.0 client credentials flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow).
220+
The following example uses a REST API technical profile to make a request to the Azure AD token endpoint using the client credentials passed as HTTP basic authentication. To configure this in Azure AD, see [Microsoft identity platform and the OAuth 2.0 client credentials flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow).
221221

222222
You may need to modify this to interface with your Identity Provider. See the [RESTful technical profile](restful-technical-profile.md) reference for all options available.
223223

@@ -245,9 +245,9 @@ You may need to modify this to interface with your Identity Provider. See the [R
245245
</TechnicalProfile>
246246
```
247247

248-
### Change the REST technical profile to use Bearer Token Authentication
248+
### Change the REST technical profile to use bearer token authentication
249249

250-
To support Bearer Token authentication in your custom policy, modify the REST API technical profile with the following:
250+
To support bearer token authentication in your custom policy, modify the REST API technical profile with the following:
251251

252252
1. In your working directory, open the *TrustFrameworkExtensions.xml* extension policy file.
253253
1. Search for the `<TechnicalProfile>` node that includes `Id="REST-API-SignUp"`.
@@ -256,12 +256,11 @@ To support Bearer Token authentication in your custom policy, modify the REST AP
256256
```xml
257257
<Item Key="AuthenticationType">Bearer</Item>
258258
```
259-
1. Change/Add the *UseClaimAsBearerToken* to *bearerToken*, as follows:
259+
1. Change or add the *UseClaimAsBearerToken* to *bearerToken*, as follows. The *bearerToken* is the name of the claim that the bearer token will be retrieved from (the output claim from `SecureREST-AccessToken`).
260260

261261
```xml
262262
<Item Key="UseClaimAsBearerToken">bearerToken</Item>
263263
```
264-
(bearerToken is the name of the claim the Bearer token will be retrieved from - the output claim from `SecureREST-AccessToken`)
265264

266265
1. Ensure you add the claim used above as an input claim:
267266

@@ -294,7 +293,7 @@ After you add the above snippets, your technical profile should look like the fo
294293
</ClaimsProvider>
295294
```
296295

297-
## Using a static OAuth2 Bearer
296+
## Using a static OAuth2 bearer
298297

299298
### Add the OAuth2 bearer token policy key
300299

@@ -304,7 +303,7 @@ Create a policy key to store the bearer token value.
304303
1. Make sure you're using the directory that contains your Azure AD B2C tenant. Select the **Directory + subscription** filter in the top menu and choose your Azure AD B2C directory.
305304
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
306305
1. On the Overview page, select **Identity Experience Framework**.
307-
1. Select **Policy Keys** and then select **Add**.
306+
1. Select **Policy Keys**, and then select **Add**.
308307
1. For **Options**, choose `Manual`.
309308
1. Enter a **Name** for the policy key. For example, `RestApiBearerToken`. The prefix `B2C_1A_` is added automatically to the name of your key.
310309
1. In **Secret**, enter your client secret that you previously recorded.
@@ -353,4 +352,4 @@ The following is an example of a RESTful technical profile configured with beare
353352

354353
## Next steps
355354

356-
- Learn more about [Restful technical profile](restful-technical-profile.md) element in the IEF reference.
355+
- Learn more about the [Restful technical profile](restful-technical-profile.md) element in the IEF reference.

0 commit comments

Comments
 (0)