Skip to content

Precision of validation-timestamp #488

Closed
@kronthto

Description

@kronthto

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.

$timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;

Edit: May also apply to the nbf check - which is often also set to the issuance date

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions