【问题标题】:Custom Policy RESTful-Api UserJourney Error自定义策略 RESTful-Api UserJourney 错误
【发布时间】:2017-11-03 15:18:24
【问题描述】:

我正在开发一个 RESTful 服务,该服务在 Azure AD B2C 的注册/登录过程中被调用。我的服务记录状态,该数据成功到达,并创建了输出声明 (customerId)。

但我收到以下错误消息,并且没有创建用户:

AADB2C90161 自断言的发送响应失败,原因是(内部服务器错误)。
相关 ID 7eac5fd2-cd85-4535-b166-4cc8f0264d07

我已经将自己定位于这个例子:https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/master/scenarios/aadb2c-ief-rest-api-netfw/

有没有人遇到过类似的问题并暗示我的问题可能是什么?

在 TrustFrameworkExtension 中:

<ClaimsProvider>
  <DisplayName>KTM REST APIs</DisplayName>
  <TechnicalProfiles>
    <TechnicalProfile Id="REST-API-SignUp">
      <DisplayName>Generate and return customerID claim</DisplayName>
      <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <Metadata>
        <Item Key="ServiceUrl">https://<my.service.com>/api/Identity/Signup</Item>
        <Item Key="AuthenticationType">None</Item>
        <Item Key="SendClaimsIn">Body</Item>
      </Metadata>

      <InputClaims>          
        <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="Email" />
        <InputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="FirstName" />
        <InputClaim ClaimTypeReferenceId="surname" PartnerClaimType="LastName" />
        <InputClaim ClaimTypeReferenceId="testClaim" PartnerClaimType="ObjectId" />           
      </InputClaims>
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />
      </OutputClaims>
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
    </TechnicalProfile>

    <TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
      <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />
      </OutputClaims>
      <ValidationTechnicalProfiles>
        <ValidationTechnicalProfile ReferenceId="REST-API-SignUp" />
      </ValidationTechnicalProfiles>
    </TechnicalProfile>
  </TechnicalProfiles>
</ClaimsProvider>

【问题讨论】:

标签: azure azure-active-directory azure-ad-b2c


【解决方案1】:

在这种情况下,您遇到了运行时错误。声明类型“customerId”在策略中定义为字符串,但看起来通过网络传来的值(其中 partnerClaimType 为“CustomerId”)是一个数字,因此系统无法映射它。看到这一行:

<OutputClaim ClaimTypeReferenceId="customerId" PartnerClaimType="CustomerId" />

这就是 Rest API 返回字符串与数字的方式(注意数字中没有引号):

{
   "name": "John",
   "age": 24
}

虽然此消息可以改进,you should configure your policy to collect logs using Application Insights。这将使您能够更轻松地调试类似的运行时问题。

【讨论】:

    猜你喜欢
    • 2015-10-14
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-06
    相关资源
    最近更新 更多