How to integrate SAML authentication into WCF web service application

前端 未结 2 1827
情歌与酒
情歌与酒 2021-02-09 04:52

I have a WCF web service application built and tested on IIS7. Regarding authentication I wanted to implement a sql server hosted userd id and password authentication for consum

相关标签:
2条回答
  • 2021-02-09 05:02

    Since 2011, support for Claims-Aware WCF Services has apparently improved with the release of .NET 4.5. I'll copy info from that article in case it ever changes, but as of the time of this answer, the process appeared to be as simple as:

    1. Adding a reference to WIF (Microsoft.IdentityModel.dll) in your WCF Service project. Since this is delivered with .NET 4.5, I do not believe a NuGet package is necessary.

    2. Use the following code sample to create a self-hosted Claims-Aware service:

      var host = new ServiceHost(typeof(ClaimsAwareWebService), new Uri("myUri")); FederatedServiceCredentials.ConfigureServiceHost(host);

      host.Open();

    3. Set your WCF service to use the federatedServiceHostConfiguration Behavior Extension.

    0 讨论(0)
  • 2021-02-09 05:10

    I think SAML 2.0 is not provided by standard WCF. To make it work you must combine WCF with WIF (Windows identity foundation). Here you have very complex example of usage WCF with WIF and claim based authorization. The example uses SAML 1.1 but it is only configuration change to make it work with SAML 2.0.

    Your problem is generally called Federated authentication or Federated identity where user authenticates against STS (service token service) and it receives security token (it can be for example SAML token). Than the client calls real service (RP - relaying party) where it passes its security token. So what are you going to build? If your company policy demands SAML usage they most probably already have STS and you just need to authenticate clients by SAML tokens as mentioned in the article.

    0 讨论(0)
提交回复
热议问题