gpt4 book ai didi

saml-2.0 - B2C SAML 缺失声明

转载 作者:行者123 更新时间:2023-12-03 06:35:08 25 4
gpt4 key购买 nike

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

我一直在遵循 https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-get-started-custom 上的指南和 https://github.com/Azure-Samples/active-directory-b2c-advanced-policies/blob/master/Walkthroughs/RP-SAML.md设置我的 B2C 环境。

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

<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就会显示。

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

---编辑---

我尝试添加“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>

最佳答案

使用 sub 声明作为 <saml:Subject><saml:NameID> 的情况并不常见SAML 断言的元素。

建议按如下方式使用 objectId 声明。

1) 确保使用 SAML2 协议(protocol)的合作伙伴声明声明 objectId 声明:

<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 声明添加到 <OutputClaims />收集依赖方技术概况并设置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 属性,则指定 SubjectNamingInfoClaimType 属性> 元素必须设置为此 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> 元素必须设置为 ClaimType 元素的 DefaultPartnerClaimType 属性,该元素由该 OutputClaimClaimTypeReferenceId 属性引用强>元素:

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

关于saml-2.0 - B2C SAML 缺失声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49669435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com