私は次のことを試みます:
- WCF クライアントが STS を呼び出し、SAML アサーションを取得する
- クライアントは SAML アサーションを使用してサービスを呼び出します
client.linq
上記のシナリオを 3 つのLinqPad スクリプトとして実装しましsts.linq
たservice.linq
。それらはすべてhttps://github.com/codeape2/WCF_STSにあります。
これを機能させるには、助けが必要です。
の次のコードを使用するclient.linq
と、STS を呼び出して SAML アサーションを取得できます。
SecurityToken GetToken()
{
var binding = new BasicHttpBinding();
var factory = new WSTrustChannelFactory(binding, stsAddress);
factory.TrustVersion = TrustVersion.WSTrustFeb2005;
var rst = new RequestSecurityToken
{
RequestType = RequestTypes.Issue,
KeyType = KeyTypes.Symmetric,
AppliesTo = new EndpointReference(serviceAddress)
};
return factory.CreateChannel().Issue(rst);
}
次のステップでは、次のコードを使用して、SAML アサーションを含めてサービスを呼び出します (試みます)。
var binding = new WSFederationHttpBinding(WSFederationHttpSecurityMode.Message);
binding.Security.Message.EstablishSecurityContext = false;
var factory = new ChannelFactory<ICrossGatewayQueryITI38>(
binding,
new EndpointAddress(new Uri(serviceAddress), new DnsEndpointIdentity("LocalSTS"))
);
factory.Credentials.SupportInteractive = false;
factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode =
X509CertificateValidationMode.None;
var proxy = factory.CreateChannelWithIssuedToken(token);
var response = proxy.CrossGatewayQuery(
Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "urn:ihe:iti:2007:CrossGatewayQuery", "Hello world")
);
次に何が起こるか、まったくわかりません。スクリプトを実行すると、フィドラーが実行されます。次のように表示されます。
/STS
(予想どおり)への最初のリクエストproxy.CrossGatewayQuery
への3 つの呼び出しの結果/Service
:2.1. アクション付きの SOAP 呼び出し
http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue
2.2. アクション付きの SOAP 呼び出し
http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue
2.3. action を指定した最後の SOAP 呼び出し
urn:ihe:iti:2007:CrossGatewayQuery
。Fiddler を使用すると、SOAP セキュリティ ヘッダーにステップ 1 の SAML アサーションが含まれていることに気付きました。
最後の呼び出しにより、サービスから SOAP エラーが返されます。メッセージ内の少なくとも 1 つのセキュリティ トークンを検証できませんでした。保存された Fiddler のリクエスト/レスポンス ログはこちら: https://drive.google.com/file/d/0B-UZlLvBjjB2S050TXRhVEo2Vmc/view?usp=sharing
誰かが次のことについて教えてくれたら、とても感謝しています。
RST/Issue
WCF クライアントがおよびRSTS/Issue
要求を に送信するのはなぜですか/Service
(上記の手順 2.1 および 2.2)。- つまり、STS から取得した SAML アサーションを渡して、STS に 1 つの要求を送信し、次にサービスに 1 つの要求を送信します。