Invalidate HTTPSession when the login-token expirates | Community
Skip to main content
August 28, 2021
Solved

Invalidate HTTPSession when the login-token expirates

  • August 28, 2021
  • 2 replies
  • 705 views

Hi,

 

We are storing some sensitive user information in the HTTPSession, and we would like to clear them when the login token expires. 

 

We implemented AuthenticationHandler, and used its dropCredentials() method to invalidate the HTTPSession. But this only works when user clicks logout button explicitly. However, we also want to invalidate the HTTPSession whenever the login token expires. Is there any way event that is emitted whenever the login token expires, or any specific filter to implement invalidate the HTTPSession on token expiration. 

 

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Asutosh_Jena_

Hi @ansrk 

 

You can use the expiration time of your HTTPSession from org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl using "tokenExpiration" field. When the expiration time is reached, login token along with HTTPSession cookie both will be expired at the same time.

 

 

Thanks!

2 replies

arunpatidar
Community Advisor
Community Advisor
August 29, 2021

Hi,

You can create a session-check service, which will basically be checking session in some interval e.g. every 5 min via ajax call. if session is invliad, you can clear the data and perform logout as well.

Arun Patidar
Asutosh_Jena_
Community Advisor
Asutosh_Jena_Community AdvisorAccepted solution
Community Advisor
August 30, 2021

Hi @ansrk 

 

You can use the expiration time of your HTTPSession from org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl using "tokenExpiration" field. When the expiration time is reached, login token along with HTTPSession cookie both will be expired at the same time.

 

 

Thanks!