Friday, August 07, 2009

Geneva framework and WCF service to WCF service identity delegation

In order to use credentials from WCF service to call method on other WCF service that also use authentication from Geneva Framework STS you can use code like following:

var principal = Thread.CurrentPrincipal as IClaimsPrincipal;
var callerTokens = principal.GetBootstrapTokens();

using (var serviceFactory = new ChannelFactory("WSFederationHttpBinding_IMyApi"))
{
serviceFactory.ConfigureChannelFactory();

if (callerTokens.Count > 0)
{
var service = serviceFactory.CreateChannelActingAs(callerTokens[0]);
service.SomeMethod();
}
}

No comments: