Search code examples
azure-active-directoryazure-ad-b2c-custom-policyazure-ad-b2c

AAD B2C multiple types of registration flows


I am creating application where I use AD B2C with Custom Policies to implement user management capabilities. In my application however I need to support multiple types of accounts while for each of the account type there should be different sign-up process (different user data to collect). My question is, what is the best approach to implement this?


Solution

  • I would suggest you to provide the users with 2 different buttons e.g. UserType1 and UserType2 on the application page and these buttons should invoke different user flows. There are 2 options available for this purpose:

    1. Create 2 separate chain of policy files
    2. Create multiple user journeys in Base or Extensions file and use multiple RP (signup_signin) files referencing different user journeys.

    In order to create two set of policy files, you can choose to create two separate chains, as mentioned below:

    B2C_1A_TRUSTFRAMEWORKBASE > B2C_1A_TRUSTFRAMEWORKEXTENSIONS > B2C_1A_SIGNUP_SIGNIN

    B2C_1A_TRUSTFRAMEWORKBASE1 > B2C_1A_TRUSTFRAMEWORKEXTENSIONS1 > B2C_1A_SIGNUP_SIGNIN1

    However, it is not necessary to use 2 set of policy files, if you want to use 2 RP (B2C_1A_SIGNUP_SIGNIN) files. You may also consider creating 2 separate user journeys in your B2C_1A_TRUSTFRAMEWORKBASE or B2C_1A_TRUSTFRAMEWORKEXTENSIONS file, e.g., <UserJourney Id="SignUpOrSignIn"> and <UserJourney Id="SignUpOrSignIn1">.

    Once you have the two User Journeys configured, in B2C_1A_SIGNUP_SIGNIN file you can reference <DefaultUserJourney ReferenceId="SignUpOrSignIn" /> and in B2C_1A_SIGNUP_SIGNIN1 file, reference <DefaultUserJourney ReferenceId="SignUpOrSignIn1" />

    If you use this configuration, the policy file chains will look like:

    B2C_1A_TRUSTFRAMEWORKBASE > B2C_1A_TRUSTFRAMEWORKEXTENSIONS > B2C_1A_SIGNUP_SIGNIN

    B2C_1A_TRUSTFRAMEWORKBASE > B2C_1A_TRUSTFRAMEWORKEXTENSIONS > B2C_1A_SIGNUP_SIGNIN1

    Additionally, the name of RP File (SIGNUP_SIGNIN) will be different in both cases. In option 1, all three files have different names and in option 2, Base and Extensions files will be same only the RP files are different. Regardless of which option you choose, you can specify the name of the RP File (SIGNUP_SIGNIN) in the URL you have mentioned above. B2C supports 200 policy files to be uploaded, so you can choose to go with option 1 without worrying about exhausting the allowed limit of policy files.