rest - How to invalidate user session on inactivity in a stateless server? -



rest - How to invalidate user session on inactivity in a stateless server? -

i'm building stateless restful server backend in java, used angularjs frontend. since should stateless, don't create sessions generate access tokens, more exactly json web tokens, client has nowadays on every request.

the tokens contain "expires" field acts absolute expiration date. however, have additional expiration on user inactivity. define access token valid long 24 hours if user active 1 time every 30 minutes.

i implement writing database on every request , verify time between requests, seems lot of work working out of box when using application server's session management.

to 100% stateless on server side need force state logic client. solution is:

issue jwt 2 expiry dates (one session - 30 minutes, sec refresh - 24h) implement getting new token same user previous token (new token has new expiry date session, same refresh) reject requests when whatever expiry date exceeded implement "clever" javascript client able new tokens while user clicking ui; can optimize it, skipping refresh requests when token has more 25 minutes expiration date

rest session stateless json-web-token

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -