WCFメッセージ資格情報の実装の詳細
-
06-07-2019 - |
質問
次のようなWCFバインディングを使用して、メッセージ交換中に実際のユーザー名+パスワード(資格情報)が保存される場所に関する技術的な詳細を探しています。
<bindings>
<wsHttpBinding>
<binding name="wsHttp">
<security mode="TransportWithMessageCredential">
<transport/>
<message clientCredentialType="UserName"
negotiateServiceCredential="false"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
次に、クライアントアプリケーション内でこのサービスを呼び出して、有効な一連の資格情報を渡します
using (SupplierServiceClient client = new SupplierServiceClient()) {
client.ClientCredentials.UserName.UserName = "admin";
client.ClientCredentials.UserName.Password = "password";
SupplierList = client.GetSupplierCollection();
}
最初は、WCFがこのデータを取得してそれをSOAPヘッダーに入れていると想定していましたが、WSDLからはそのようには見えません...何か助けがありますか?
編集:
以下は、本番環境でのクライアントのセキュリティ構成の様子です
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" establishSecurityContext="false" />
</security>
解決
UserNameCredentialsを設定すると、実際にはUsername Token Profileを活用します。これにより、トークンがSOAPヘッダーとしてメッセージに追加されます。 SOAPヘッダーは次のようになります。
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<env:Header>
<wsse:UsernameToken>
<wsse:Username>jdoe</wsse:Username>
<wsse:Password>passw0rd</wsse:Password>
<wsse:Nonce><!-- optional nonce here --></wsse:Nonce>
</wsse:UsernameToken>
</env:Header>
<env:Body>
<!-- body here -->
</env:Body>
</env:Envelope>
今、あなたがWSDLについて言及している理由は正確にはわかりません。トークンはWSDLに表示されませんが、WSDLには操作に関する適切なWS-Policy注釈が含まれている必要があります。これにより、WSDLのコンシューマーは、リクエストにUsernamePasswordTokenを実際に送信する必要があることを発見できます。
最後に、誰かがRequestSecurityToken(RST)を呼び出しましたが、単純なUsernameToken認証を使用しているだけの場合は、RSTが関与するべきではありません(必要ではありません)。 RSTが関与する必要があるのは、WS-Trustを使用してSecure Token Server(STS)とトークン交換を行う場合のみです。
他のヒント
サンプルSOAPメッセージは次のようになります。
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:MessageID>urn:uuid:01d3a7d2-dc5a-42cf-acf0-3dd6bd50230e</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://localhost:9999/Service1.svc</a:To>
</s:Header>
<s:Body>
<t:RequestSecurityToken Context="uuid-7c240c06-c14b-42af-82dd-10f44f423928-1" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<t:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeySize>256</t:KeySize>
<t:BinaryExchange ValueType="http://schemas.xmlsoap.org/ws/2005/02/trust/spnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">YGsGBisGAQUFAqBhMF+gJDAiBgorBgEEAYI3AgIKBgkqhkiC9xIBAgIGCSqGSIb3EgECAqI3BDVOVExNU1NQAAEAAAC3shjiBgAGAC8AAAAHAAcAKAAAAAUBKAoAAAAPU0cyMjA1Nk1BVE1VVA==</t:BinaryExchange>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
所属していません StackOverflow