auth0 / node-jsonwebtoken

JsonWebToken implementation for node.js http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html
MIT License
17.73k stars 1.23k forks source link

Disallowing Validation of Expired Tokens #959

Open andreseloysv opened 9 months ago

andreseloysv commented 9 months ago

The Problem

The library first validates the signature of tokens before assessing their expiration status. This approach results in unnecessary CPU usage, as it not only validates signatures of expired tokens but also decodes them again using the verify method of node-jws. This double processing of expired but correctly signed tokens is inefficient and could be optimized.

The ideal solution

I would like the jsonwebtoken library to first verify if a token has expired before it checks the signature. This approach would improve efficiency and security by immediately discarding tokens that are no longer valid due to expiration.

Alternative

currently, one might manually check the expiration of the token before passing it to the library, but this adds extra steps and complexity to the authentication process.