WCF through Windows Service - Client Authentication

I am WCF / Security Newb. I created a WCF service that is hosted through a Windows service. The WCF service captures data from a third-party data source that is protected through Windows authentication. I need:

  • Transfer client privileges through the Windows service, through the WCF service and to a third-party data source or ...

  • Limit who can call the Windows service / WCF service for members of a specific AD group.

Any suggestions on how I can accomplish any of these tasks?

+3
source share
1 answer

Is this in a firewall scenario inside the network / behind?

, netTcp ( ) Windows. Windows WCF.

, - , :

[PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]
[PrincipalPermission(SecurityAction.Demand, Name = "JohnDoe")]
public void YourSensitiveMethod();

WindowsIdentity , :

if(ServiceSecurityContext.Current.WindowsIdentity != null)
{
    WindowsPrincipal principal = new WindowsPrincipal(ServiceSecurityContext.Current.WindowsIdentity);
    if(!principal.IsInRole("Administrators")
    { 
        return; // or throw a FaultEXception or something
    } 
}

?

UPDATE: , WCF , WCF Codeplex. ( !) .

netTcpBinding Windows :

<bindings>
  <netTcpBinding>
    <binding name="SecuredByWindows">
      <security mode="Transport">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </netTcpBinding>
</bindings>
+5

Source: https://habr.com/ru/post/1740584/


All Articles