2009-08-18 21 views
8

मैंने कई एमएसडीएन लेख और कोडप्लेक्स मार्गदर्शन का पालन किया है लेकिन डब्ल्यूसीएफ को केर्बेरोस प्रमाणीकरण और प्रतिनिधिमंडल के साथ काम करने के लिए नहीं मिल सकता है और थोड़ी मदद की सराहना करता है।डब्ल्यूसीएफ और केर्बेरोज प्रमाणीकरण

सेटअप

मैं एक दूरस्थ मशीन

  • पर एक आईआईएस वेबसाइट में WCF सेवा है IIS 6.0 Windows 2003 R2 पर - सपा 2
  • मशीन के लिए SPN जोड़ दिया गया है (http/myserver & & http/myserver: 8080)
  • आईआईएस ऐप पूल
  • के लिए एक एडी खाता बनाया गया है
  • ई खाते की स्थापना, (Kerberos के लिए) के प्रतिनिधिमंडल की अनुमति देते हैं, सच

करने के लिए सेट मैं 8080 पर Brian Booth's debug site का उपयोग कर रहा है और यह साइट Kerberos प्रतिनिधि मंडल के लिए सभी आवश्यकताओं से गुजरता है। डीबग आईआईएस साइट पर अज्ञात प्रमाणीकरण बंद है, और एकीकृत विंडोज प्रमाणीकरण पर है।

मैंने डब्ल्यूसीएफ सेवा की मेजबानी करने वाली साइट पर इन सेटिंग्स को प्रतिबिंबित किया है।

वेब सेवा - वेब कॉन्फ़िग (मूल)

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WsHttpBindingConfig"> 
       <security> 
        <message negotiateServiceCredential="true" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="Service">  
      <endpoint address="" 
       binding="wsHttpBinding" 
       bindingConfiguration="WsHttpBindingConfig" 
       contract="IService">  
       <identity>  
        <servicePrincipalName value="http/myserver" />  
        <dns value="" />  
       </identity>  
      </endpoint>  
      <endpoint address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange" />  
     </service>  
    </services>  
    <behaviors>  
     <serviceBehaviors>  
      <behavior name="ServiceBehavior">  
       <serviceMetadata httpGetEnabled="true"/>  
       <serviceDebug includeExceptionDetailInFaults="true"/>  
       <serviceAuthorization 
        impersonateCallerForAllOperations="true" />  
      </behavior>  
     </serviceBehaviors>  
    </behaviors>  
</system.serviceModel> 

वेब सेवा - वेब विधि

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 
public string GetCurrentUserName() 
{ 
    string name = WindowsIdentity.GetCurrent().Name; 
    return name; 
} 

क्लाइंट अनुप्रयोग - ऐप कॉन्फ़िग

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IService" 
       ... /> 
       ... 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" 
         proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="Windows" 
         negotiateServiceCredential="true" 
         algorithmSuite="Default" 
         establishSecurityContext="true" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://myserver/Service.svc" 
      binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IService" 
      contract="KerberosService.IService" 
      name="WSHttpBinding_IService"> 
      <identity> 
       <servicePrincipalName value="http/myserver" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

अनुप्रयोग त्रुटि

निम्न त्रुटि तब होती है जब अपने परीक्षण आवेदन, एक WinForms अनुप्रयोग, वेब विधि कॉल करने की कोशिश करता है:

"HTTP अनुरोध ग्राहक प्रमाणीकरण योजना 'बेनामी' के साथ अनधिकृत है । प्रमाणीकरण हैडर सर्वर से प्राप्त था 'निगोशिएट, NTLM' "

ईवेंट लॉग

निम्न त्रुटि ईवेंट लॉग में है:।

अपवाद: सिस्टम .ServiceModel.ServiceActivationException: सेवा '/Service.svc' संकलन के दौरान अपवाद के कारण सक्रिय नहीं हो सकता है tion। अपवाद संदेश है: इस सेवा के लिए सुरक्षा सेटिंग्स को 'बेनामी' प्रमाणीकरण की आवश्यकता है लेकिन यह आईआईएस एप्लिकेशन के लिए सक्षम नहीं है जो इस सेवा को होस्ट करता है।

जो मुझे समझ में नहीं आता है। इस सेवा का पूरा बिंदु अज्ञात प्रमाणीकरण की अनुमति नहीं देना है, प्रत्येक उपयोगकर्ता/अनुरोध कोर्बेरोज टिकटों का उपयोग करके प्रमाणित किया जाना चाहिए, फिर उन्हें अन्य मशीनों के माध्यम से पास करना होगा।

मैं केर्बेरो प्रमाणीकरण और प्रतिनिधिमंडल के लिए इस डब्ल्यूसीएफ सेवा को कैसे कॉन्फ़िगर करना चाहिए?

संशोधन 1

this SO question पढ़ने के बाद मैं मेटाडाटा endpoint हटा दिया। इसने इस मुद्दे को हल नहीं किया है।

संशोधन 2

अधिक शोध करने के बाद मैं basicHttpBinding को wsHttpBinding बदलने के लिए सुझाव दे कुछ पोस्ट नहीं मिला। Web.config के उस हिस्से में संशोधन को नीचे शामिल किया गया है, और उस बाध्यकारी के संदर्भ में सेवा समापन बिंदु अद्यतन किया गया है।

वेब सेवा - वेब कॉन्फ़िग (संशोधित)

<basicHttpBinding> 
    <binding name="basicBindingConfig"> 
     <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" 
       proxyCredentialType="Windows" 
       realm="" /> 
     </security> 
    </binding> 
</basicHttpBinding> 

क्लाइंट अनुप्रयोग - ऐप कॉन्फ़िग (संशोधित)

<!-- ... --> 
<security mode="TransportCredentialOnly"> 
    <transport clientCredentialType="Windows" 
     proxyCredentialType="Windows" 
     realm="" /> 
    <message clientCredentialType="UserName" 
     algorithmSuite="Default" /> 
</security> 
<!-- ... --> 

त्रुटि (संशोधित)

वर्तमान त्रुटि दिखती है जैसे इसमें एक केर्बेरोस होता है ntication हेडर।

HTTP अनुरोध 'निगोशिएट' ग्राहक प्रमाणीकरण योजना के साथ अनधिकृत है। प्रमाणीकरण हैडर सर्वर से प्राप्त था 'निगोशिएट SOMEHUGESCARYKEYHERE

+1

नोट, मैंने कल कुछ इसी तरह पोस्ट किया और हटा दिया, इस पोस्ट में अधिक शोध के आधार पर संशोधन शामिल हैं और पढ़ने के लिए क्लीनर होना चाहिए। – blu

+1

मैंने marc_s की प्रतिक्रिया के आधार पर संशोधित ऐप कॉन्फ़िगरेशन जोड़ा। – blu

उत्तर

3

कुछ है कि मैं नोटिस: क्लाइंट और सर्वर config सुरक्षा मोड पर सहमत नहीं है।

मूल अनुभाग में, आपके पास web.config में <security>..... है (मोड = "संदेश" छोड़ा गया है, और <security mode="Message"> क्लाइंट पक्ष पर है।

आपके संपादन के बाद, ऐसा लगता है कि क्लाइंट पक्ष अपरिवर्तित है, लेकिन सर्वर (web.config) में अब <security mode="TransportCredentialOnly"> है।

सवाल वास्तव में है: क्या आप गारंटी दे सकते हैं कि क्लाइंट और सर्वर के बीच केवल एक नेटवर्क पैर होने जा रहा है? अर्थात। क्या यह कॉर्पोरेट फ़ायरवॉल के पीछे है? उस स्थिति में, मैं दोनों सिरों पर <security mode="Transport"> के साथ नेट टीसीपी बाध्यकारी की सिफारिश करता हूं।

यदि ऐसा नहीं है, तो आप या तो wsHttp बाइंडिंग (जो अधिक सुरक्षा और विश्वसनीयता सुविधाओं का समर्थन करता है, लेकिन धीमा और "भारी") या मूल Http बाइंडिंग के साथ ठीक है। उस स्थिति में, आपको दोनों सिरों पर <security mode="Message"> का उपयोग करना होगा, और प्रमाण पत्र के साथ सेवा प्रमाणित करना होगा (ताकि सेवा और ग्राहक के पास एक सामान्य "गुप्त" हो जो एन्क्रिप्शन के लिए उपयोग किया जाए)।

मैं शुरुआत के लिए प्रतिरूपण भागों को छोड़ने की कोशिश करता हूं और सेवा और क्लाइंट के बीच बुनियादी संचार और पारस्परिक प्रमाणीकरण प्राप्त करता हूं और पहले चल रहा हूं - एक बार यह जगह हो जाने पर, आप प्रतिरूपण बिट्स जोड़ना शुरू कर सकते हैं, और आप हमेशा एक ज्ञात विन्यास पर वापस आ सकते हैं जो काम करता है।

डेविड Sackstein है एक great series of blog posts पाँच सुरक्षा परिदृश्यों है कि उद्योग गुरु युवल लोवी की पहचान की है समझा (अपने Programming WCF पुस्तक में - WCF बाइबिल) सबसे आम और सबसे उपयोगी के रूप में - क्रम में मापदंडों के संभव संयोजनों की संख्या को सीमित करने के लिए आप ट्विक करना चाहते हैं। उनमें से एक एक "इंटरनेट" परिदृश्य है जो शायद आपकी सेवा का सामना कर रहा है, तो शायद यहां लागू होगा।

मार्क

+1

उत्तर के लिए धन्यवाद। मैंने अद्यतन क्लाइंट कोड शामिल नहीं किया था, मुझे लगा कि सवाल के रूप में पर्याप्त अव्यवस्था है। मैं आपके द्वारा प्रदान की गई जानकारी पर जाउंगा, धन्यवाद। – blu

+1

"प्रमाण पत्र के साथ सेवा प्रमाणित करें", यह कुछ ऐसा है जो यहां से बचने की कोशिश कर रहा है। हम उपयोगकर्ताओं को प्रमाणीकृत करने और एसपी और एसक्यूएल जैसे बैक-एंड मशीनों के माध्यम से सभी तरह से प्रतिनिधि के लिए सीधे केर्बेरोज टिकट का उपयोग करने की उम्मीद कर रहे थे। – blu

7

मेरे लिए मौजूदा सेटअप करता है काम:

सर्वर पर:

<system.serviceModel> 
    <bindings> 
    <wsHttpBinding> 
     <binding name="wsHttpBindingConf" useDefaultWebProxy="true"/> 
    </wsHttpBinding> 
    </bindings> 

    <services> 
    <service behaviorConfiguration="returnFaults" name="Epze.BusinessLayer.ZeitManager"> 
     <endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConf" contract="Epze.Contract.IZeitManager"/> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 

    <behaviors> 
    <serviceBehaviors> 
     <behavior name="returnFaults"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <serviceAuthorization impersonateCallerForAllOperations="true"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

सेट WCF के लिए सभी तरीकों पर निम्न विशेषता:

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 

ग्राहक पर:

<system.serviceModel> 
    <bindings> 
    <wsHttpBinding> 
     <binding name="WSHttpBinding_IZeitManager" 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="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/> 
      </security> 
     </binding> 
    </wsHttpBinding> 
    </bindings> 

    <behaviors> 
    <endpointBehaviors> 
     <behavior name="Delegation"> 
     <clientCredentials> 
      <windows allowedImpersonationLevel="Delegation" /> 
     </clientCredentials> 
     </behavior> 
    </endpointBehaviors> 
    </behaviors>   

    <client> 
    <endpoint address="http://server.mydomain.net/ePZEsvc/ZeitManager.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IZeitManager" 
       contract="External.Epze.IZeitManager" name="WSHttpBinding_IZeitManager" behaviorConfiguration="Delegation"> 
     <identity> 
      <servicePrincipalName value="HOST/localhost"/> 
     </identity>      
    </endpoint> 
    </client> 
</system.serviceModel> 

HTH, स्वेन

+1

प्रमाणीकरण विधियों के लिए आपकी आईआईएस सेटिंग्स के बारे में क्या? क्या अनाम प्रवेश बंद है? – Jonathan

+1

मेरे पास विंडोज प्रमाणीकरण और अनाम पहुंच सक्षम है। लेकिन आपको अपनी सेवा के लिए मैक्स (IMetadataExchange) एंडपॉइंट जोड़ते समय केवल बेनामी की आवश्यकता होगी। –

1

आप अपने प्रारंभिक विन्यास कोशिश करते हैं और एक ही समय का कारण अज्ञात और खिड़कियों प्रमाणीकरण होना करने के लिए है जब आप का उपयोग कर रहे wsHttpBinding डिफ़ॉल्ट सुरक्षा संदेश सुरक्षा है आईआईएस स्थापित करने के लिए यह सुनिश्चित करना चाहिये और जब तक आप https नहीं करना चाहते हैं तब तक कोई परिवहन सुरक्षा परिभाषित नहीं होती है। एसओ क्लियर का कहना है कि इसे आईआईएस पर अज्ञात प्रमाणीकरण की आवश्यकता है।

2

आपको अपने क्लाइंट कॉन्फ़िगरेशन में एक व्यवहार कॉन्फ़िगरेशन निर्दिष्ट करने की आवश्यकता है। SVCUtil ऑटो उत्पन्न नहीं करता है। इसने मेरे मुद्दे को हल किया और अब मैं सफलतापूर्वक केर्बेरोज का उपयोग कर रहा हूं। हालांकि यह एक मिशन था!

<client>   
    <endpoint address="..."    
    binding="customBinding" bindingConfiguration="..."    
    contract="..." name="..." behaviorConfiguration="ImpersonationBehavior" />     
    </client>   
    <behaviors> 
     <endpointBehaviors>    
     <behavior name="ImpersonationBehavior">    
       <clientCredentials>     
       <windows allowedImpersonationLevel="Impersonation"/>      </clientCredentials>    
    </behavior>      
    </endpointBehaviors>     
    </behaviors> 
संबंधित मुद्दे