Using WIF and a Passive STS is cool, but it’s even cooler when your Passive STS is in a different machine.
Now that we have Federation SignIn and a Passive STS that lives in a Different box and all out web apps rely on that external STS… How can I sign out?
In my case I tried everything and of course, it worked in my machine. Then it got deployed and the user didn’t get signed out because the browser didn’t expire the WIF token.
I executed all this and custom code to make the cookies expire but there was one left, the one created by the STS.
FederatedAuthentication.SessionAuthenticationModule.SignOut(); FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie(); FederatedAuthentication.WSFederationAuthenticationModule.SignOut(false); FormsAuthentication.SignOut();
Bloody cookie, die!!! But nothing. The browser wouldn’t expire it and then it all made sense, I can’t make expire cookies that I haven’t created myself. So I thought that there would be a solution to this and I run all this without any luck. I checked the WIF doco, I Goggled it with Bing and nothing.
Finally I found a reference to something and of course NO SAMPLES (Isn’t WIF wonderfull!!!)
The solution is using the FederatedSignOut method that redirects to the STS, this one signs you out and redirects the browser to the page that you wanted to go to let the user know that he’s out.
WSFederationAuthenticationModule authModule = FederatedAuthentication.WSFederationAuthenticationModule; string signoutUrl = (WSFederationAuthenticationModule.GetFederationPassiveSignOutUrl(authModule.Issuer, authModule.Realm, null)); WSFederationAuthenticationModule.FederatedSignOut(new Uri(authModule.Issuer), new Uri(authModule.Realm + "LoggedOut.html"));
It’s up to you to find out how to solve the new issue, the redirection to LoggedOut.html sends you back to the Login page in the STS because you where logged out (this is good fun if you use Windows Authentication because you get logged in again without knowing it.
The second catch is… once you are in the LoggedOut.html page, press the back button in the browser 🙂