Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF / WIF - Should I find claims in the backend?

I have an ASP.NET application calling a WCF service. In ASP.NET application, I make a call to ADFS to perform authentication and I can see all the claims of the user in CurrentPrincipal. Then I perform the call of the WCF service (wsHttpBinding), but the list of claims is empty.

What could be the reason?

like image 601
bjnr Avatar asked Oct 19 '22 22:10

bjnr


1 Answers

If I'am not mistake there different ways to get Claims in WCF.

Thread.CurrentPrincipal - Simple and easy to used but need some setting in your configuration, which is most neglected.

<behaviors>
  <serviceBehaviors>
    <behavior name="Test.Services.WifBehavior">
      <serviceCredentials useIdentityConfiguration="true" />
        <!---Set principalPermissionMode to always to pass the ClaimsIdentity info to the Thread.CurrentPrincipal-->
      <serviceAuthorization principalPermissionMode="Always"/>
    </behavior>
  <serviceBehaviors>
</behaviors>

OperationContext.Current.ClaimsPrincipal - I can't remember if this needs some configuration but I guess you can get it directly from method invoked.

OperationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets - Create a Custom Authorization Manager for a Service and need to add in config.

Note that I used Windows Identity Foundation (WIF).

like image 134
jtabuloc Avatar answered Oct 21 '22 21:10

jtabuloc