2014-10-01 1 views
0

Использование средства идентификации и доступа (часть VS 2012) Я могу настроить WCF для использования нашего корпоративного сервера ADFS.Как защитить веб-службу WCF с помощью ADFS в .NET 4.5?

Соответствующие web.config

<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" />--> 
      <serviceCertificate findValue="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" /> 
      </serviceCredentials> 
      <serviceAuthorization principalPermissionMode="Always"/> 
     </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="TransportWithMessageCredential"> 
      <message establishSecurityContext="false"> 
       <issuerMetadata address="https://auth1.domain.com/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="https://wcfurl.domain.com/" /> 
     </audienceUris> 
     <issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"> 
     <authority name="http://auth1.domain.com/adfs/services/trust"> 
      <keys> 
      <add thumbprint="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" /> 
      </keys> 
      <validIssuers> 
      <add name="http://auth1.domain.com/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> 

Однако, когда я ссылаться на эту службу WCF из консольного приложения (Add Service Reference) вызов выполняется непосредственно к службе WCF, не перенаправляются на ADFS для аутентификации как это было бы со стандартным приложением ASP.NET.

Действительно ли мне нужно реализовать вызов adfs по коду? Если да, то подскажите, как это сделать?

+0

Где будет ли ваша служба организована? –

+0

На корпоративном сервере IIS @ https://wcfurl.domain.com/ –

ответ

1

Эрик, в веб-службах аутентификации на основе SAML и в приложении на основе браузера (например, в веб-приложении) используется другой механизм аутентификации. Постарайтесь увидеть пассивным против активной аутентификации, в вашем случае клиент должен вести аутентификации (активный клиент) с использованием WS-Trust, так как нет редиректа в вебе-службе call.Check из этого http://msdn.microsoft.com/en-us/magazine/ee335705.aspx

-Peace

Смежные вопросы