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
@@ -28,44 +28,44 @@ Complete the steps in [Get started with custom policies in Azure Active Director
28
28
To enable sign-in for users from a specific Azure AD organization, you need to register an application within the organizational Azure AD tenant.
29
29
30
30
1. Sign in to the [Azure portal](https://portal.azure.com).
31
-
2. Make sure you're using the directory that contains organizational Azure AD tenant (contoso.com) by clicking the **Directory and subscription filter** in the top menu and choosing the directory that contains your tenant.
32
-
3. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **App registrations**.
33
-
4. Select **New application registration**.
34
-
5. Enter a name for your application. For example, `Azure AD B2C App`.
35
-
6. For the **Application type**, select `Web app / API`.
36
-
7. For the **Sign-on URL**, enter the following URL in all lowercase letters, where `your-B2C-tenant-name` is replaced with the name of your Azure AD B2C tenant:
31
+
1. Make sure you're using the directory that contains your organizational Azure AD tenant (for example, contoso.com). Select the **Directory + subscription filter** in the top menu, and then choose the directory that contains your Azure AD tenant.
32
+
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **App registrations**.
33
+
1. Select **New registration**.
34
+
1. Enter a **Name** for your application. For example, `Azure AD B2C App`.
35
+
1. Accept the default selection of **Accounts in this organizational directory only** for this application.
36
+
1. For the **Redirect URI**, accept the value of **Web**, and enter the following URL in all lowercase letters, where `your-B2C-tenant-name` is replaced with the name of your Azure AD B2C tenant.
For example, `https://contoso.b2clogin.com/contoso.onmicrosoft.com/oauth2/authresp`.
43
43
44
-
8. Click **Create**. Copy the **Application ID** to be used later.
45
-
9. Select the application, and then select **Settings**.
46
-
10. Select **Keys**, enter the key description, select a duration, and then click **Save**. Copy the value of the key that is displayed to be used later.
44
+
1. Select **Register**. Record the **Application (client) ID** for use in a later step.
45
+
1. Select **Certificates & secrets**, and then select **New client secret**.
46
+
1. Enter a **Description** for the secret, select an expiration, and then select **Add**. Record the **VALUE** of the secret for use in a later step.
47
47
48
48
## Create a policy key
49
49
50
50
You need to store the application key that you created in your Azure AD B2C tenant.
51
51
52
-
1. Make sure you're using the directory that contains your Azure AD B2C tenant by clicking the **Directory and subscription filter** in the top menu and choosing the directory that contains your tenant.
53
-
2. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
54
-
3. On the Overview page, select **Identity Experience Framework**.
55
-
4. Select **Policy Keys** and then select **Add**.
56
-
5. For **Options**, choose `Manual`.
57
-
6. Enter a **Name** for the policy key. For example, `ContosoAppSecret`. The prefix `B2C_1A_` is added automatically to the name of your key.
58
-
7. In **Secret**, enter your application key that you previously recorded.
59
-
8. For **Key usage**, select `Signature`.
60
-
9. Click **Create**.
52
+
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 then choose the directory that contains your Azure AD B2C tenant.
53
+
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
54
+
1. Under **Policies**, select **Identity Experience Framework**.
55
+
1. Select **Policy keys** and then select **Add**.
56
+
1. For **Options**, choose `Manual`.
57
+
1. Enter a **Name** for the policy key. For example, `ContosoAppSecret`. The prefix `B2C_1A_` is added automatically to the name of your key when it's created, so its reference in the XML in following section is to *B2C_1A_ContosoAppSecret*.
58
+
1. In **Secret**, enter your client secret that you recorded earlier.
59
+
1. For **Key usage**, select `Signature`.
60
+
1. Select **Create**.
61
61
62
62
## Add a claims provider
63
63
64
-
If you want users to sign in by using Azure AD, you need to define Azure AD as a claims provider that Azure AD B2C can communicate with through an endpoint. The endpoint provides a set of claims that are used by Azure AD B2C to verify that a specific user has authenticated.
64
+
If you want users to sign in by using Azure AD, you need to define Azure AD as a claims provider that Azure AD B2C can communicate with through an endpoint. The endpoint provides a set of claims that are used by Azure AD B2C to verify that a specific user has authenticated.
65
65
66
66
You can define Azure AD as a claims provider by adding Azure AD to the **ClaimsProvider** element in the extension file of your policy.
67
67
68
-
1. Open the *TrustFrameworkExtensions.xml*.
68
+
1. Open the *TrustFrameworkExtensions.xml* file.
69
69
2. Find the **ClaimsProviders** element. If it does not exist, add it under the root element.
70
70
3. Add a new **ClaimsProvider** as follows:
71
71
@@ -78,17 +78,16 @@ You can define Azure AD as a claims provider by adding Azure AD to the **ClaimsP
78
78
<DisplayName>Contoso Employee</DisplayName>
79
79
<Description>Login with your Contoso account</Description>
@@ -122,38 +121,38 @@ You can define Azure AD as a claims provider by adding Azure AD to the **ClaimsP
122
121
To get a token from the Azure AD endpoint, you need to define the protocols that Azure AD B2C should use to communicate with Azure AD. This is done inside the **TechnicalProfile** element of **ClaimsProvider**.
123
122
124
123
1. Update the ID of the **TechnicalProfile** element. This ID is used to refer to this technical profile from other parts of the policy.
125
-
2. Update the value for **DisplayName**. This value will be displayed on the sign-in button on your sign-in screen.
126
-
3. Update the value for **Description**.
127
-
4. Azure AD uses the OpenID Connect protocol, so make sure that the value for **Protocol** is `OpenIdConnect`.
128
-
5. Set value of the **METADATA** to `https://login.windows.net/your-AD-tenant-name.onmicrosoft.com/.well-known/openid-configuration`, where `your-AD-tenant-name` is your Azure AD tenant name. For example, `https://login.windows.net/fabrikam.onmicrosoft.com/.well-known/openid-configuration`
129
-
6. Open your browser and go to the **METADATA** URL that you just updated, look for the **issuer** object, copy and paste the value into the value for **ProviderName** in the XML file.
130
-
8. Set **client_id** and **IdTokenAudience** to the application ID from the application registration.
131
-
9. Under **CryptographicKeys**, Update the value for **StorageReferenceId** to the policy key that you defined. For example, `ContosoAppSecret`.
124
+
1. Update the value for **DisplayName**. This value will be displayed on the sign-in button on your sign-in screen.
125
+
1. Update the value for **Description**.
126
+
1. Azure AD uses the OpenID Connect protocol, so make sure that the value for **Protocol** is `OpenIdConnect`.
127
+
1. Set value of the **METADATA** to `https://login.windows.net/your-AD-tenant-name.onmicrosoft.com/.well-known/openid-configuration`, where `your-AD-tenant-name` is your Azure AD tenant name. For example, `https://login.windows.net/fabrikam.onmicrosoft.com/.well-known/openid-configuration`
128
+
1. Open your browser and go to the **METADATA** URL that you just updated, look for the **issuer** object, and then copy and paste the value into the value for **ProviderName** in the XML file.
129
+
1. Set **client_id** to the application ID from the application registration.
130
+
1. Under **CryptographicKeys**, update the value of **StorageReferenceId** to the name of the policy key that you created earlier. For example, `B2C_1A_ContosoAppSecret`.
132
131
133
132
### Upload the extension file for verification
134
133
135
134
By now, you have configured your policy so that Azure AD B2C knows how to communicate with your Azure AD directory. Try uploading the extension file of your policy just to confirm that it doesn't have any issues so far.
136
135
137
136
1. On the **Custom Policies** page in your Azure AD B2C tenant, select **Upload Policy**.
138
-
2. Enable **Overwrite the policy if it exists**, and then browse to and select the *TrustFrameworkExtensions.xml* file.
139
-
3. Click **Upload**.
137
+
1. Enable **Overwrite the policy if it exists**, and then browse to and select the *TrustFrameworkExtensions.xml* file.
138
+
1. Click **Upload**.
140
139
141
140
## Register the claims provider
142
141
143
-
At this point, the identity provider has been set up, but it’s not available in any of the sign-up/sign-in screens. To make it available, you create a duplicate of an existing template user journey, and then modify it so that it also has the Azure AD identity provider:
142
+
At this point, the identity provider has been set up, but it's not yet available in any of the sign-up/sign-in pages. To make it available, create a duplicate of an existing template user journey, and then modify it so that it also has the Azure AD identity provider:
144
143
145
144
1. Open the *TrustFrameworkBase.xml* file from the starter pack.
146
-
2. Find and copy the entire contents of the **UserJourney** element that includes `Id="SignUpOrSignIn"`.
147
-
3. Open the *TrustFrameworkExtensions.xml* and find the **UserJourneys** element. If the element doesn't exist, add one.
148
-
4. Paste the entire content of the **UserJourney** element that you copied as a child of the **UserJourneys** element.
149
-
5. Rename the ID of the user journey. For example, `SignUpSignInContoso`.
145
+
1. Find and copy the entire contents of the **UserJourney** element that includes `Id="SignUpOrSignIn"`.
146
+
1. Open the *TrustFrameworkExtensions.xml* and find the **UserJourneys** element. If the element doesn't exist, add one.
147
+
1. Paste the entire content of the **UserJourney** element that you copied as a child of the **UserJourneys** element.
148
+
1. Rename the ID of the user journey. For example, `SignUpSignInContoso`.
150
149
151
150
### Display the button
152
151
153
-
The **ClaimsProviderSelection** element is analogous to an identity provider button on a sign-up/sign-in screen. If you add a **ClaimsProviderSelection** element for Azure AD, a new button shows up when a user lands on the page.
152
+
The **ClaimsProviderSelection** element is analogous to an identity provider button on a sign-up/sign-in page. If you add a **ClaimsProviderSelection** element for Azure AD, a new button shows up when a user lands on the page.
154
153
155
-
1. Find the **OrchestrationStep** element that includes `Order="1"` in the user journey that you created.
156
-
2. Under **ClaimsProviderSelections**, add the following element. Set the value of **TargetClaimsExchangeId** to an appropriate value, for example `ContosoExchange`:
154
+
1. Find the **OrchestrationStep** element that includes `Order="1"` in the user journey that you created in *TrustFrameworkExtensions.xml*.
155
+
1. Under **ClaimsProviderSelections**, add the following element. Set the value of **TargetClaimsExchangeId** to an appropriate value, for example `ContosoExchange`:
@@ -164,36 +163,46 @@ The **ClaimsProviderSelection** element is analogous to an identity provider but
164
163
Now that you have a button in place, you need to link it to an action. The action, in this case, is for Azure AD B2C to communicate with Azure AD to receive a token. Link the button to an action by linking the technical profile for your Azure AD claims provider:
165
164
166
165
1. Find the **OrchestrationStep** that includes `Order="2"` in the user journey.
167
-
2. Add the following **ClaimsExchange** element making sure that you use the same value for **Id** that you used for **TargetClaimsExchangeId**:
166
+
1. Add the following **ClaimsExchange** element making sure that you use the same value for **Id** that you used for **TargetClaimsExchangeId**:
Update the value of **TechnicalProfileReferenceId** to the **Id** of the technical profile you created earlier. For example, `ContosoProfile`.
174
173
175
-
3. Save the *TrustFrameworkExtensions.xml* file and upload it again for verification.
174
+
1. Save the *TrustFrameworkExtensions.xml* file and upload it again for verification.
176
175
177
176
## Create an Azure AD B2C application
178
177
179
-
Communication with Azure AD B2c occurs through an application that you create in your tenant. This section lists optional steps you can complete to create a test application if you haven't already done so.
178
+
Communication with Azure AD B2C occurs through an application that you register in your B2C tenant. This section lists optional steps you can complete to create a test application if you haven't already done so.
180
179
181
180
1. Sign in to the [Azure portal](https://portal.azure.com).
182
-
2. Make sure you're using the directory that contains your Azure AD B2C tenant by clicking the **Directory and subscription filter** in the top menu and choosing the directory that contains your tenant.
183
-
3. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
184
-
4. Select **Applications**, and then select **Add**.
185
-
5. Enter a name for the application, for example *testapp1*.
186
-
6. For **Web App / Web API**, select `Yes`, and then enter `https://jwt.ms` for the **Reply URL**.
187
-
7. Click **Create**.
181
+
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 then choose the directory that contains your Azure AD B2C tenant.
182
+
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
183
+
1. Select **Applications**, and then select **Add**.
184
+
1. Enter a name for the application, for example *testapp1*.
185
+
1. For **Web App / Web API**, select `Yes`, and then enter `https://jwt.ms` for the **Reply URL**.
186
+
1. Select **Create**.
188
187
189
188
## Update and test the relying party file
190
189
191
190
Update the relying party (RP) file that initiates the user journey that you created.
192
191
193
192
1. Make a copy of *SignUpOrSignIn.xml* in your working directory, and rename it. For example, rename it to *SignUpSignInContoso.xml*.
194
-
2. Open the new file and update the value of the **PolicyId** attribute for **TrustFrameworkPolicy** with a unique value. For example, `SignUpSignInContoso`.
195
-
3. Update the value of **PublicPolicyUri** with the URI for the policy. For example,`http://contoso.com/B2C_1A_signup_signin_contoso`
196
-
4. Update the value of the **ReferenceId** attribute in **DefaultUserJourney** to match the ID of the new user journey that you created (SignUpSignInContoso).
197
-
5. Save your changes, upload the file, and then select the new policy in the list.
198
-
6. Make sure that Azure AD B2C application that you created is selected in the **Select application** field, and then test it by clicking **Run now**.
193
+
1. Open the new file and update the value of the **PolicyId** attribute for **TrustFrameworkPolicy** with a unique value. For example, `SignUpSignInContoso`.
194
+
1. Update the value of **PublicPolicyUri** with the URI for the policy. For example, `http://contoso.com/B2C_1A_signup_signin_contoso`.
195
+
1. Update the value of the **ReferenceId** attribute in **DefaultUserJourney** to match the ID of the user journey that you created earlier. For example, *SignUpSignInContoso*.
196
+
1. Save your changes and upload the file.
197
+
1. Under **Custom policies**, select the new policy in the list.
198
+
1. In the **Select application** drop-down, select the Azure AD B2C application that you created earlier. For example, *testapp1*.
199
+
1. Copy the **Run now endpoint** and open it in a private browser window, for example, Incognito Mode in Google Chrome or an InPrivate window in Microsoft Edge. Opening in a private browser window allows you to test the full user journey by not using any currently cached Azure AD credentials.
200
+
1. Select the Azure AD sign in button, for example, *Contoso Employee*, and then enter the credentials for a user in your Azure AD organizational tenant. You're asked to authorize the application, and then enter information for your profile.
201
+
202
+
If the sign in process is successful, your browser is redirected to `https://jwt.ms`, which displays the contents of the token returned by Azure AD B2C.
203
+
204
+
## Next steps
205
+
206
+
When working with custom policies, you might sometimes need additional information when troubleshooting a policy during its development.
199
207
208
+
To help diagnose issues, you can temporarily put the policy into "developer mode" and collect logs with Azure Application Insights. Find out how in [Azure Active Directory B2C: Collecting Logs](active-directory-b2c-troubleshoot-custom.md).
0 commit comments