I have a spring boot application which logs in by making a call to an IdP
server. I receive a token from this IdP
server when the login is successful.
This token has to be used for all further interactions till the user logs out or the session expires.
I'm trying to use Redis
for session management and all the tutorials do not give a explanation as to how this works.
My question is, how do I use Redis
to store the generated token and how do I retrieve it? Does Redis
handle this internally or does Redis
generate its own token?
Redis is a key-value cache structure. So for your case, you only need to store in redis a pair of key-value for each session as:
On session initiation and a successful login you store the pair. During the session you can access the cache to validate the token. Don't forget to free the cache on logout or session time out.