api - JWT (JSON Web Token) automatic prolongation of expiration -



api - JWT (JSON Web Token) automatic prolongation of expiration -

i implement jwt-based authentication our new rest api. since expiration set in token, possible automatically prolong it? don't want users need sign in after every x minutes if actively using application in period. huge ux fail.

but prolonging expiration creates new token (and old 1 still valid until expires). , generating new token after each request sounds silly me. sounds security issue when more 1 token valid @ same time. of course of study invalidate old used 1 using blacklist need store tokens. , 1 of benefits of jwt no storage.

i found how auth0 solved it. utilize not jwt token refresh token: https://docs.auth0.com/refresh-token

but again, implement (without auth0) i'd need store refresh tokens , maintain expiration. real benefit then? why not have 1 token (not jwt) , maintain expiration on server?

are there other options? using jwt not suited scenario?

i work @ auth0 , involved in design of refresh token feature.

it depends on type of application , here our recommended approach.

web applications

a pattern refresh token before expires.

set token expiration 1 week , refresh token every time user open web application , every 1 hour. if user doesn't open application more week, have login 1 time again , acceptable web application ux.

to refresh token api needs new endpoint receives valid, not expired jwt , returns same signed jwt new expiration field. web application store token somewhere.

mobile/native applications

most native applications login 1 time , once.

the thought refresh token never expires , can exchanged valid jwt.

the problem token never expired never means never. do if lose phone? so, needs identificable user somehow , application needs provide way revoke access. decided utilize device's name, e.g. "maryo's ipad". user can go application , revoke access "maryo's ipad".

another approach revoke refresh token on specific events. interesting event changing password.

we believe jwt not useful these utilize cases utilize random generated string , store on our side.

api security rest authentication jwt

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 -