我正在建立一个入门的webapp来为我的LOB应用程序配置用户。我的大多数客户都是“商业客户”,这意味着他们通常会通过自定义策略定向到v1公共端点,允许他们对自己的AAD租户进行身份验证。挑战是新用户还需要在LOB应用程序中进行后续配置(创建数据库用户,分配一些权限等)。
作为入职的一部分,我想做的是调用graphAPI来创建将成为b2c中的联合用户帐户,然后使用新用户objectId返回处理特定于我的LOB应用程序的后续设置。理想情况下,当用户第一次到达时,他们将被重定向到针对他们自己的AAD的身份验证,然后映射到b2c中的预先创建的用户,最后使用已经配置并准备好的objectId登陆LOB应用程序。
这是一个支持的方案,有一些创意使用自定义策略和graphAPI?
谢谢马克
您有以下选项:
1.使用外部电子邮件地址创建本地帐户用户
使用Azure AD Graph API,您可以使用create a local account user,并将用户对象的signInNames属性设置为外部用户的电子邮件地址:
{
"accountEnabled": false,
"creationType": "LocalAccount",
"displayName": "John Smith",
"passwordProfile": {
"password": "a-strong-random-password",
"forceChangePasswordNextLogin": false
}
"signInNames": [
{
"type": "emailAddress",
"value": "[email protected]"
}
]
}
注意:我建议将用户对象的accountEnabled属性设置为true,以便最终用户无法使用本地帐户密码登录。
使用自定义策略,您可以添加新逻辑以使用外部电子邮件地址查找本地帐户用户,并将外部用户身份添加到此本地帐户用户,例如:
...
<!--
Find the external account user using the external user identity.
-->
<OrchestrationStep Order="16" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserReadUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserReadUsingAlternativeSecurityId-NoError" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If the external account user hasn't been found, then find the local account user using the external email address.
-->
<OrchestrationStep Order="17" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserReadUsingEmailAddress" TechnicalProfileReferenceId="AAD-UserReadUsingEmailAddress-NoError" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If an account user hasn't been found, then create an external account user with the external user identity.
-->
<OrchestrationStep Order="18" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>objectId</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUsingAlternativeSecurityId" TechnicalProfileReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ClaimsExchanges>
</OrchestrationStep>
<!--
If the local account user has been found using the external email address, then add the external user identity to this local account user.
-->
<OrchestrationStep Order="19" Type="ClaimsExchange">
<Preconditions>
<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
<Value>authenticationSource</Value>
<Value>localAccountAuthentication</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserWriteUsingAlternativeSecurityId technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="true">
<Value>newUserCreated</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
<!-- The following claim is output from the AAD-UserReadUsingEmailAddress-NoError technical profile. -->
<Precondition Type="ClaimsExist" ExecuteActionsIf="false">
<Value>existingUserFoundByEmail</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<ClaimsExchanges>
<ClaimsExchange Id="AADUserWriteUserIdentity" TechnicalProfileReferenceId="AAD-UserWriteUserIdentity" />
</ClaimsExchanges>
</OrchestrationStep>
...
2.使用外部用户标识创建外部帐户用户
使用Azure AD Graph API,可以将create an external account user与用户对象的userIdentities属性设置为外部用户的对象标识符:
{
"accountEnabled": false,
"displayName": "John Smith",
"mailNickname": "john.smith",
"otherMails": [
"[email protected]"
],
"userIdentities": [
{
"issuer": "https://sts.windows.net/{their-tenant-object-id}/",
"issuerUserId": "{their-user-object-id}"
}
],
"userPrincipalName": "{guid}@{your-tenant-name}.onmicrosoft.com"
}
其中issuerUserId必须设置为外部用户的对象标识符的base64编码。
注意:在Azure AD OpenID Connect技术配置文件中,您可能必须将socialIdpUserId声明的声明映射从子声明更改为oid声明,以便它与用户对象的userIdentities.issuerUserId属性匹配:
<OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="oid" />