views:

945

answers:

8

To implement single sign off, i would like the user to get logged out of application B additionally when ever the user clicks logout on application A. Is it possible to implement this using some form of a POST request to application B? i.e. when the user clicks on logout:

  1. Generate existing POST request to logout of application A
  2. Generate additional POST request to logout of application B as well.
A: 

Yes, how you do it depends on the programming language you are using.

For example under ASP.Net you'd use System.Net.HttpWebRequest within the handling of the Logout event of application A to make a logout request to application B

If you can post what language you're working in I can give a proper example

RobV
Its a J2EE application. Java language
Subramanian
Typically a language I don't work in or know well, someone else will have to produce an example
RobV
A: 

Depending on the implementation of your authentication system, probably you can/need to send the POST using JavaScript instead of from server-side.

Ikhwan
A: 

Without specific information, it's hard to give a specific answer, but as you're refering to POST, I'll assume a browser is involved.

POSTs (without using Javascript or similar) occur when a form is submitted. As the form can have only one action, it can only target one server-side page.

One solution is to simply have Application A forward sign-out credentials to Application B once one action is received, which allows for more opportunities to check returns.

If, however, you're set on POST'ing to different pages, see this tutorial for one iframe-related hack - http://www.codeproject.com/KB/scripting/multiact.aspx

Jon
When application A forwards the request to application B, wont we be showing the logout page of application B? That would mean when user clicks logout on application A, we show him the logout page of application B.
Subramanian
No, you do it solely on the backend, and only send your original logout page to the user. Application A would in effect be acting as the user in interaction with Application B (and return nothing, assuming success - or an "error logging out" if Application failed).
Jon
I tried URLConnection with little success though. Ajax is ruled out since it would be cross-domain.
Subramanian
Did you need cookies or similar? HTTPClient may provide whatever's lacking if so.http://www.innovation.ch/java/HTTPClient/urlcon_vs_httpclient.html
Jon
+1  A: 

The cleanest way to do this is to check if your SSO provider has a single-sign-off feature.

Coding this up and deploying it would make your overall IT solution a bit brittle.

Another suggestion is to take this up with your (Enterprise) architect as SSO is usually an enterprise initiative and point her to (very cogent) arguments in this post : http://lists.danga.com/pipermail/yadis/2005-July/001085.html

Ryan Fernandes
A: 

I think, you can just do it like what OpenId does.

ZA
A: 

If your login session is stored by a cookie, and there are nothing else you need to supply to log out of application B, clearing the cookie in javascript will usually destroy the session and sign the user out.

futureelite7
A: 

I have done exactly what you were suggesting. Simply, since my system "knew" what the partner systems were, I sent a special logout request to each site with a chain of "other sites". The site would log the user out, remove the first site off of the list, and then redirect to its logout URL. This was all done with simple, generic Redirects, rather than POSTs or Javascript.

Obviously, all of the sites were changed to be "in on it". But it worked like a champ.

Will Hartung
A: 

How about making it a cookie based authentication? A same cookie authenticates a user for various applications (in your case 2 different application.) Once a user sign off from one application (app A), invalidates a cookie (by expiry date) so that whenever a user sends a POST request to rest of the application (app B) the request is not processed. A Servlet that traces each POST request to validate the cookie is required for each application.

royalGhost
Got this issue resolved - introduced a token (session creation time) and cached this token within the application. If the request comes through the back button, a check was introduced to see if this token has been cached/archived within the application. If token is archived, user would be re-directed to session timeout page.
Subramanian