Search code examples
azure-active-directoryazure-ad-b2cazure-ad-graph-apipoliciesazure-ad-b2b

How to enable Javascript on Custom Azure AD B2C SignUpOrSignin Policy


I am trying to enable Javascript on my custom "SignUpOrSignin.xml" policy, so I can take custom actions on the Reset Password and Sign Up buttons.

I did the following steps on SignUpOrSignin.xml :

 <RelyingParty>
<DefaultUserJourney ReferenceId="SignUpOrSignIn" />
<UserJourneyBehaviors>
  <ScriptExecution>Allow</ScriptExecution>
</UserJourneyBehaviors>
 .........
 .........
 .........
</RelyingParty>

and on TrustFrameworkBase.xml :

 <ContentDefinition Id="api.signuporsignin">
    <LoadUri>https://ttt.blob.core.windows.net/b2c-migration-users/pages/unified.html</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:unifiedssp:1.1.0</DataUri>
    <Metadata>
      <Item Key="DisplayName">Signin and Signup</Item>
      <Item Key="TemplateId">azureBlue</Item>
    </Metadata>
  </ContentDefinition>

Unfortunetly, when I try to upload the SignUpOrSignin.xml policy in the AAD B2C Instance, I receive the following validation error:

Validation failed: 1 validation error(s) found in policy "B2C_1A_JITMIGRAION_SIGNUP_SIGNIN" of tenant "mytenant.onmicrosoft.com". Please use page contract in content definitions when enabling JavaScript.

What am I missing ? Any help will be much appreciated!


Solution

  • For any ContentDefinition that you want to enable JS on, the DataUri needs to be the contract version. That means urn:com:microsoft:aad:b2c:elements:unifiedssp:1.1.0 needs to be changed to urn:com:microsoft:aad:b2c:elements:contract:unifiedssp:1.2.0 (See Content Definitions Documentation). The page layout version is also different, and you can see what those differences are by going here.