1

I am able to generate SecurityToken but I am unable to pass it when creating channel.

In .NET Framework 4.8 I could do,

var proxy = factory.CreateChannelWithIssuedToken(securityToken);

But I am unable to find alternative in .Net Core, I looked at decompiled source,

I tried this by creating a poco "FederatedClientCredentialsParameters" but this didn't work either.

var proxy = factory.CreateChannel();
            IClientChannel clientChannel = (IClientChannel) proxy;
            clientChannel.GetProperty<ChannelParameterCollection>().Add(new FederatedClientCredentialsParameters()
            {
                IssuedSecurityToken = token
            });

I have tried looking into setting factory.endpointbehavior but can't find an avenue where I can insert security token. Most answers seems to be around client credential for username and password but not related WS Trust based security token.

2 Answers2

0

At present, core's support for wcf is very limited. In order to use WCF in core, core provides the following packages to support WCF:

enter image description here

The functions provided by these packages are also very limited. Many WCF functions cannot be used in core. You can pass security tokens in the .net framework, but core does not support you to do so.

My suggestion is to use the .net framework, you can also consider using custom binding and custom credentials. For more information about core's support for WCF, please refer to this link:

https://github.com/dotnet/wcf/tree/master/src

Feel free to let me know if the problem persists.

Ding Peng
  • 3,702
  • 1
  • 5
  • 8
0

I ended up creating my custom credential, custom credential token manager & custom token provider.

Then before creating proxy, I configured my custom credential code.

        factory.Endpoint.EndpointBehaviors.Clear();
        factory.Endpoint.EndpointBehaviors.Add(new CustomCredentials()

This allowed my custom credential code to return token at run time and it finally worked!

For detailed implementation see post by Joe at the bottom of following thread, How can I pass a username/password in the header to a SOAP WCF Service