在Azure B2C自定义策略中持久保留strongAuthenticationEmailAddress,重置StrongAuthenticationPhoneNumber以及反之亦然

问题描述

我能够通过修改策略扩展文件https://github.com/azure-ad-b2c/samples/tree/master/policies/username-signup-or-signin)中定义的“ ProfileEditWithUsername”用户流程来编辑“ strongAuthenticationEmailAddress”。我将StrongAuthenticationEmailAddress保留在“ AAD-UserWriteProfileUsingObjectId”技术资料中,上述用户旅程将其用作业务流程步骤4中的验证资料。

但是,我注意到,如果我运行策略来更改strongAuthenticationEmailAddress,则可以成功更改电子邮件,但是将StrongAuthenticationPhoneNumber和备用电话(用于身份验证)设置为空白。 同样,我实现了edit-MFA电话号码策略(https://github.com/azure-ad-b2c/samples/tree/master/policies/edit-mfa-phone-number),并使用它可以编辑strongAuthenticationPhoneNumber,但是它将strongAuthenticationEmailAddress设置为空白。

getKeysByPattern()

解决方法

我记得遇到了同样令人沮丧的问题。

如果您在TechnicalProfile中保留了StrongAuthentication字段之一,除非您也将其保留,否则它将清除任何其他StrongAuthentication字段。

因此,无论您在哪里保留一个strongAuthentication字段,都应将它们全部保留。在您的示例中,您的技术资料“ AAD-UserWriteProfileUsingObjectId”应如下所示:

2020-08-27 16:30:25.559888+0800 SocketConnectionTest[32297:26213693] SocketStream read error [0x6000020ce340]: 1 54 stream event NSStreamEvent(rawValue: 8) The operation couldn't be completed. Connection reset by peer stream event NSStreamEvent(rawValue: 8) The operation couldn't be completed. Connection reset by peer

请注意PersistedClaims中为strongAuthenticationPhoneNumber添加的新行。

在方案中还有另一个地方发生,它与signInNames集合有关。如果您坚持使用诸如signInNames.username之类的东西,它将清除所有其他signInNames(例如signInNames.emailaddress),除非您也坚持执行signInNames.emailaddress,所以也要注意这一点。