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

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

What could be the reason?

+5
source share
1 answer

If I am not mistaken, there are different ways to get a claim to WCF.

Thread.CurrentPrincipal . It is simple and convenient to use, but in the configuration you need to set some parameters that are most ignored.

<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 configuration is needed, but I think you can get it directly from the called method.

OperationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets - Create a custom authorization manager for the service and you need to add configuration to it.

Please note that I used the Windows Identity Foundation (WIF).

+3
source

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


All Articles