状況は次のとおりです。
- STS からのセキュリティ トークンを a の形式で
GenericXmlSecurityToken
持っています (そのための SAML アサーション要素もあります)。 - このセキュリティ トークンを使用してサード パーティのサービスを呼び出す必要
WS2007FederationHttpBinding
があります。 - 実際の SOAP リクエストには、SOAP セキュリティ ヘッダーの SAML アサーション要素に加えて
http://www.w3.org/2000/09/xmldsig#
、timestamp 要素に署名する署名要素 ( namespace から) と、SAML アサーションを含む body 要素も含める必要があります。 WS2007FederationHttpBinding
、および多くのカスタム バインディングのバリエーションでは、値の型を持つ署名にキー参照要素を含めることができませんhttp://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID
(つまり、SAML アサーション)。- 私が (= true を介して
ProtectTokens
) それらから得ることができたのは、署名された SAML アサーション要素ですが、それ以上ではありません。
基本的に、リクエストで取得する必要があるのは次のとおりです。
<soapenv:Header>
<wsse:Security>
<saml:Assertion="" AssertionID = "ID_56eecf2a-a143-4ec9-ab85-479d8602122f">
...
</saml:Assertion>
<WSU:Timestamp>
...
</WSU:Timestamp>
<ds:Signature>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="#rsa-sha1"/>
<!--Body signature-->
<ds:Reference URI="#id">
<ds:Transforms>
< ds: Transform Algorithm = "xml-exc-c14n #" />
</ds:Transforms>
<ds:DigestMethod Algorithm="#sha1"/>
<ds:DigestValue >
di3JiPJM90D3P62ChO1d4Sy12 + 4 =
</ds:DigestValue DigestValue>
</ds:Reference>
<!--Timestamp element signature-->
<ds:Reference URI = "#Timestamp" >
<ds:Transforms>
<ds:Transform Algorithm = "xml-exc-c14n #" />
</ds:Transforms>
<ds:DigestMethod Algorithm="#sha1"/>
< ds:DigestValue>C+GkwwH5RuXocsD0iphwUvmQpj0=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>kq+FG6qqdx...==</ds:SignatureValue>
<!--Key reference, pointing back to the SAML assertion element-->
<!--This is the actual problem. Didn't manage to add this at all.-->
<ds:KeyInfo>
<wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0 #SAMLAssertionID">
ID_56eecf2a-a143-4ec9-ab85-479d8602122f</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</soapenv:Header>
<soapenv:Body wsu:Id="id">
...
</soapenv:Body>
WS2007FederationHttpBinding
ただし、署名を追加するために (またはカスタム バインディング) を構成する方法については途方に暮れています。
私が今取り組んでいること:
/**
*
* Federation binding stuff
*
*/
var federationBinding = new WS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);
federationBinding.Security.Message.EstablishSecurityContext = false;
federationBinding.Security.Message.IssuedKeyType = SecurityKeyType.AsymmetricKey;
federationBinding.Security.Message.NegotiateServiceCredential = false;
federationBinding.Security.Message.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID";
federationBinding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Basic256;
/**
*
* Custom binding, the one actually used by the channel
*
*/
var binding = new CustomBinding(federationBinding.CreateBindingElements());
binding.Elements.Remove(binding.Elements.FirstOrDefault(i => i is TextMessageEncodingBindingElement));
var messageSecurity = (TransportSecurityBindingElement)binding.Elements.FirstOrDefault(i => i is TransportSecurityBindingElement);
//Remove it, I add another one later
binding.Elements.Remove(messageSecurity);
//Security element configuration
var secBinding = new AsymmetricSecurityBindingElement()
{
MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10,
ProtectTokens = true,
SecurityHeaderLayout = SecurityHeaderLayout.Lax,
IncludeTimestamp = true,
EnableUnsecuredResponse = true,
DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256
};
secBinding.InitiatorTokenParameters = new IssuedSecurityTokenParameters(
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
secBinding.RecipientTokenParameters = new IssuedSecurityTokenParameters(
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
secBinding.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
これに加えて、同じ結果で を使用してみTransportSecurityBindingElement
ました: リクエストでトークンを取得できますが、署名は取得できません。
これに関するアイデア/ヒントは大歓迎です。