Admir Tuzović
Admir Tuzović

Reputation: 11177

Add SecurityTokenHandler to WCF programmatically

I'm implementing custom UserNameSecurityTokenHandler (http://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.usernamesecuritytokenhandler.aspx) and I plan to use it with my WCF service.

I have no issues registering it within web.config and it works flawlessly.

However due to requirements of the client, I'm supposed to move initialization of handler from Web.Config to code.

I've been looking for a way to implement UserNameSecurityTokenHandler somehow as IServiceBehavior, however without much success.

a) Is it doable at all?

b) How?

c) Why not?

Upvotes: 0

Views: 1246

Answers (1)

leastprivilege
leastprivilege

Reputation: 18482

See here http://leastprivilege.com/2012/07/16/wcf-and-identity-in-net-4-5-usernamepassword-authentication/

I added the token handler at service host creation time.

Upvotes: 2

Related Questions