I'm building a nodejs server with jwt authentication.
At the moment my jwts have a expiration time of 1 month. If the user goes on the loggin page, I check if his request contains a valid jwt, if yes, he don't have to type in his username and password. If he logs out, the jwt gets deleted on the clientside, so the user have to log in next time with his credentials.
What if an attacker listens to the connection (I'm already using ssl) and gets the token. Even if the user logs out and gets a new token on his next session, the attacker can impersonate the user with the old token, as long as it is valid right?
Is it a good idea to store the IAT of the "current" token of the user in the DB and compare it to the IAT of the token in the request to avoid the access of the attacker?
I know, 1 month is quite a long time for a jwt. I also had the idea to generate a new token, every time the client logs in (with exp. time 2 days). But if an attacker gets only 1 valid token, he also gets the new tokens, isn't he?
Do you have any suggestions?
Thanks, Cheers!