Hi, in the current version:
|
['nbf', $this->maxAge - $this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'], |
That line should be:
['nbf', -$this->leeway, static::ERROR_TOKEN_NOT_NOW, 'Not now'],
When checking the nbf ("not before") time, then the "max age" value is not relevant.
Let's see an example:
- Current time = 2020-10-08 12:00:00
- Max age = 3 hours = 10800 sec
- nbf = 2020-10-08 11:00:00 (will be valid after this time)
- leeway = 5 sec (allow max 5 sec misalignment of server clocks)
Then the current code would say:
- The token fails the
nbf check because:
- reference value = 2020-10-08 11:00:00 + 3 hours - 5 sec = 2020-10-08 13:59:55
- And the current time still hasn't reached this value yet.
But it should only subtract the leeway, and leave the irrelevant "max age" out of this:
- The
nbf check is successful, because:
- reference value = 2020-10-08 11:00:00 - 5 sec = 2020-10-08 10:59:55
- And the current time is greater than this value.
Hi, in the current version:
php-jwt/src/ValidatesJWT.php
Line 89 in 926ef39
That line should be:
When checking the
nbf("not before") time, then the "max age" value is not relevant.Let's see an example:
Then the current code would say:
nbfcheck because:But it should only subtract the leeway, and leave the irrelevant "max age" out of this:
nbfcheck is successful, because: