开发者

Set username credential for a new channel without creating a new factory

开发者 https://www.devze.com 2022-12-26 12:45 出处:网络
I have a backend service and front-end services. They communicate via the trusted subsystem pattern. I want to transfer a username from the frontend to the backend and do this via username credentials

I have a backend service and front-end services. They communicate via the trusted subsystem pattern. I want to transfer a username from the frontend to the backend and do this via username credentials as found here:

http://msdn.microsoft.com/en-us/library/ms730288.aspx

This does not work in our scenerio where the front-end builds a backend service channel factory via:

channelFactory = new ChannelFactory<IBackEndService>(.....);

Creating a new channel is done via die channel factory. I can only set the credentials one time after that I get an exception that the username object is read-only.

开发者_运维百科channelFactory.Credentials.Username.Username = "myCoolFrontendUser";
var channel = channelFactory.CreateChannel();

Is there a way to create the channel factory only one time as this is expensive to create and then specify username credential when creating a channel?


I found out that this is not possible. I know add a custom header value to each call that identifies the user. You need to do this as you do not want to create a factory for each user that could hit your front-end. Besides that, creating factories is expensive.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号