Azure AD B2C 在注册策略中预填充自定义属性

2024-01-04

从 Web 应用程序 (ASP.Net MVC) 调用时,Azure AD B2C 是否支持在注册策略中预填充自定义属性?

我们可以创建自定义 SignUp 属性,但我们无法在文档中找到如何传递值来填充自定义属性的规范。如果开箱即用不支持此功能,是否有人找到解决方法?

以下是有关上下文的更多详细信息,以防有人遇到类似的情况并找到有用的解决方案:

我们探索使用 Azure AD B2C 解决以下场景的选项:注册用户通过发送邀请电子邮件来邀请其他人注册应用程序,其中包含应用程序登录页面的 url 以及作为特殊邀请码 (guid) 的查询参数,这样它就可以点击链接并重定向到注册页面。受邀者创建帐户后,我们需要使用代码将新创建的用户与发送邀请的用户关联起来。

目前,这是使用默认身份提供程序在 ASP.Net 中实现的(使用 AspNet... 表将用户数据存储在数据库中)。通过使用 Azure AD B2C 替换本地身份提供商,我们在往返 Azure AD B2C 注册页面期间丢失了上下文。用户单击电子邮件上的链接并进入注册页面,但邀请码未预先填充。


邀请流程的工作示例是here https://github.com/Azure-Samples/active-directory-b2c-advanced-policies/tree/master/wingtipgamesb2c.

In the WingTipGamesWebApplication项目,该InvitationController控制器类有两个操作方法,Create and Redeem.

The Create操作方法将签名的兑换链接发送到受邀用户的电子邮件地址。此兑换链接包含此电子邮件地址。它还可以包含邀请码。

The Redeem操作方法处理兑换链接。它传递电子邮件地址,作为已验证的电子邮件使用 Wingtip Games 应用程序的客户端密钥签名的 JWT 中的声明(请参阅CreateSelfIssuedToken方法中的Startup类中的WingTipGamesWebApplication项目),从兑换链接到邀请函政策。它还可以传递邀请码。

The 邀请函政策可以在以下位置找到:here https://github.com/Azure-Samples/active-directory-b2c-advanced-policies/blob/master/wingtipgamesb2c/Policies/b2ctechready.onmicrosoft.com_B2C_1A_invitation.xml.

The 邀请函政策宣布已验证的电子邮件声明作为输入声明:

<RelyingParty>
  <DefaultUserJourney ReferenceId="Invitation" />
  <TechnicalProfile Id="Invitation">
    <InputTokenFormat>JWT</InputTokenFormat>
      <CryptographicKeys>
        <Key Id="client_secret" StorageReferenceId="WingTipGamesClientSecret" />
    </CryptographicKeys>
    <InputClaims>
      <InputClaim ClaimTypeReferenceId="extension_VerifiedEmail" />
    </InputClaims>
  </TechnicalProfile>
</RelyingParty>

The 扩展名验证电子邮件声明类型,声明为只读字段(以便最终用户无法修改),映射到已验证的电子邮件输入声明:

<BuildingBlocks>
  <ClaimsSchema>
    <ClaimType Id="extension_VerifiedEmail">
      <DisplayName>Verified Email</DisplayName>
      <DataType>string</DataType>
      <DefaultPartnerClaimTypes>
        <Protocol Name="OAuth2" PartnerClaimType="verified_email" />
        <Protocol Name="OpenIdConnect" PartnerClaimType="verified_email" />
        <Protocol Name="SAML2" PartnerClaimType="http://schemas.wingtipb2c.net/identity/claims/verifiedemail" />
      </DefaultPartnerClaimTypes>
      <UserInputType>Readonly</UserInputType>
    </ClaimType>
  </ClaimsSchema>
</BuildingBlocks>

The 邀请函用户旅程可以在here https://github.com/Azure-Samples/active-directory-b2c-advanced-policies/blob/master/wingtipgamesb2c/Policies/b2ctechready.onmicrosoft.com_B2C_1A_base.xml.

第二个编排步骤邀请函用户旅程执行本地帐户-注册-验证电子邮件技术简介:

<UserJourney Id="Invitation">
  <OrchestrationSteps>
    ...
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <ClaimsExchanges>
        ...
        <ClaimsExchange Id="LocalAccountRegistrationExchange" TechnicalProfileReferenceId="LocalAccount-Registration-VerifiedEmail" />
      </ClaimsExchanges>
    </OrchestrationStep>
  </OrchestrationSteps>
</UserJourney>

The 本地帐户-注册-验证电子邮件技术配置文件使用经过验证的电子邮件地址注册本地帐户:

<TechnicalProfile Id="LocalAccount-Registration-VerifiedEmail">
  <DisplayName>WingTip Account</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="ContentDefinitionReferenceId">api.localaccount.registration</Item>
    <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
    <Item Key="language.button_continue">Create</Item>
  </Metadata>
  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="TokenSigningKeyContainer" />
  </CryptographicKeys>
  <InputClaimsTransformations>
    <InputClaimsTransformation ReferenceId="CreateEmailFromVerifiedEmail" />
  </InputClaimsTransformations>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="extension_VerifiedEmail" />
  </InputClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="extension_VerifiedEmail" Required="true" />
    <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="displayName" Required="true" />
    <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="localAccountAuthentication" />
    <OutputClaim ClaimTypeReferenceId="executed-SelfAsserted-Input" DefaultValue="true" />
    <OutputClaim ClaimTypeReferenceId="newUser" />
    <OutputClaim ClaimTypeReferenceId="objectId" />
    <OutputClaim ClaimTypeReferenceId="sub" />
    <OutputClaim ClaimTypeReferenceId="userPrincipalName" />
  </OutputClaims>
  <ValidationTechnicalProfiles>
    <ValidationTechnicalProfile ReferenceId="AzureActiveDirectoryStore-WriteUserByEmail-ThrowIfExists" />
  </ValidationTechnicalProfiles>
  <UseTechnicalProfileForSessionManagement ReferenceId="SSOSession-AzureActiveDirectory" />
</TechnicalProfile>

本地账户注册前Azure Active Directory 存储-通过电子邮件写入用户-ThrowIf 存在验证技术概况,从已验证的电子邮件创建电子邮件索赔转换复制已验证的电子邮件声称对email claim:

<ClaimsTransformation Id="CreateEmailFromVerifiedEmail" TransformationMethod="FormatStringClaim">
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="extension_VerifiedEmail" TransformationClaimType="inputClaim" />
  </InputClaims>
  <InputParameters>
    <InputParameter Id="stringFormat" DataType="string" Value="{0}" />
  </InputParameters>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="email" TransformationClaimType="outputClaim" />
  </OutputClaims>
</ClaimsTransformation>

要将邀请码保存到本地帐户,您必须:

  • 将“extension_InvitationCode”声明添加到声明架构中
  • 将其作为输入声明添加到邀请函 policy
  • 将其作为输入声明添加到本地帐户-注册-验证电子邮件技术简介
  • 将其作为持久声明添加到Azure Active Directory 存储-通过电子邮件写入用户-ThrowIf Exist技术简介
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Azure AD B2C 在注册策略中预填充自定义属性 的相关文章

随机推荐

  • iOS:在视频中裁剪视频左侧和底部的奇怪绿线

    如何删除视频上的绿线 当裁剪视频 2 或 3 次时 视频中的左侧或底部或左侧和底部均显示绿色或混合绿红闪烁线 视频裁剪方法 void cropButton CGRect cropFrame self cropView croppedImag
  • 如何修复使用 pdfbox java 链接的可访问性标记注释失败/错误?

    使用 adobe 找到了解决方案 https answers acrobatusers com How I fix Tagged Annotations fail error accessibility links q228128 aspx
  • C# 4 和 CLR 兼容性

    C 版本 4 的所有新增内容 动态 代码契约等 是否预计将在当前的 NET CLR 上运行 或者是否也有计划的 NET 升级 C 4 将需要 NET 4 0 CLR
  • 为什么当我使用命令行进行屏幕录制时,屏幕录制会出现错误[关闭]

    Closed 这个问题需要细节或清晰度 help closed questions 目前不接受答案 我正在尝试通过以下方式对我的 Android 设备进行屏幕录制this http developer android com about v
  • Rails:已完成 401 未经授权

    我收到此错误 但我不知道为什么 我特别排除了 CSRF 检查 这 webhook即使在生产中 该方法也有效 其他类似的问题是关于 Devise 的 但我没有在此控制器中使用 Devise stripes controller rb clas
  • 从 Node.js 将 Json 存储到 MySQL 数据库

    我知道这个问题已经被问过很多次了 但是经过激烈的搜索 我似乎找不到我正在寻找的答案 我有一个 js 格式的脚本 它创建一个 json 数据数组 然后将其存储在一个 json 文件中 阵列设置为 var sessionState curren
  • 如何将光标移动到文档末尾?

    我想将光标移动到脚本开头的文档末尾 我怎么做 我已经知道如何将光标移动到文档的开头 如下所述here https stackoverflow com questions 26945026 how can i move the cursor
  • 如何通过 https 启动 java servlet?

    我正在尝试在 eclipse 中的 tomcat 上运行 servlet 当我在服务器上运行时 servlet 会运行并为我提供如下链接 http localhost 8443 AuthServer 服务器 我已将 Tomcat 服务器配置
  • google app engine webapp 中 jinja2 自动转义的问题

    我决定安装 jinja2 与我的 webapp 应用程序一起使用 以支持自动转义功能 因此 我将 jinja2 安装到 python 2 5 中 并在项目中创建了一个符号链接来指向该目录 大部分情况下工作正常 除了 当我实际尝试使用 aut
  • 如何更改 Visual Studio 2012 Express 项目模板?

    例如 我不希望我的类和接口符合 StyleCop 在非 Express 版本中 我们可以在以下位置找到并更改类模板 C Program Files x86 Microsoft Visual Studio 11 0 Common7 IDE I
  • 更改 SFSafariViewController 的色调颜色?

    正如标题所说 如何更改 iOS 9 中新的 SFSafariViewController 的整体色调颜色 iOS 10 的一些消息 现在我们有两个属性来控制整体外观SFSafariViewController source link htt
  • Java Runtime.getRuntime().exec() 带引号

    我正在尝试通过 linux 上的 exec 调用运行 ffmpeg 但是我必须在命令中使用引号 ffmpeg 需要它 我一直在查看 processbuilder 和 exec 的 java 文档以及 stackoverflow 上的问题 但
  • 对服务与工厂感到困惑

    据我了解 当在工厂内部时 我返回一个被注入控制器的对象 当在服务内部时 我正在使用以下方法处理对象this并且不返回任何东西 我假设服务是始终是单身人士 并且一个新工厂对象被注入到每个控制器中 然而 事实证明 工厂对象也是单例对象吗 演示示
  • JSF MVC设计问题

    我有一个 JSF 支持 bean 设计问题 现在 我的支持 bean 保存 UI 显示信息和业务模式数据 人们建议模型和视图应该分开 那么创建不同的 bean 来保存 UI 显示数据并让支持 bean 引用它是个好主意吗 那么创建不同的 b
  • 我可以只选择 MYSQL 中的一列而不是全部,以使其更快吗?

    我想做这样的事情 query mysql query SELECT userid FROM users WHERE username username the user id 因为我想要的只是与用户名对应的用户ID 通常的方法是 query
  • 如何格式化 SQLCMD 输出

    我正在使用下面的命令行使用 SQLCMD 运行 SQL 查询 sqlcmd S Server Q select top 100 From people d people t 10 该表有 20 列 当我查看输出命令行窗口时 文本会换行并使其
  • 客户端 MVC 与服务器 MVC

    我希望从其他用户那里获得一些关于服务器端 MVC 优势的意见 拥有许多 javascript 库的强大功能 服务器端 MVC 服务器还有什么用处呢 您可以轻松地使用带有模板和 REST API 的客户端 MVC 来创建响应速度更快的应用程序
  • subprocess.Popen,从子进程(子进程)获取变量[重复]

    这个问题在这里已经有答案了 我想知道如何处理它 我从子进程到父进程获取变量 值 我正在将子进程作为脚本运行 父级看起来像 import subprocess p subprocess Popen abaqus python getData
  • 为什么负载不能绕过同一核心上的另一个线程从写入缓冲区写入的值?

    如果CPU核心使用写缓冲区 则负载可以从写缓冲区绕过最近的存储到引用的位置 而无需等到它出现在缓存中 但是 正如它所写的记忆一致性和连贯性入门 https lagunita stanford edu c4x Engineering CS31
  • Azure AD B2C 在注册策略中预填充自定义属性

    从 Web 应用程序 ASP Net MVC 调用时 Azure AD B2C 是否支持在注册策略中预填充自定义属性 我们可以创建自定义 SignUp 属性 但我们无法在文档中找到如何传递值来填充自定义属性的规范 如果开箱即用不支持此功能