简体   繁体   English

使用动态HTML的Azure AD B2C UI自定义

[英]Azure AD B2C UI Customization with dynamic HTML

I am trying to configure my own html and CSS for Azure AD B2C sign-up and sign-in policy by following this link . 我正在尝试通过以下链接为Azure AD B2C注册和登录策略配置我自己的htmlCSS

I am successful in taking the user to custom Sign-Up and Sign-In pages, but now I want to have dynamic sign-up page. 我成功地将用户带到了自定义Sign-UpSign-In页面,但现在我想拥有动态注册页面。 I want to pass some values in the query string or some other way and based on those values I want to add or remove some elements inside html. 我想在query string传递一些值或以其他方式传递一些值,并根据我想要添加的值或删除html中的一些元素。

In future I want to put those values in a database and query them before rendering html. 将来我想将这些值放在数据库中并在渲染html之前查询它们。

Is this achievable? 这可以实现吗? Any guidance is highly appreciated. 任何指导都非常感谢。

Short answer, there is no easy way today to add dynamic behavior to your custom Azure AD B2C UIs . 简而言之, 今天没有简单的方法可以为您的自定义Azure AD B2C UI添加动态行为

The most viable way to achieve this is by using JavaScript which isn't supported in Azure AD B2C yet. 实现这一目标的最可行方法是使用Azure AD B2C不支持的JavaScript。

You can support this ask and stay up to date on its progress by voting for it in the Azure AD B2C feedback forum: Add support for JavaScript inside the custom UI branding page 您可以通过在Azure AD B2C反馈论坛中投票来支持此问题并及时了解其进度: 在自定义UI品牌页面中添加对JavaScript的支持

A potential workaround: create separate policies with your different UI permutations/variations . 可能的解决方法:使用不同的UI排列/变体创建单独的策略 This would allow you to have a single query string parameter (the policy) to determine which UI to pick. 这将允许您使用单个查询字符串参数(策略)来确定要选择的UI。

By default B2C disables Javascript because the policies are executed on login.microsoft.com 默认情况下,B2C会禁用Javascript,因为策略是在login.microsoft.com上执行的

B2C supports something called Vanity domains although you will have to request it, what this does is makes it appears that the policies are executed on your domain so instead of B2C支持名为Vanity域的东西,虽然你必须要求它,但这样做会使政策在你的域上执行,而不是

login.microsoft.com?p=signinpolicy the url would be login.microsoft.com?p=signinpolicy url将是

myvanitydomain?p=signinpolicy myvanitydomain P = signinpolicy

The process is long and exhausting and as far as i know is not open to the general public 这个过程漫长而且令人筋疲力尽,据我所知,不向公众开放

By changing this you can now run javascript because Microsoft dont want you running Javascript on their domains 通过更改此功能,您现在可以运行javascript,因为Microsoft不希望您在其域上运行Javascript

So far I have not managed to find any way to automatically enable Javascript at page loads as Microsoft strip out all script tags. 到目前为止,我还没有找到任何方法在页面加载时自动启用Javascript,因为Microsoft删除了所有脚本标记。

If you are authoring custom policies and you are wanting to change the HTML template that is loaded by Identity Experience Framework (IEF) based on a query string parameter, then you can define this query string parameter in your relying party policy as follows: 如果您正在编写自定义策略,并且希望根据查询字符串参数更改Identity Experience Framework(IEF)加载的HTML模板,则可以在依赖方策略中定义此查询字符串参数,如下所示:

<RelyingParty>
  <UserJourneyBehaviors>
    ...
    <ContentDefinitionParameters>
      <Parameter Name="campaign_id">{OAUTH-KV:campaign_id}</Parameter>
    </ContentDefinitionParameters>
  </UserJourneyBehaviors>
  <TechnicalProfile>
    ...
  </TechnicalProfile>
</RelyingParty>

When you add the query string parameter to the authentication request: 将查询字符串参数添加到身份验证请求时:

https://login.microsoftonline.com/contoso.onmicrosoft.com/oauth2/v2.0/authorize/?p=b2c_1a_sign_up_sign_in&campaign_id=1 https://login.microsoftonline.com/contoso.onmicrosoft.com/oauth2/v2.0/authorize/?p=b2c_1a_sign_up_sign_in&campaign_id=1

Then IEF loads the HTML template with this query string parameter: 然后,IEF使用此查询字符串参数加载HTML模板:

https://b2c.contoso.com/templates/signupsignin?campaign_id=1 https://b2c.contoso.com/templates/signupsignin?campaign_id=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM