Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding a client that requires both a Basic Authentication UserName credential and another WS-Security UserName credential #5725

Open
Rans4ckeR opened this issue Jan 13, 2025 · 0 comments

Comments

@Rans4ckeR
Copy link
Contributor

We have a setup where a wcf client connects to a mandatory gateway application using Basic Authentication. The request is then forwarded to a third party service which uses WS-Security. Both have 2 different username/password values.

Until now I was only able to make this work by configuring the client to use Basic Authentication and then to add the WS-Security header manually.

Is there a better way to achieve this in (.NET9) code?

I'm using a custom binding which contains the BindingElement created by:

SecurityBindingElement.CreateUserNameOverTransportBindingElement()

The client's Basic Authentication UserName credentials are then set like so:

var clientCredentials = (ClientCredentials)client.Endpoint.EndpointBehaviors[typeof(ClientCredentials)];

clientCredentials.UserName.UserName = username;
clientCredentials.UserName.Password = password;

But then I'm stuck with setting the WS-Security UserName credentials (except when manually adding the header).

Is there a way to specify 2 different UserName credentials? One for Basic Authentication and one for WS-Security?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant