The default timestamp uses time() which just has second precision.
Some OAuth-Servers/Providers - like Laravels passport (with thephpleague-server and Carbon2) / lcobucci - issue tokens with microsecond precision in the iat/nbf fields.
If such a token is validated with this lib in standard-configuration the same second (of course after) it is issued, validation will wrongly fail with the Cannot handle token prior to error (without systemclock skew), as $payload->iat > ($timestamp ) e.g. 1676279484.234102 > 1676279484 albeit the time of validation is e.g. 1676279484.7 or 1676279484.4 .
This can be mitigated by setting a $leeway of 1 second of course.
I think however the validation should be enhanced by either rounding or using a microtime()-stamp.
https://github.com/firebase/php-jwt/blob/4dd1e007f22a927ac77da5a3fbb067b42d3bc224/src/JWT.php#L96
Edit: May also apply to the nbf check - which is often also set to the issuance date
The default timestamp uses
time()which just has second precision.Some OAuth-Servers/Providers - like Laravels passport (with thephpleague-server and Carbon2) / lcobucci - issue tokens with microsecond precision in the iat/nbf fields.
If such a token is validated with this lib in standard-configuration the same second (of course after) it is issued, validation will wrongly fail with the
Cannot handle token prior toerror (without systemclock skew), as$payload->iat > ($timestamp )e.g.1676279484.234102 > 1676279484albeit the time of validation is e.g. 1676279484.7 or 1676279484.4 .This can be mitigated by setting a $leeway of 1 second of course.
I think however the validation should be enhanced by either rounding or using a microtime()-stamp.
https://github.com/firebase/php-jwt/blob/4dd1e007f22a927ac77da5a3fbb067b42d3bc224/src/JWT.php#L96
Edit: May also apply to the nbf check - which is often also set to the issuance date