2009-05-21 7 views
3

私はASP.NETアプリケーションでWCFサービスに接続しています。私は1つのユーザー名とパスワードを使用してログインしており、whoeveverの実際のユーザー名をASP.NET Webアプリケーションにメッセージヘッダーで以下のように記録しています。私も、私は心配何wcf:メッセージヘッダーにユーザー名を追加することは安全ですか?

 <serviceCredentials> 
     <serviceCertificate findValue="CN=tempCert" /> 
     <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 
      membershipProviderName="MySqlMembershipProvider" /> 
     </serviceCredentials> 

以下のようにサービスの証明書を使用してい

using (OperationContextScope scope = new OperationContextScope(myService2.InnerChannel)) 
    { 
    Guid myToken = Guid.NewGuid(); 

    MessageHeader<string> messageHeader = new MessageHeader<string>(HttpContext.Current.User.Identity.Name); 
    MessageHeader untyped = messageHeader.GetUntypedHeader("token", "ns"); 

    OperationContext.Current.OutgoingMessageHeaders.Add(untyped); 

    lblResult.Text = myService2.GetData(1231); 
    } 

は、この十分な保護は人々がメッセージヘッダに格納されているユーザー名になって停止するかどうか?

ASP.NETの設定は

<system.serviceModel> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name="NewBehavior"> 
       <clientCredentials> 
        <serviceCertificate> 
         <authentication revocationMode="NoCheck"/> 
        </serviceCertificate> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="wsHttpEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/> 
        <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/WCFTestService/Service.svc" behaviorConfiguration="NewBehavior" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint" contract="WCFTestService.IService" name="wsHttpEndpoint"> 
      <identity> 
       <certificate encodedValue=""/> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

であり、サービス側でその

<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpEndpointBinding"> 
     <security> 
     <message clientCredentialType="UserName" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="ServiceBehavior" name="Service"> 
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" 
     name="wsHttpEndpoint" contract="IService"> 
     <!--<identity> 
     <dns value="" /> 
     </identity>--> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
     <serviceCredentials> 
     <serviceCertificate findValue="CN=tempCert" /> 
     <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 
      membershipProviderName="MySqlMembershipProvider" /> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

答えて

2

大きな問題は次のとおりです。あなたは、トランスポート・レベルまたはmessage-のいずれかの種類を持っていますあなたのバインディングでレベルのセキュリティが有効になっている?どのバインディングを使用していますか?

トランスポートレベルのセキュリティ(通常はSSL経由のHTTPSを使用)を使用している場合は、非常に安全であると思われるポイントツーポイント暗号化トランスポートチャネルがあります。

クライアント上の証明書を使用するメッセージレベルのセキュリティもあり、メッセージ全体を暗号化する場合は、安全でなければなりません。

実際に使用しているバインディングと、そのバインディングで使用しているセキュリティ設定はまったく異なります。私たちにサーバーの設定を見せてください!

マーク

+0

設定を表示するように投稿を更新しました。まだこのすべてのもので自分のやり方を感じているので、私は知恵のナゲットに感謝します! – AJM

+1

私はあなたが大丈夫だと思います。 wsHttpBindingを指定し、サービスはサービス証明書を使用してクライアントに対して自身を認証します。メッセージレベルのセキュリティが指定されています。つまり、クライアントはすべてサービス証明書の公開鍵を使用してメッセージを暗号化し、それらを有線経由で送信します。また、サービスの公開鍵を使用して暗号化されるため、秘密鍵はそれらを解読することができる。私はあなたが安全でなければならないと思います。 –

+0

助けてくれてありがとう:-) – AJM

関連する問題