2014-03-25 2 views
0

ADFS를 사용하여 WCF 서비스에 클레임 기반 보안을 추가하려고합니다. 난 성공적으로 웹 응용 프로그램 (수동 연합)에 대한 일을했지만, 주제에 대한 문서의 부족으로 인해 붙어있어.AD FS로 보안 WCF 서비스를 만드는 방법

Web.Config 파일을 사용하여 작업 해봤지만 ... 한 가지 문제에서 다음 문제로가는 것 같습니다. 클라이언트 측 web.config의 보안 부분은 다음과 같습니다.

<system.serviceModel> 
     <behaviors> 
     <endpointBehaviors> 
      <behavior> 
      <clientCredentials> 
       <serviceCertificate> 
       <authentication certificateValidationMode="None"/> 
       </serviceCertificate> 
      </clientCredentials> 
      </behavior> 
    </endpointBehaviors> 
     </behaviors> 
     <bindings> 
      <ws2007FederationHttpBinding> 
       <binding name="WS2007FederationHttpBinding_IService1"> 
        <security mode="Message"> 
         <message> 
          <issuer address="https://myIssuer/adfs/services/trust/13/windows" binding="basicHttpsBinding" /> 
          <issuerMetadata address="https://myIssuer/adfs/services/trust/mex" /> 
          <tokenRequestParameters> 
           <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512"> 
            <trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey</trust:KeyType> 
            <trust:KeySize xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">256</trust:KeySize> 
            <trust:KeyWrapAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p</trust:KeyWrapAlgorithm> 
            <trust:EncryptWith xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptWith> 
            <trust:SignWith xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2000/09/xmldsig#hmac-sha1</trust:SignWith> 
            <trust:CanonicalizationAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm> 
            <trust:EncryptionAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm> 
           </trust:SecondaryParameters> 
          </tokenRequestParameters> 
         </message> 
        </security> 
       </binding> 
      </ws2007FederationHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost/Services/Service1.svc" 
       binding="ws2007FederationHttpBinding" bindingConfiguration="WS2007FederationHttpBinding_IService1" 
       contract="ServiceRef.XISecurity.IService1" name="WS2007FederationHttpBinding_IService1" /> 
     </client> 
    </system.serviceModel> 

올바른 바인딩 유형 또는 엔드 포인트를 사용하고 있는지 확실하지 않습니다. 나는 다음과 같은 코드를 실행하면 :

버전 주소 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none를)'지원되지 않습니다

 Service1Client obj = new Service1Client(); 
    string str = obj.GetData(5); 

을 나는 다음과 같은 예외를 얻을. 그 내 Web.config의 파일을 설정하는 방법에 대한 단계 튜토리얼에 의해 좋은 단계가있다 :

여기

<configuration> 
    <configSections> 
    <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
    </configSections> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    <add key="ida:FederationMetadataLocation" value="https://myIssuer/FederationMetadata/2007-06/FederationMetadata.xml" /> 
    <add key="ida:ProviderSelection" value="productionSTS" /> 
    </appSettings> 
    <location path="FederationMetadata"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
      <serviceCredentials useIdentityConfiguration="true"> 
      <!--Certificate added by Identity and Access Tool for Visual Studio.--> 
      <serviceCertificate findValue="CN=localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName" /> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add scheme="http" binding="ws2007FederationHttpBinding" /> 
     <!--<add binding="basicHttpsBinding" scheme="https" />--> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    <bindings> 
     <ws2007FederationHttpBinding> 
     <binding name=""> 
      <security mode="Message"> 
      <message> 
       <issuerMetadata address="https://myIssuer/adfs/services/trust/mex" /> 
      </message> 
      </security> 
     </binding> 
     </ws2007FederationHttpBinding> 
    </bindings> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true" /> 
    </system.webServer> 
    <system.identityModel> 
    <identityConfiguration> 
     <audienceUris> 
     <add value="http://localhost:2017/Service1.svc" /> 
     </audienceUris> 
     <issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"> 
     <authority name="http://myIssuer/adfs/services/trust"> 
      <keys> 
      <add thumbprint="7502424014D0A1BD87A5DEEF0D1EB13390101F07" /> 
      </keys> 
      <validIssuers> 
      <add name="http://myIssuer/adfs/services/trust" /> 
      </validIssuers> 
     </authority> 
     </issuerNameRegistry> 
     <!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.--> 
     <certificateValidation certificateValidationMode="None" /> 
    </identityConfiguration> 
    </system.identityModel> 
</configuration> 

나의 첫번째 질문은 서버 측에 내 Web.config의이야? 이상적으로 .NET 4.5와 하나?

두 번째 질문 : 저는 실제로 ADFS 종단점 또는 바인딩을 사용하는 것에 대해 혼란스러워합니다. 여기에 현재 설정되어 있습니다.

<issuer address="https://myIssuer/adfs/services/trust/13/windows" binding="basicHttpsBinding" /> 

도움을 주시면 대단히 감사하겠습니다. 감사합니다

답변

0

두 번째 질문에 대한 대답으로 끝점에 대한 정보를 http://technet.microsoft.com/en-us/library/adfs2-help-endpoints(WS.10).aspx에서 찾을 수 있습니다. 끝점은 기본적으로 ADFS 서버와 통신하는 데 사용할 수있는 주소를 지정합니다. 엔드 포인트의 유형은 인증서 또는 사용자 이름 제공 여부와 같은 요구 사항에 대해서도 알려줍니다.
끝점과 WIF 바인딩 간의 매핑은 http://blogs.msdn.com/b/alikl/archive/2011/10/01/how-to-use-ad-fs-endpoints-when-developing-claims-aware-wcf-services-using-wif.aspx입니다. 이것은 구성 파일 대신 코드를 사용하여 엔드 포인트와 통신 할 때 유용했습니다.

관련 문제