We just have been discussing the login and logout behaviour when using OAuth 2. Let's say we have two webapps A and B using one OAuth provider O (built using the spring-security-oauth2 stack).
When you want to login to A you get redirected to O, enter your credentials, get a session there on O, redirected back to A with an access token and a session is created on A as well.
Now when you want to login to B you get redirected to O, get directly sent back with a token to B because you still have a valid sesison on O and a session is created on B as well (without having to enter your credentials again).
This solves our single sign on problem.
A requirement now is, that when logging out from A or B you are logged out always from both/all apps (single sign off).
Our idea is:
- Enhance the access token with the current session id
- If apps
AorBwant to logout a user, they redirect him to the logout page ofO - If the user gets logged out from
O, all access tokens belonging to the current session onOare removed and the user gets redirected back toAorB - The session on
AorBgets destroyed AandBcheck for the validity of their OAuth access token on each request and destroy their session if the token is not valid any more
Do you think this is a valid use case for OAuth 2? How you would you implement single sign off differently?