-
Notifications
You must be signed in to change notification settings - Fork 12
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
access_token、refresh_token的原理与实现 #298
Comments
解决使用jwt刷新token带来的问题:https://segmentfault.com/a/1190000013151506 |
Token refresh的实现:https://www.cnblogs.com/wqtmelo/p/8527148.html 在access_token里加入refresh_token标识,给access_token设置短时间的期限(例如一天),给refresh_token设置长时间的期限(例如七天)。当活动用户(拥有access_token)发起request时,在权限验证里,对于requeset的header包含的access_token、refresh_token分别进行验证: 1、access_token没过期,即通过权限验证; 2、access_token过期,refresh_token没过期,则返回权限验证失败,并在返回的response的header中加入标识状态的key,在request方法的catch中通过webException来获取标识的key,获取新的token(包含新的access_token和refresh_token),再次发起请求,并返回给客户端请求结果以及新的token,再在客户端更新公共静态token模型; 3、access_token过期,refresh_token过期即权限验证失败。 |
总结: 前端:前端只接受access_token,如果值存在,则覆盖原理的access_token,没有的话则不做其他操作 后端:
存储:前端存在cookie或者localstorge,后端存数据库或者缓存比如redis |
access_token、refresh_token介绍:https://www.jianshu.com/p/8a0e74b60efe |
发的用户认证token超时刷新策略 :https://segmentfault.com/a/1190000014545422
The text was updated successfully, but these errors were encountered: