Javascript 在客户端被禁用,尽管我已根据文档添加了以下内容。
<RelyingParty>
<DefaultUserJourney ReferenceId="B2CSignUpOrSignInWithPassword" />
<UserJourneyBehaviors>
<ScriptExecution>Allow</ScriptExecution>
</UserJourneyBehaviors>
...
</RelyingParty>
当我尝试上传自定义策略时,收到错误 - “启用 JavaScript 时,请在内容定义中使用页面契约。”在文档中找不到与此错误相关的任何内容。
尝试使用 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>
期望 javascript 在客户端登录页面上工作
如果您仍然遇到错误,请将
DataUri
标签替换为
<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.2.0</DataUri>
至 <DataUri>urn:com:microsoft:aad:b2c:elements:contract:providerselection:1.2.0</DataUri>
对于
ContentDefinition
api.idpselections
和 api.idpselections.signup
。
我面临同样的问题,要纠正我按照以下步骤(对于自定义策略):
首先:在 _Base.Xml 中转到 ContentDefinitions 并找到 DataUri,将所有旧 uri 更改为新的,如下链接 https://learn.microsoft.com/en-us/azure/active-directory-b2c/contentdefinitions#migrating -到页面布局
第二:确保元素和页面标识符之间有“合同”一词,例如:更改此 瓮:com:微软:aad:b2c:元素:globalexception:1.2.0 为了这 瓮:com:微软:aad:b2c:元素:合同:globalexception:1.2.0
第三:在您的特定自定义策略中,找到 RelyingParty 并将 ScriptExecution 元素添加到 RelyingParty 的 UserJourneyBehaviors 元素中
有些是这样的
<RelyingParty>
<DefaultUserJourney ReferenceId="B2CSignUpOrSignInWithPassword" />
<UserJourneyBehaviors>
<ScriptExecution>Allow</ScriptExecution>
</UserJourneyBehaviors>
...
</RelyingParty>
第四:上传base.xml,上传您的自定义policy.xml并享受!
来自巴西的问候。
如果有人仍然遇到错误,那么您应该将内容定义中的 all 数据 URI 替换为以下 url 中定义的数据:
在您的策略中随处使用新数据 URI,而不是旧,这将解决问题。我的也是用同样的方法修复的。不仅如此,Microsoft 文档还明确指出“如果您打算使用 JavaScript,则需要为自定义策略中的所有内容定义定义页面布局版本和页面契约版本”。
参考网址:https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-samples
只有当我用 contract 更新所有 ContentDefinition 时,这才对我有用,就像,这需要我的时间
SignUpOrSignin.xml
<UserJourneyBehaviors>
...
<ScriptExecution>Allow</ScriptExecution>
</UserJourneyBehaviors>
TrustFrameworkExtensions.xml / TrustFrameworkBase.xml
<ContentDefinition Id="api.selfasserted.appfactor.registration">
<LoadUri>https://raw.githubusercontent.com/mdzzaman/dev-info/master/az/selfasserted-appfactor-registration.html</LoadUri>
<RecoveryUri>https://raw.githubusercontent.com/mdzzaman/dev-info/master/az/selfasserted-appfactor-registration.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.6</DataUri>
<Metadata>
<Item Key="DisplayName">App Factor</Item>
</Metadata>
</ContentDefinition>
<ContentDefinition Id="api.error">
<LoadUri>~/tenant/templates/AzureBlue/exception.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:globalexception:1.2.1</DataUri>
<Metadata>
<Item Key="DisplayName">Error page</Item>
</Metadata>
</ContentDefinition>
<ContentDefinition Id="api.signuporsignin">
<LoadUri>~/tenant/templates/AzureBlue/unified.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:unifiedssp:2.1.4</DataUri>
<Metadata>
<Item Key="DisplayName">Signin and Signup</Item>
</Metadata>
</ContentDefinition>
... 全部
尽管 AAD B2C 策略的所有设置均正确,但我还是发现了两个问题。第一个问题是浏览器正在缓存旧的 html,我需要通过清除缓存来重新加载。另一个问题是,如果我按照 AAD B2C 文档的建议将脚本放入标头中,它就不会执行。我将它移动到 body 元素并且它起作用了。