我有一个应用程序直接针对WIF / WCF活动STS进行身份验证。该应用程序也是一个被动STS,充当网站依赖方的WS-Federation端点。
当用户登录网站RP时,他们会被重定向到被动STS进行身份验证(用户名和密码),并且在两步过程中,被动STS(充当主动RP)会向问题RST发送问题RST STS,并收到一个签名的SAML令牌作为回报。对于第二步,被动STS向STS发送第二个问题RST,使用上一步骤中收到的令牌进行身份验证。
问题是在第二步中,WCF客户端从SAML断言中剥离<Signature>
元素,然后再将其发送回SOAP头中的STS。我已经验证(通过测试序列化传递给ChannelFactory<TChannel>.CreateChannelWithIssuedToken
的令牌),当我在生成的频道上调用IWSTrustContract.Issue
时,令牌仍然存在签名。
这是断言XML,因为它应该提供给STS:
<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_0a5efbe5-446c-459c-8aaa-dda87748bca2" Issuer="https://sts.environment.com/" IssueInstant="2014-01-30T21:48:56.673Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:Conditions NotBefore="2014-01-30T21:48:56.673Z" NotOnOrAfter="2014-01-30T22:48:56.673Z">
<saml:AudienceRestrictionCondition>
<saml:Audience>https://login.environment.com/</saml:Audience>
</saml:AudienceRestrictionCondition>
</saml:Conditions>
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</saml:ConfirmationMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<trust:BinarySecret xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"><!--Removed--></trust:BinarySecret>
</KeyInfo>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="upn" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
<saml:AttributeValue><!--Removed--></saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<Reference URI="#_0a5efbe5-446c-459c-8aaa-dda87748bca2">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<DigestValue><!--Removed--></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue><!--Removed--></SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate><!--Removed--></X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</saml:Assertion>
这就是STS收到的服务跟踪查看器:
<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_0a5efbe5-446c-459c-8aaa-dda87748bca2" Issuer="https://sts.environment.com/" IssueInstant="2014-01-30T21:50:27.842Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:Conditions NotBefore="2014-01-30T21:50:27.841Z" NotOnOrAfter="2014-01-30T22:50:27.841Z">
<saml:AudienceRestrictionCondition>
<saml:Audience>https://login.environment.com/</saml:Audience>
</saml:AudienceRestrictionCondition>
</saml:Conditions>
<saml:AttributeStatement>
<saml:Subject>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</saml:ConfirmationMethod>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<trust:BinarySecret xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"><!--Removed--></trust:BinarySecret>
</KeyInfo>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Attribute AttributeName="upn" AttributeNamespace="http://schemas.xmlsoap.org/ws/2005/05/identity/claims">
<saml:AttributeValue><!--Removed--></saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
当然,STS无法验证断言的签名,因为它已被剥离,并且无法验证客户端并为网站RP颁发持票令牌。
为什么WCF联合客户端从断言中剥离签名,如何让它不这样做呢?