2017-09-23 118 views
1

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

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

下面是万一有人的背景下一些细节也遇到过类似的情况,并发现了一个有用的解决方案:

我们探索解决与Azure的AD B2C以下情形的选项:注册用户邀请他人通过向应用程序的登录页面发送具有url的邀请电子邮件以及特殊的邀请代码(guid)作为查询参数来注册应用程序,因此它可以单击该链接并将其重定向到注册页面。被邀请的人创建一个帐户后,我们需要使用该代码才能将新创建的用户与发送邀请的用户相关联。

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

+0

欢迎来到Stack Overflow。你已经尝试过这么做了什么?请回顾[我如何问一个好问题](https://stackoverflow.com/help/how-to-ask)。堆栈溢出不是一种编码服务。预计您会在发布之前研究您的问题,并尝试亲自编写代码***。如果您遇到* specific *,请返回并包含[Minimal,Complete和Verifiable示例](https://stackoverflow.com/help/mcve)以及您尝试的内容摘要,以便我们提供帮助。 – FluffyKitten

+0

@FluffyKitten对此没有具体说明?第一句话是一个非常具体的问题。并且我可能会添加一个很好的问题:)问候,Mike D. – spottedmahn

+1

@spottedmahn自从我发表评论以来,该问题已被编辑。但仅仅是单独具体是不够的 - 在我最初的评论中看到其余的要求。 – FluffyKitten

回答

1

邀请流程的工作示例为here

WingTipGamesWebApplication项目中,InvitationController控制器类有两个操作方法,CreateRedeem

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

Redeem操作方法处理兑换链接。它将电子邮件地址作为verified_email声明在由Wingtip Games应用程序的客户端密钥签名的JWT中(请参阅中类中中的方法),从兑换链接到邀请政策。它也可以传递邀请码。

邀请政策可以在here找到。

邀请政策声明verified_email权利要求作为输入,根据权利要求:

<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> 

extension_verifiedEmail权利要求类型,它被声明为只读字段(使得它不能被映射到verified_email输入声明:

<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> 

邀请用户旅程可在here中找到。

邀请用户旅程的第二编制步骤执行LocalAccount登记-VerifiedEmail技术简介:

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

LocalAccount登记-VerifiedEmail技术简介与注册的本地帐户已验证电子邮件地址:

<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> 

要保存对本地帐户的邀请码,您必须:

  • 添加“extension_InvitationCode”要求权利要求的模式
  • 其添加为输入声明到邀请政策
  • 其添加为输入声明到LocalAccount登记-VerifiedEmail技术简介
  • 添加它作为一个持久要求的AzureActiveDirectoryStore-WriteUserByEmail-ThrowIfExist技术简介
+0

感谢您的详细解释。为了确认我们的理解 - 建议的解决方案是创建一个自定义策略,可以在验证电子邮件的模型之后添加一个新属性作为声明,并且此属性将存储在Azure AD B2C中,并在声明之后作为声明返回给Web应用程序。来宾用户注册?实际上,遵循这个模型,可以添加许多自定义属性,是否正确?要部署它,它只是上传这些文件: .._ B2C_1A_base.xml .._ B2C_1A_base_extensions.xml .._ B2C_1A_invitation.xml 或其他步骤是必需的吗? –

+1

对于上述所有问题,您都是正确的。向Web应用程序发出定制声明将使Web应用程序能够将邀请用户与邀请用户相链接。或者,您可以在用户旅程中添加编排步骤,以调用REST式服务(例如Azure功能)来链接它们。 –

相关问题