ForgeRock Identity Cloud & Azure AD B2C

Author:

Patryk Krolikowski

Created at:

Jun 2022

Updated at:

Jun 2022

Did you ever wonder how to integrate ForgeRock Identity Cloud (this also applies to ForgeRock Access Management) and Microsoft Azure AD B2C? And maybe even how to do it using OpenID Connect? If so, read on!

Why…

First, you might be asking yourself — Azure AD B2C can be an Identity Provider itself, right? So, why would I even consider using a 3rd party provider?

That’s a very valid question and I think there might be several reasons why.

Some may argue that Azure AD B2C is not the most capable and flexible IAM system on the market. It’s a curated experience targeted at a very specific use case and which is tightly integrated with Microsoft ecosystem. As such it might be too limiting. For example for those who use applications of various types, integrate using modern federation standards, seek ultra flexibility and end user experience. There might be other reasons too. One example could be having an IAM solution already in place. In such scenario you don’t want to manage your identity data all over the place — you want to keep it with you IAM solution. Another scenario is having a multi cloud strategy. Azure AD B2C is Azure Cloud specific. So, if you’re diversifying your cloud vendors then you might not want to be limited to Azure only. Last but not the least reason might be simply avoiding a vendor lock-in.

What…

What is it that we want to achieve then?

There are a few goals here:

  • we want to keep our identity where it currently belongs- in our case ForgeRock Identity Cloud and control user registration and authentication flow — eg. when it comes to MFA, progressive profiling, consent management.

  • we already use applications tightly integrated into Microsoft ecosystem — eg. Microsoft Dynamics

  • we want to use standards for authentication and federation everywhere — by standards I mean mainly SAML2, OAuth2, OpenID Connect.

In such case what are the most typical integration examples we can think of? Let’s discuss the two that are most frequently asked about:

  • ForgeRock Identity Cloud playing a role of an OpenID Provider (Identity Provider) and Azure AD B2C being a Relying Party (Service Provider).

and reverse i.e:

  • ForgeRock Identity Cloud playing a role of a Relying Party and Azure AD B2C being an OpenID Provider.

In this article we’ll cover the first use case.

Before we jump straight into the techie bit lets see what that would look like from an enduser perspective

And here’s the architecture diagram:

https://backstage-community-prod.storage.googleapis.com/original/1X/1d1c179913f5f370b42150e90b9a588cd0322302

Architecture diagram

How…

First things first. Let’s create an Azure AD B2C instance. It should be a pretty straightforward task — it is well described here. One of the issues that you may have is an error message like that:

“The subscription is not registered to use namespace ‘Microsoft.AzureActiveDirectory’. See Troubleshoot common Azure deployment errors - Azure Resource Manager | Microsoft Learn for how to register subscriptions*.*”

And then the tenant creation fails. I found a great article by Adam Storr describing how to overcome that issue.

Once you’re done we should have a summary message similar to this:

https://backstage-community-prod.storage.googleapis.com/original/1X/2b37188afb8dedd82ca522a8d604c49ce76d0ff9

Azure AD B2C Tenant Creation

We are not creating any users locally on Azure AD B2C side — at least not yet.

Once have Azure AD B2C tenant created we can move to the configuration steps.

ForgeRock Identity Cloud as an OP

Now it is time to set our first use case up. Here’s the outline of what we need to do (I’ll cover the details in subsequent paragraphs):

ForgeRock Identity Cloud

  1. Register Azure AD B2C as a Relying Party

  2. Create or use an existing Journey

  3. Create a test user

Azure AD B2C

  1. Register a web application used for testing

  2. Create an Identity Provider

  3. Create a User Flow

Let’s configure ForgeRock Identity Cloud first as an OpenID Provider, then we’ll move on to setting up Azure AD B2C.

ForgeRock Identity Cloud

Register Azure AD B2C as a Relying Party

ForgeRock Identity Cloud is ready to be an OpenID Provider out of the box. The only thing that needs to be configured is registration of a Relying Party — Azure AD B2C in our case.

First let’s visit the Platform UI and go to the Applications section (which is responsible for creating Relying Parties) and hit “Add Application”:

https://backstage-community-prod.storage.googleapis.com/original/1X/d62eb6b7ea8f32771d699911d7f2985645ddd8a3

OAuth2 Client Configuration — initial screen

Next, choose the App type eg. Web:

https://backstage-community-prod.storage.googleapis.com/original/1X/1fd5e978fc12b3e786697555f6f4eb826e2994e4

OAuth2 Client Configuration — selecting an application type

then fill the credentials i.e client_id and client_secret :

https://backstage-community-prod.storage.googleapis.com/original/1X/7f11ee11bdc34b0f1993a19dc4c8c7d4fc59d033

OAuth2 Client Configuration — seeting client_id and client_secret

Then configure the rest of the properties:

https://backstage-community-prod.storage.googleapis.com/original/1X/d76ff4f84efe7a1979926e1a939847725b4f0082

OAuth2 Client Configuration — basic configuration

For the sign-in URLs we’ll need to provide a redirect_uri for the Azure AD B2C.

The “Sign-in URL” in our case should have syntax similar to this one:

https://[XXX].b2clogin.com/[XXX].onmicrosoft.com/oauth2/authresp

where [XXX] is the prefix of the “Initial domain name” you received as the result of Azure AD B2C tenant creation. For instance if you have myb2cinstance.onmicrosoft.com then the [XXX] would be myb2cinstance .

For the Scope section — remember to add profile and email scopes; openid should already be there.

Then go to the “Show Advanced Settings” section and change the “Authentication” tab and change “Token Endpoint Authentication Method” to client_secret_post :

https://backstage-community-prod.storage.googleapis.com/original/1X/b27a4c1267b5c739d76ae9e544c1b4e6f5c8b879

OAuth2 Client Configuration — Token Endpoint Authentication Method

Save changes and continue.

Create or use an existing Journey

Now, let’s a have a look at the Journeys — a super flexible way to create user flows (eg. registration, authentication) and experience in a form similar to the decision trees.To get to them let’s visit the “Journeys” section of the Platform UI:

https://backstage-community-prod.storage.googleapis.com/original/1X/fbde2db9de27f5a521e4d91263616ca112512b57

ForgeRock Identity Cloud — Journeys

As you can see there are quite a few Journey in my ForgeRock Identity Cloud instance. Lots of them come out of the box and can be used for our testing. For instance a Login journey which looks like that:

https://backstage-community-prod.storage.googleapis.com/original/1X/e33ff4330cc00e18fdf41557453542969f8b39e7

ForgeRock Identity Cloud — Login journey

That is a super simple flow. We just use user’s username and password and verify these credentials with the Data Store. If they are valid we increase the Login Count and check whether another Journey (called “Progressive Profile”) should be invoked.

If yes then we go through that journey and once finished we return with the the result back to our main journey. If the result is “True” we end the Journey with “Success”, we return “Failure” otherwise.

Side note: Progressive Profile refers to the ability to ask users to provide additional profile information over time, or to update existing information when needed. The sample Progressive Profile tree used above checks the number of logins, and prompts the user to fill out their marketing preferences if they haven’t already.

Create a test user

The last thing to do is creating a test user. In order to do so we need to go back to the main Platform UI and go to “Identities”→ “Manage” section:

https://backstage-community-prod.storage.googleapis.com/original/1X/de358762ab38a4b59b292aeb64e4af424b26dcc0

ForgeRock Identity Cloud — Managed Identities

Then we go to “Alpha realm — Users”, hit “New Alpha Realm User”

https://backstage-community-prod.storage.googleapis.com/original/1X/e60c5a8c6f8e2ce8c52b98afd99b1bc5447c9c7b

ForgeRock Identity Cloud — test user creation

and fill the details.

Note: Please use a “real” email address as Azure AD B2C will want to send a confirmation email to that address during the initial Azure AD B2C User Flow.

https://backstage-community-prod.storage.googleapis.com/original/1X/db344507ed21c70f1e607ced1e45b7b1bc67cb94

ForgeRock Identity Cloud — user creation form

With that, we are ready to move on.

Azure AD B2C

Register our web application

We can either use an existing application or build our own. For simplicity we can use one of the sample, published on-line applications Microsoft offers — https://jwt.ms. This application allows us to inspect token details once the integration has been completed.

Regardless of the application we chose we need to register it.

In order to do so, in Azure AD B2C portal go to App Registrations → New Registration

https://backstage-community-prod.storage.googleapis.com/original/1X/d3d0917001b0a794a1db026cf971839f67b48e4d

App Registration — step 1

Then fill the details for the jwt.ms application

https://backstage-community-prod.storage.googleapis.com/original/1X/329cb938da4fe25e1ae8787d11daf8fefabae0d3

App Registration — step 2

Go to the details of the newly registered app and make a note of “Application (client) ID” — that’s a client_id

https://backstage-community-prod.storage.googleapis.com/original/1X/d59abfc0603a374c006a27fedd4b4e757d7183fe

App configuration — copy Application (client) ID

Then go to “Certificates & secrets” section and create a secret.Give it a description and set expiration time to your liking.

https://backstage-community-prod.storage.googleapis.com/original/1X/21bb834a56739e7faaad8e046d84673c99dc72f9

Next, copy the generated secret (“Value” and not the “Secret ID”) — this will become your client_secret . Make sure you do it right after creating it. The value will be not available later on.

https://backstage-community-prod.storage.googleapis.com/original/1X/230fef72e152b441770bba9513c7692637ba4b5d

Create an Identity Provider

Now go back to the main Azure AD B2C configuration page and choose “Identity Providers”. Then hit “New OpenID Connect provider”

https://backstage-community-prod.storage.googleapis.com/original/1X/f526b366a0f72e87acd4ae9138c3698d2ccef804

Create OpenID provider.

Then we need to fill some details out:

https://backstage-community-prod.storage.googleapis.com/original/1X/867ace5f41cf290c27a1b1c2332ff227dc558e44

ForgeRock Identity Cloud as an OP

Makes sure to put the right `.well-known`endpoint in the Metadata Url field. For the ForgeRock Identity Cloud in most cases it will be:

https://[your_fidc_instance]/am/oauth2/realms/root/realms/alpha/.well-known

…where alpha is the name of the realm. If it is different in your case change it accordingly.

Use the same “Client ID” and “Client secret” that we set up in ForgeRock Identity Cloud during OpenID Connect `azure`application creation. Also make sure you have the right scopes in place as well as “Identity Provider Claims Mapping” section is filled out.

Create a User Flow

Now we need to configure a user flow that will bring the web application and our Identity Provider together.

Go to the main page of Azure AD B2C config. Under “Policies” click “User flows” → “New user flow”:

https://backstage-community-prod.storage.googleapis.com/original/1X/c3eca328d54e00cae273b2a2ab7343d175a2a3c9

Create a new User Flow

Then from the list of flow types select “Sign up and sign in” plus a “recommended” version of the flow. The reason why we select this particular flow type is we want to register a user with Azure AD B2C if one does not exist when coming back from ForgeRock Identity Cloud.

https://backstage-community-prod.storage.googleapis.com/original/1X/fca079dfc3054d66b59bab5a794fde2ac9a8b128

User flow type — Sign-up and Sign-in and Version

Then, give the flow a name and configure Identity Providers. These can be local (handled by Azure AD B2C) or “social” — like Google, or “custom” — like ForgeRock Identity Cloud. Let’s pick “Email signup” for a local account and ForgeRock Identity Cloud as a custom provider. We can skip MFA config as well as Conditional access leaving the defaults:

https://backstage-community-prod.storage.googleapis.com/original/1X/1e7983b71d7699c38be6f59186729fe97f763c64

User Flow — Select Identity Providers

The next section is interesting — User attributes and token claims. It allows for collecting attributes from the user during sign-up and select which claims will be returned in the token:

https://backstage-community-prod.storage.googleapis.com/original/1X/a26480720a72386e41861e5030b5986866d507f2

User Flow — Attributes and Claims — part 1

To get more attributes/claims pairs let’s go ahead and click Show more… Then we can choose whatever we need eg.:

https://backstage-community-prod.storage.googleapis.com/original/1X/7890462315a6f65533a9cb9509f02330d9d01a8f

User Flow — Attributes and Claims — part 2

Then, hit the “Create” button to create the flow.

But, there’s one last thing to check before we test the user flow. Let’s make sure we don’t have a user in Azure AD B2C that would correspond to the one we had created in ForgeRock Identity Cloud. It should be creating during the first encounter.

https://backstage-community-prod.storage.googleapis.com/original/1X/32a365bffcbce9ec123179a16f132a932b2f7d09

Users view — before testing user flow

Now, when we run the flow the sequence should be as follows:

https://backstage-community-prod.storage.googleapis.com/original/1X/2e2d46143eaac01bb7dd7e60c3f9a8aec6159160

User journey — flow diagram

Now we are ready to test it. Select “B2C_1_myflow” (or whatever flow you created) from the User Flows section of Azure AD B2C main config screen:

https://backstage-community-prod.storage.googleapis.com/original/1X/10ad6efdcc58d96de132ca4ca088db445c560376

Testing the flow

That should give you a view similar to that one:

https://backstage-community-prod.storage.googleapis.com/original/1X/be1c1f4866d8e583831499a6cbbc9e059501b9c1

Testing the flow — “Run user flow” — step 1

Hit “Run user flow”. Now we have to pick an application which will be tested against the flow — we use jwt.ms that we had created:

https://backstage-community-prod.storage.googleapis.com/original/1X/d08937447b05b82d1b5a2c7cd618d7f45a758c4c

Testing the flow- “Run user flow” — step 2

As the last step we can check whether the user has been successfully created in Azure AD B2C:

https://backstage-community-prod.storage.googleapis.com/original/1X/3f214a6d813bc24b45c9efa80a5cd9edd6f66d42

Users view — after testing user flow

The user is there now. Have a look at the “Source” column.

So far I’ve shown how to integrate Azure AD B2C with ForgeRock Identity Platform using OpenID Connect where the first one is a Relying Party and the latter an OpenID Provider.

Thanks Steffo Weber, Stéphane Orluc and Andre Posner for invaluable feedback!

By Patryk Krolikowski Originally posted on https://medium.com/@scureq If you need to integrate Zendesk with ForgeRock Identity Cloud acting as an Identity Provider using SAML then this story is for you. If not, you can still read it ;). This post is a joint effort of Andre Posner and myself. ForgeRock Identity Cloud configuration First let’s visit the Platform UI of our Identity Cloud instance. Then go to Access Management Native console: [image] Forgerock Identity Cloud Platform console…