【问题标题】:B2C SAML missing claimsB2C SAML 缺失声明
【发布时间】:2018-09-15 02:28:46
【问题描述】:

我正在尝试使用 B2C 自定义策略将 B2C 配置为我的 SAML Idp。作为测试,我已将我们的本地 ADFS 环境设置为 SAML RP,这似乎是 B2C 登录页面正常工作所必需的(B2C SAML 不支持 Idp 发起的会话)。

我一直按照 https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-get-started-customhttps://github.com/Azure-Samples/active-directory-b2c-advanced-policies/blob/master/Walkthroughs/RP-SAML.md 的指南来设置我的 B2C 环境。

我只显示了最终用户收到的 B2C 登录页面,但是在我将帐户的凭据输入到 B2C 登录页面后,我会使用 SAML 令牌重定向回我的 RP,但是它未解析任何已配置的声明。 SAML 令牌显示以下错误:

<samlp:Status> 
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Responder" />
     <samlp:StatusMessage>Id:410906d7-639d-4828-b28d-22f84dfa617b ; Message: Policy &apos;B2C_1A_signup_signin_saml' in tenant ' mytenant.onmicrosoft.com'' specifies the claim 'sub' for the SubjectNamingInfo, but the claim is either not present or is null.</samlp:StatusMessage> 
<IsPolicySpecificError>true</IsPolicySpecificError> 
</samlp:Status>

我的 SignUpOrSigninSaml.xml RP 配置如下:

<RelyingParty>
  <DefaultUserJourney ReferenceId="SignUpOrSignInSaml"/>
    <TechnicalProfile Id="PolicyProfile">
      <DisplayName>PolicyProfile</DisplayName>
      <Protocol Name="SAML2" />
        <Metadata>
          <Item Key="PartnerEntity">https://adfs-test.mycorporation.com.au/FederationMetadata/2007-06/FederationMetadata.xml</Item>
          <Item Key="KeyEncryptionMethod">Rsa15</Item>
          <Item Key="DataEncryptionMethod">Aes256</Item>
          <Item Key="XmlSignatureAlgorithm">Sha256</Item>
        </Metadata>

    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="displayName" />
      <OutputClaim ClaimTypeReferenceId="givenName" />
      <OutputClaim ClaimTypeReferenceId="surname" />
    </OutputClaims>
    <!-- The ClaimType in the SubjectNamingInfo element below is a reference to the name of the claim added to the claims bag used by the token minting process.
    This name is determined in the following order. If no PartnerClaimType is specified on the output claim above, then the DefaultPartnerClaimType for the protocol specified in the claims schema if one exists is used, otherwise the ClaimTypeReferenceId in the output claim is used.

    For the SubjectNamingInfo below we use the DefaultPartnerClaimType of http://schemas.microsoft.com/identity/claims/objectidentifier, since the output claim does not specify a PartnerClaimType. -->
    <!-- <SubjectNamingInfo ClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" ExcludeAsClaim="true"/> -->
    <SubjectNamingInfo ClaimType="sub" />
</TechnicalProfile>
</RelyingParty>

我为“SubjectNamingInfo”尝试了几种不同的配置,例如:

<SubjectNamingInfo ClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" ExcludeAsClaim="true"/>

<SubjectNamingInfo ClaimType="sub" />

<SubjectNamingInfo ClaimType="name" />

但它们都产生相同的错误。

我相信,一旦对 SubjectNamingInfo 问题进行排序,配置的 OutputClaims 就会显示出来。

有人知道我该如何解决这个问题,以便我能够在令牌中看到我的用户帐户的声明吗?

---编辑---

我试图添加“sub”作为输出声明,但是由于它没有在基本文件中定义,B2C 不允许它。或者,我尝试将主题命名信息更改为已定义为输出声明的声明

<SubjectNamingInfo ClaimType="givenName" />

但是我似乎仍然遇到同样的错误:

<samlp:Status> 
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Responder" /> 
<samlp:StatusMessage>Id:a3fe7ab0-4483-45b6-93f8-e75b539a3aea ; Message: The relying party technical profile of policy &apos;mytenant.onmicrosoft.com' in tenant 'B2C_1A_signup_signin_saml' specifies the claim type 'givenName' as the subject naming info claim, but the claim is not present or is null.</samlp:StatusMessage> 
<IsPolicySpecificError>true</IsPolicySpecificError>

【问题讨论】:

  • 您是否在作为此旅程的一部分执行的任何步骤中为主题声明设置值?
  • @nyoung 我已经尝试将主题声明设置为 givenName 知道它应该在用户旅程期间设置。收到同样的错误

标签: saml-2.0 azure-ad-b2c


【解决方案1】:

sub 声明用作 SAML 断言的 &lt;saml:Subject&gt;&lt;saml:NameID&gt; 元素并不常见。

建议使用 objectId 声明如下。

1) 确保 objectId 声明与 SAML2 协议的合作伙伴声明一起声明:

<ClaimType Id="objectId">
  <DisplayName>Object Identifier</DisplayName>
  <DataType>string</DataType>
  <DefaultPartnerClaimTypes>
    <Protocol Name="OAuth2" PartnerClaimType="oid" />
    <Protocol Name="OpenIdConnect" PartnerClaimType="oid" />
    <Protocol Name="SAML2" PartnerClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" />
  </DefaultPartnerClaimTypes>
</ClaimType>

2) 将 objectId 声明添加到依赖方技术配置文件的 &lt;OutputClaims /&gt; 集合并设置 SubjectNamingInfo 元素:

<RelyingParty>
  <TechnicalProfile Id="PolicyProfile">
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="objectId" />
      <OutputClaim ClaimTypeReferenceId="displayName" />
      <OutputClaim ClaimTypeReferenceId="givenName" />
      <OutputClaim ClaimTypeReferenceId="surname" />
    </OutputClaims>
    <SubjectNamingInfo ClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" ExcludeAsClaim="true"/>
  </TechnicalProfile>
</RelyingParty>

更多关于SubjectNamingInfo

的信息

SubjectNamingInfo 元素的 ClaimType 属性引用必须声明为技术配置文件的输出声明的声明类型。

此声明类型按名称引用,具有以下优先级:

1) 如果为 OutputClaim 元素指定了 PartnerClaimType 属性,则为 SubjectNamingInfo 指定 ClaimType 属性> 元素必须设置为此 OutputClaim 元素的 ClaimTypeReferenceId 属性:

<RelyingParty>
  <TechnicalProfile Id="PolicyProfile">
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="objectId" PartnerClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" />
      ...
    </OutputClaims>
    <SubjectNamingInfo ClaimType="objectId" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" ExcludeAsClaim="true"/>
  </TechnicalProfile>
</RelyingParty>

2) 如果未指定 OutputClaim 元素的 PartnerClaimType 属性,则 SubjectNamingInfoClaimType 属性strong> 元素必须设置为此 OutputClaimClaimTypeReferenceId 属性引用的 ClaimType 元素的 DefaultPartnerClaimType 属性强>元素:

<ClaimType Id="objectId">
  <DefaultPartnerClaimTypes>
    <Protocol Name="SAML2" PartnerClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" />
  </DefaultPartnerClaimTypes>
</ClaimType>

<RelyingParty>
  <TechnicalProfile Id="PolicyProfile">
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="objectId" />
      ...
    </OutputClaims>
    <SubjectNamingInfo ClaimType="http://schemas.microsoft.com/identity/claims/objectidentifier" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" ExcludeAsClaim="true"/>
  </TechnicalProfile>
</RelyingParty>

【讨论】:

  • 我尝试将 SubjectNamingInfo 更改为“givenName”,知道它被配置为输出声明,但不幸的是仍然产生相同的错误。我已经用错误更新了我的帖子。
  • 嗨@Brady 我已经更新了上面的答案,提供了有关设置SubjectNamingInfo 元素的更多信息。
  • 嘿@Chris Padgett。感谢您提供详细信息,但它仍然产生相同的错误:我怀疑该问题与 B2C 中的此功能仍处于公共预览版这一事实有关,但我很高兴向您发送我的 Base、Extensions 和 RP .xml如果您想自己尝试文件?或者,如果您在 B2C 租赁中使用此功能,我可以试一下您的配置文件吗? (当然删除了文件中的敏感信息:))
  • Hi @Brady An example policy 可以在 Wingtip 示例中找到。它调用a sign-in user journey,并使用SubjectNamingInfo 元素的userPrincipalName 声明发出SAML 令牌。
  • 嗨@LarsKemmann 我相信RP-SAML 示例在撰写本文时已经过时。建议 SAML 令牌颁发者技术配置文件确实引用 SAML SSO 会话提供程序技术配置文件,以便在 Azure AD B2C 和依赖方应用程序之间使用 SSO 会话。有关详细信息,请参阅here
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 2021-09-23
  • 1970-01-01
  • 1970-01-01
  • 2021-04-27
  • 2018-12-19
相关资源
最近更新 更多