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

你好,为什么refreshtoken获取新token的代码中,新accesstoken的有效期加上了refresh_token的有效期? #4

Closed
woann opened this issue May 5, 2022 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@woann
Copy link

woann commented May 5, 2022

image

@woann
Copy link
Author

woann commented May 5, 2022

新access_token不应该也按照配置文件的有效期生成吗?为什么这里要加上$tokenPayload['exp']

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

没过期也可以刷新的,例如:学员需要考试,在考试之前需要强制刷新(访问令牌并没有过期)获取访问令牌,避免在考试过程中令牌失效

@woann
Copy link
Author

woann commented May 5, 2022

我测试的结果是,假如access_token有效期是20秒,过期后,我通过refreshtoken刷新得到的新access_token有效期不是20秒,你可以测试下看看

@woann
Copy link
Author

woann commented May 5, 2022

image
这样改了才正常

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

不是20秒,而是 20 + 60 秒是吗?

@woann
Copy link
Author

woann commented May 5, 2022

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

那是因为配置项有

// 时钟偏差冗余时间,单位秒。建议这个余地应该不大于几分钟。
'leeway' => 60,

你把这个设置成 0,就可以了

@woann
Copy link
Author

woann commented May 5, 2022

不是的,这个参数我测试的时候已经改为0了。

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

#4 (comment) 你反馈的这个问题确实是存在的,在常驻内存框架下,令牌签发时间iat 并不是当前的时间戳,而是初始化的时间戳。之前一直是在fpm下使用,没有这个问题

@woann
Copy link
Author

woann commented May 5, 2022

通过refresh_token刷新获得的新access_token,有效期貌似是access_exp + refresh_exp的总和,刚刚试了下access_token有效期设置为20秒,refresh_exp有效期为1小时,现在已经过去了接近十分钟,新的access_token一直有效

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

嗯!就是令牌签发时间iat 这个问题

@woann
Copy link
Author

woann commented May 5, 2022

等你搞好我再update😋

@Tinywan
Copy link
Owner

Tinywan commented May 5, 2022

v1.2.5 已经按照你的修复,感谢反馈

@woann
Copy link
Author

woann commented May 5, 2022

ok,已更新

@woann woann closed this as completed May 5, 2022
@Tinywan Tinywan added the bug Something isn't working label May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants