Ping Federate抛出错误:cvc-complex-type.2.4c:验证SAML响应时

问题描述 投票:0回答:1

我正在向Ping Federate发送SAML回复。如果SAML响应包含SAML属性,则它可以正常工作,而如果SAML响应不包含SAML属性,则会抛出以下错误:

响应XML无效。错误:[错误:cvc-complex-type.2.4c:预期元素'Attribute @ urn:oasis:names:tc:SAML:2.0:断言EncryptedAttribute @ urn:oasis:names:tc:SAML:2.0:断言'之前'元素AttributeStatement @ urn中的内容结尾:oasis:names:tc:SAML:2.0:assertion]。

以下是抛出此错误的SAML响应(没有SAML属性):

<?xml version="1.0" encoding="UTF-8"?>
<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" Destination="https://test/sp/ACS.saml2" ID="frtgckggfpwphf_vxeatxzlvgrq" IssueInstant="2018-08-30T11:50:38.183Z" Version="2.0">
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">Test</saml2:Issuer>
    <saml2p:Status>
        <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
    </saml2p:Status>
    <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="_4947dc191f01c1e98d448c2fadd5c289" IssueInstant="2018-08-30T11:50:38.183Z" Version="2.0">
        <saml2:Issuer>Test</saml2:Issuer>
        <saml2:Subject>
            <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">testUser</saml2:NameID>
            <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                <saml2:SubjectConfirmationData NotOnOrAfter="2018-08-30T11:52:38.183Z" Recipient="https://test/sp/ACS.saml2"/>
            </saml2:SubjectConfirmation>
        </saml2:Subject>
        <saml2:Conditions NotBefore="2018-08-30T11:50:38.183Z" NotOnOrAfter="2018-08-30T11:52:38.183Z">
            <saml2:AudienceRestriction>
                <saml2:Audience>TestAudience</saml2:Audience>
            </saml2:AudienceRestriction>
        </saml2:Conditions>
        <saml2:AuthnStatement AuthnInstant="2018-08-30T11:50:38.184Z" SessionIndex="_4947dc191f01c1e98d448c2fadd5c289">
            <saml2:AuthnContext>
                <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml2:AuthnContextClassRef>
            </saml2:AuthnContext>
        </saml2:AuthnStatement>
        <saml2:AttributeStatement/>
    </saml2:Assertion>
</saml2p:Response>

我相信这可能是因为

<saml2:AttributeStatement/>

但是在线工具说上面的XML是有效的。

Ping Federate是否需要特定格式的SAML响应(即,如果没有SAML属性,则没有'saml2:AttributeStatement'),或者这是完全不同的问题?

谢谢

single-sign-on saml opensaml pingfederate
1个回答
1
投票

SAML核心规范(https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf)说:

2.7.3元素<AttributeStatement>

<AttributeStatement>元素描述了SAML权威机构声明断言主题与指定属性相关联的声明。包含<AttributeStatement>元素的断言必须包含<Subject>元素。它是AttributeStatementType类型,它通过添加以下元素来扩展StatementAbstractType<Attribute><EncryptedAttribute> [一个或多个] <Attribute>元素指定断言主题的属性。加密的SAML属性可以包含在<EncryptedAttribute>元素中。以下模式片段定义了<AttributeStatement>元素及其AttributeStatementType复杂类型:

<element name="AttributeStatement" type="saml:AttributeStatementType"/>
<complexType name="AttributeStatementType">
  <complexContent>
    <extension base="saml:StatementAbstractType">
      <choice maxOccurs="unbounded">
        <element ref="saml:Attribute"/>
        <element ref="saml:EncryptedAttribute"/>
      </choice>
    </extension>
  </complexContent>
</complexType>

您使用的在线工具不正确(它们可能只是验证XML而不是针对SAML架构进行验证):您必须在<Subject>中包含Attribute和“一个或多个”EncryptedAttributeAttributeStatement

FWIW:如果你不打算发送任何属性,你可以将AttributeStatement全部放在一起,只是发送一个空的违反规范。

© www.soinside.com 2019 - 2024. All rights reserved.