Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Spring WebSession lifecycle tracking #28164

Open
jakshay21 opened this issue Mar 11, 2022 · 1 comment
Open

Support for Spring WebSession lifecycle tracking #28164

jakshay21 opened this issue Mar 11, 2022 · 1 comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@jakshay21
Copy link

jakshay21 commented Mar 11, 2022

TL; DR;

Add support for callbacks for tracking the lifecycle of a WebSession in WebSessionStore.

Foreword

We had a use case to track journey of a WebSession. We wanted to track various aspects of it like when it was created, retrieved, saved, invalidated etc.

Problem

The session expires based on -
  1. maxIdleTime limit reached, default is 30mins
  2. maxSessions limit reached, default is 10000
  3. invalidate was called

We wanted to distinguish the sessions which were removed due to inactivity for 30mins or maxSessions limit reached.
Currently there as no such hooks for any of the methods defined in WebSession interface to track the same.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 11, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Apr 25, 2022

Thanks for the request.

WebSessionManager and related components are pluggable, so this would have to be done independent of the actual implementations, i.e. wrapping the WebSessionStore in WebSessionManager and the WebSession that that returns. This would allow intercepting create and retrieve on WebSessionStore, and save and invalidate on WebSession. I'll turn this into a feature request, but an application could do the same in the mean time.

For maxSessions, that's implementation specific but could be tracked by checking for errors from save.

For maxIdleTime, which is also implementation specific, there isn't any good way to detect that. You can get the map of all sessions and for each check if it is expired but that's not ideal. It might require exposing a WebSession callback that notifies when a session is detected to be expired.

@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 25, 2022
@rstoyanchev rstoyanchev added this to the 6.x Backlog milestone Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants