Skip to content
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

Leeway not applying to self #143

Closed
jmcmurdo91 opened this issue Apr 5, 2017 · 1 comment
Closed

Leeway not applying to self #143

jmcmurdo91 opened this issue Apr 5, 2017 · 1 comment

Comments

@jmcmurdo91
Copy link

I am using JWT.php from the Google PHP API and when I first authenticate using a Google Account JWT.php throws a Fatal Error. If I refresh the page a few seconds later the error goes away.

On line 112 of JWT.php I alter the error message to:

if (isset($payload->iat) && $payload->iat > (time() + self::$leeway)) { throw new BeforeValidException( 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat) . 'The payload output is:' . $payload->iat . ' but time is ' . time() ); }

I find from the error message that the iat property of $payload is 4 seconds slower than time(). No problem, I change the following in line 30:

public static $leeway = 5;

This still doesn't make a difference.

The only way to resolve the problem is to manually enter the leeway into the calculation on line 111:

if (isset($payload->iat) && $payload->iat > (time() + self::$leeway + 5))

It would appear that time() + self::$leeway is just time()?

Thanks

@jmcmurdo91
Copy link
Author

Outdated version, apologies.

Have noticed Pull #88 which should have resolved this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant