single-sign-on - Ping Federate 抛出错误:cvc-complex-type.2.4c:验证 SAML 响应时
问题描述
我正在向 Ping Federate 发送 SAML 响应。如果 SAML 响应包含 SAML 属性,则它可以正常工作,而如果 SAML 响应不包含 SAML 属性,则会引发以下错误:
响应 XML 无效。错误:[错误:cvc-complex-type.2.4c:在元素 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”),还是完全不同的问题?
谢谢
解决方案
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
进行扩展 :或[一个或多个] 该 元素指定断言主题的属性。加密的 SAML 属性可以包含在元素中。以下模式片段定义了元素及其复杂类型:StatementAbstractType
<Attribute>
<EncryptedAttribute>
<Attribute>
<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
必须EncryptedAttribute
在AttributeStatement
.
FWIW:如果您不打算发送任何属性,则可以将所有属性AttributeStatement
一起省略,只是发送空属性违反规范。
推荐阅读
- google-cloud-platform - 谷歌云功能价格计算问题
- python - 使用字典时处理错误的 Pythonic 方法
- javascript - 带有 Leaflet 和 Leaflet.GridLayer.GoogleMutant 的 Safari 上不会触发事件上下文菜单
- javascript - Electron fs.writeFile - 多次保存文件时出现问题
- vhdl - 如何在 VHDL 中编写具有输入相关范围的 std_logic_vector 赋值?
- django - 使用 SearchVector 在 PSQL 和 Django 中按主键搜索
- mongodb - 如何从 MERN 中的 mongodb 获取数据
- javascript - 为什么我的 SQL 查询执行缓慢
- c# - 为什么我不能用 NLog 中的事件属性编写?
- r - 读取 1450000 行的 yelp review json 文件和更多行与 R