I'm building a stateless RESTful server backend in Java, that will be used by an AngularJS frontend. Since it should be stateless, I don't create sessions but generate access tokens, more precisely JSON web tokens, the client has to present on every request.
The tokens contain an "expires" field which acts as an absolute expiration date. However, I would like to have an additional expiration on user inactivity. So I would define the access token to be valid as long as 24 hours if the user is active once every 30 minutes.
I could implement this by writing something to the database on every request and verify the time between requests, but this seems a lot of work for something that was working out of the box when using application server's session management.
To be 100% stateless on server side you need to push state logic to the client. The solution is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With