dongliang1865 2015-11-03 10:21
浏览 101
已采纳

BulletPHP框架和Firebase / JWT - 检查令牌错误

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\wwwoutes\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 
  • 写回答

1条回答 默认 最新

  • douhao2011 2015-11-16 19:32
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况