-
Notifications
You must be signed in to change notification settings - Fork 19
Description
The Problem:
I've noticed that the JWT generated in auth/__init__.py#L31 does not have an expiration date set. In my opinion, this is not a good practice because JWT tokens that never expire pose a security risk. If such a token is lost or exposed, it cannot be revoked server-side, potentially leading to permanent unauthorized access.
The Proposed Solution:
According to RFC 7519, the "exp" claim can be used to specify the token's lifetime. I suggest setting an expiration time to mitigate this risk. Since there is no refresh-token mechanism in place yet, we should choose a balanced expiration time - not too short to disrupt user experience, but not too long for security reasons. I recommend starting with an 8-hour validity period.
Suggested Changes:
- Set the
"exp"claim when generating the JWT, with a default lifespan of 8 hours. - Validate the expiration date when decoding the JWT to ensure expired tokens are rejected.
Would love to hear any thoughts or alternative suggestions!