PHP-Open-Source-Saver / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
MIT License
729 stars 113 forks source link

Remove issued at from persistant claims #200

Closed ashvin27 closed 1 year ago

ashvin27 commented 1 year ago

Remove iat(IssuedAt) from persistant claim to resolve refresh token expiration issue

Description

Checklist:

mfn commented 1 year ago

why?

jansgescheit commented 1 year ago

Because a token cannot be extended beyond the Refresh TTL. After a refresh, the new token retains the IAT of the very first token. This means that after the expiry of the Refresh TTL of the first generated token, the user still has to log in again.

jansgescheit commented 1 year ago

Because a token cannot be extended beyond the Refresh TTL. After a refresh, the new token retains the IAT of the very first token. This means that after the expiry of the Refresh TTL of the first generated token, the user still has to log in again.

Okay, I see in the JWT specs that this is how the refresh TTL is supposed to work.

specialtactics commented 1 year ago

I don't really follow why it would cause the user to have to log in again, we use this package without that problem.

If you wanted a custom set of claims, you can do that too already?

jansgescheit commented 1 year ago

The problem is, that after the refresh the new token get's the iat from the old token. So if your Refresh TTL is 2 weeks your users have to login again with their credentials. The iat is not rolling with the last refresh but nailed to the very first token.

Example:

TTL = 60min Refresh TTL = 2 weeks

jansgescheit commented 1 year ago

Here is another article which also addresses the problem in this package

Messhias commented 1 year ago

Thanks, everyone for contributing, I've tested here and so far I have got any issues, we're good to merge this update?

Thanks.

Messhias commented 1 year ago

@eschricker what are your thoughts about that?

Messhias commented 1 year ago

@ashvin27 can you do the requested changes in the comments?