3

以下のような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>
4

2 に答える 2

3

UserNameCredentialsを設定することにより、実際にはユーザー名トークンプロファイルを活用しています。これにより、トークンが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)とトークン交換を行う場合のみです。

于 2009-10-28T23:00:08.503 に答える
0

サンプルの 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>
于 2009-10-28T14:04:34.633 に答える