WCF Transfer Additional Security Data Through All Service Calls

Client side I need to pass a piece of information (for this example, you can say a line) to each service call that I make. Services use this string (currentRole) along with user / password credentials to retrieve a set of user requirements related to their current role.

The solutions that I have encountered so far are as follows:

1) Change the message headers when they exit the client, and make sure that the message header has a service side.

2) Use user credentials, which from what I understand also require a special security token to save the string.

Are there any other approaches that are missing, for example, just adding this information to an existing token / credential? And are there any pros and cons to the solutions mentioned above?

Thanks.

+3
source share
1 answer

You can also write client-side behavior that would add this header to messages (so you didn't have to think about doing it yourself in your code).

You can implement IClientMessageInspectorand override the method BeforeSendRequest, add a message header. When you add this behavior to each endpoint of your client, it automatically adds this message header to each outgoing message.

CodeProject , -.

+1

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


All Articles