You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AD B2C自定义策略:如何实现条款与条件自动同意功能?

解决方案:将AD B2C条款同意改为“继续即同意”模式

要实现从“手动勾选同意”到“继续操作即视为同意”的切换,可通过以下步骤修改自定义政策:

1. 更新条款同意声明的ClaimType配置

修改TrustedFrameworkExtension.xml中的extension_TermsOfServiceConsented声明,将其改为隐藏输入并默认设置为true:

<ClaimType Id="extension_TermsOfServiceConsented">
  <DisplayName>Terms of Service Consented</DisplayName>
  <DataType>string</DataType>
  <DefaultPartnerClaimTypes>
    <Protocol Name="OAuth2" PartnerClaimType="tos_consented" />
    <Protocol Name="OpenIdConnect" PartnerClaimType="tos_consented" />
    <Protocol Name="SAML2" PartnerClaimType="http://schemas.[domain].com/identity/claims/tosconsented" />
  </DefaultPartnerClaimTypes>
  <UserInputType>Hidden</UserInputType>
  <DefaultValue>true</DefaultValue>
</ClaimType>
  • 移除原有的CheckboxMultiSelect类型和Restriction枚举,改用Hidden类型避免用户交互
  • 添加DefaultValue="true"确保声明默认值为同意状态

2. 确保声明在用户旅程中被正确设置(可选增强)

如果需要在特定流程节点强制设置该声明,可添加ClaimsTransformation并关联到对应的技术配置文件:

定义ClaimsTransformation

在TrustedFrameworkExtension.xml的<ClaimsTransformations>节点下添加:

<ClaimsTransformation Id="SetTosConsentedToTrue" TransformationMethod="CreateStringClaim">
  <InputParameters>
    <InputParameter Id="value" DataType="string" Value="true" />
  </InputParameters>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="extension_TermsOfServiceConsented" TransformationClaimType="createdClaim" />
  </OutputClaims>
</ClaimsTransformation>

关联到自断言技术配置文件

找到对应的自断言页面技术配置文件(例如SelfAsserted-LocalAccountSignin-Email),添加输入转换:

<TechnicalProfile Id="SelfAsserted-LocalAccountSignin-Email">
  <!-- 保留原有配置 -->
  <InputClaimsTransformations>
    <InputClaimsTransformation ReferenceId="SetTosConsentedToTrue" />
  </InputClaimsTransformations>
</TechnicalProfile>

3. 更新UI提示文本

修改自定义UI的HTML模板,移除原复选框区域,替换为“继续即同意”的提示:

<div class="tos-consent-notice">
  继续操作即表示您同意我们的<a href="/terms">使用条款</a>和<a href="/privacy">隐私政策</a>
</div>

关键说明

  • 该方案符合行业通用做法,通过隐藏声明自动设置同意状态,无需用户手动勾选
  • 声明仍会按照原配置传递给下游应用(OAuth2/OIDC/SAML2协议均保持兼容)
  • 若需区分新老用户(仅首次访问时提示),可结合用户属性存储,添加条件分支判断

内容的提问来源于stack exchange,提问作者bobbyache

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 22:24:20