Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Javascript on B2C Custom Policy

Tags:

azure-ad-b2c

Javascript is disabled on the Client Side, even though i have added below as per documentation.

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

When i try to upload the Custom Policy, i get an error - "Please use page contract in content definitions when enabling JavaScript." Cannot find anything related to this error in documentation.

Tried to add metadata to content definitions, using datauri -

<ContentDefinition Id="api.localaccountpasswordreset">  
  <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
 <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:1.1.0</DataUri>
  ...
 </ContentDefinition>

Expect javascript to work on client side login pages

like image 450
veejar Avatar asked Jul 29 '19 19:07

veejar


People also ask

How do I customize Azure B2C UI?

In the Azure portal, search for and select Azure AD B2C. In the left-hand menu, select User flows, and then select the B2C_1_signupsignin1 user flow. Select Page layouts, and then under Unified sign-up or sign-in page, select Yes for Use custom page content. In Custom page URI, enter the URI for the custom-ui.

How do I create a custom policy in Azure B2C?

Register a web application using the Azure portal so you'll be able to test your policy. Add the necessary policy keys and register the Identity Experience Framework applications. Get the Azure AD B2C policy starter pack and upload to your tenant. After you upload the starter pack, test your sign-up or sign-in policy.

What is identity experience framework?

The Identity Experience Framework is a powerful identity engine with a very comprehensive feature set, that is used internally for Microsoft services like Azure AD B2C. Only a subset of features will be tested, monitored, documented, and supported over time. The supported list will increase quickly.

How do I enable JavaScript in Azure AD B2C?

Azure AD B2C provides a set of packaged content containing HTML, CSS, and JavaScript for the user interface elements in your user flows and custom policies. To enable JavaScript for your applications: Select a page layout Enable it on the user flow by using the Azure portal

How do I enable JavaScript in a custom policy?

To enable JavaScript for your applications, you must add an element to your custom policy, select a page contract, and use b2clogin.com in your requests. Sorry, something went wrong. @mmacy thanks for you reply. Yay! I had a go with playing with b2clogin.com again and this time it worked successfully.

Can I add JavaScript to the B2C UI customisation flow?

Adding JavaScript (JS) to the B2C UI customisation flow has been on the cards for a while and now has finally been released. I suggest you read through all the links below and then read through the post. There’s a good write-up here. Let’s follow the article. This is described here.

How do I add a custom policy in Azure AD B2C?

Select Upload custom policy. Upload the extensions file that you previously changed. Select the policy that you uploaded, and then select Run now. You should be able to sign up by using an email address. By using Azure AD B2C custom policies, you can send a parameter in the URL path, or a query string.


3 Answers

I facing the same problem, to correct I follow this steps(for custom policies):

First: in _Base.Xml go to ContentDefinitions and find for DataUri, change all old uris to new like this link https://docs.microsoft.com/en-us/azure/active-directory-b2c/contentdefinitions#migrating-to-page-layout

Second: ensure that you have the word "contract" between your elements and your page identifier, example: change this urn:com:microsoft:aad:b2c:elements:globalexception:1.2.0 for this urn:com:microsoft:aad:b2c:elements:contract:globalexception:1.2.0

Third: in your specific Custom Policie, find for RelyingParty and add the ScriptExecution element to the UserJourneyBehaviors element of RelyingParty

some like this

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

Fourth: upload the base.xml, upload your custom policy.xml and enjoy!

greetings from Brasil.

like image 155
Willian De Castro Avatar answered Sep 20 '22 04:09

Willian De Castro


If you are still facing the errors, then replace the DataUri tag from

<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.2.0</DataUri> to <DataUri>urn:com:microsoft:aad:b2c:elements:contract:providerselection:1.2.0</DataUri>

for the ContentDefinition api.idpselections and api.idpselections.signup.

like image 30
Sandesh Segu Avatar answered Sep 19 '22 04:09

Sandesh Segu


This article explains end to end how to enable javascript. https://docs.microsoft.com/en-us/azure/active-directory-b2c/javascript-samples

like image 36
Jas Suri - MSFT Avatar answered Sep 19 '22 04:09

Jas Suri - MSFT