I am trying to figure out how to implement a single sign-out function using Json Web Tokens.
Say we have:
example1.comexample2.comauthserver.com
When a user must authenticate to example1.com , it is redirected to authserver.com , which verifies the user's credentials, creates a signed JWT token, and redirects the user back to example1.com using this token. example1.com then set a cookie (or LocalStorage key), and the user will authenticate with example1.com until the token expires. Authserver.com is no longer required to authenticate a user.
The user then moves on to example2.com , which is involved in the single sign-on architecture. The user must also be authenticated, so example2.com also redirects the user to authserver.com , which recognizes the user (using the cookie set for the first time), creates a new JWT token and automatically redirects the user to example2.com . example2.com then set a cookie (or LocalStorage key), and the user will be authenticated with example2.com until the token example2.com . Authserver.com is no longer required to authenticate a user.
Now, how can the "exit" function be implemented?
If the user logs off example1.com , the JWT token on example1.com is deleted and the user no longer needs to authenticate. But as soon as he tries to get to the protected zone, example1.com redirect him to authserver.com , the user will be recognized and automatically logged in again ... Even if he just logs out!
Quetion 1) So, I think that when the user logs out of example1.com , you need to make an call to authserver.com to delete the cookie set by authserver.com so that the user wonβt log in automatically?
Quetion 2) If so, what about example2.com ? Should the user still be authenticated? If not, what is the proposed stream, so example2.com knows that the JWT token it has for the user is no longer valid?