This commit is contained in:
mkm 2023-11-20 17:20:46 +08:00
parent 9513aceba0
commit b1d1d54187

View File

@ -139,20 +139,20 @@ class JWT
// Check the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
// 取消时间验证
// if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
// throw new BeforeValidException(
// 'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf)
// );
// }
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf)
);
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
// if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
// throw new BeforeValidException(
// 'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->iat)
// );
// }
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->iat)
);
}
// Check if this token has expired.
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {