-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Precision of validation-timestamp #488
Comments
Yes experiencing exactly the same issue when trying to decode Laravel passport tokens. |
Related to #475 which discusses the strict check of I suggest you (1) use the leeway to solve the issue, and (2) make a PR to this repository to either disable the strict |
Talking about precision, for me this raises an:
Because |
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.
php-jwt/src/JWT.php
Line 96 in 4dd1e00
Edit: May also apply to the nbf check - which is often also set to the issuance date
The text was updated successfully, but these errors were encountered: