简体   繁体   中英

BulletPHP framework and Firebase/JWT - Checking token error

I am developing a REST API with BuletPHP framework. The fact is I have an angular JS app which stores locally the JWT token and sends to the server for checking expiration data. I have generated a token and I want to be rejected, but when I check the response It launches this exception:

exception 'Firebase\JWT\BeforeValidException' with message 'Cannot handle token prior to 2015-11-04T18:40:33+0100' in C:\Server\www\vendor\firebase\php-jwt\src\JWT.php:103 Stack trace: #0 C:\Server\www\routes\user.php(92): Firebase\JWT\JWT::decode('eyJ0eXAiOiJKV1Q...', 'QWRhZ2FsIFNpc3R...', Array) #1 [internal function]: Closure->{closure}(Object(Bullet\Request)) #2 C:\Server\www\vendor\vlucas\bulletphp\src\Bullet\App.php(311): call_user_func(Object(Closure), Object(Bullet\Request)) #3 C:\Server\www\vendor\vlucas\bulletphp\src\Bullet\App.php(195): Bullet\App->_runPath('GET', 'eyJ0eXAiOiJKV1Q...') 

Why I am getting this exception on token decoding function?

This is my token:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6IjAyMjAxNTExNjVkMmVhMDM0MjU4ODdhNzE3YzQzNTA4MWNmYzVkYmIxMzMwNjQwIiwibmFtZSI6InJvb3QiLCJpYXQiOjE0NDY0ODYwMzMsIm5iZiI6MTQ0NjY1ODgzM30.qHMee39xJC9Rgx4AUzJSkBUnK3P5R1BTjL_JA5j_6f5L99U-gzZkB4VM0LWrfIMOBFQWFC9lwlUNFPWnwPUiYQ 

This is happening because the time on your local machine/ local server is slightly slower than the remote server(wherever the token is being generated from) time.

If you modify line 113 of vendor\\firebase\\php-jwt\\src\\JWT.php with the following debug you can see the output:

echo '<br /> payload->iat = '. $payload->iat . '<br />and time() = '.time() . "<br />leeway= ". self::$leeway;

This will output something similar to:

payload->iat = 1447702275  
and time() = 1447702211  
leeway= 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM