处理刷新令牌过期的策略
我正在制作一个 React 应用程序并使用 JWT 进行身份验证。 用户登录后,我会发出一个访问令牌并设置一个名为 jwt 的仅 http cookie,其值为刷新令牌。根据我在网上阅读的一些文章,建议访问令牌的有效期较短,而刷新令牌的有效期较长,因此我将访问令牌的有效期设置为1天,刷新令牌的有效期为25天,(数字不是很相关的)。现在,一旦刷新令牌过期,用户就会自动注销。
现在我正在开发的应用程序是一个数据输入仪表板,我不希望用户在输入大量数据后突然注销,即使这种情况每月发生一次,所以我想知道管理这种情况的行业标准
I am making a react application and using JWT for authentication.
As soon as a user logs in I issue a access token and set a http only cookie named jwt and value is refresh token. As per some articles I have read online it is suggested that access token have a short validity and refresh token have a long validity, so I set validity of access token to be 1 day and refresh token to be 25 days, (numbers are not very relevant). Now as soon as refresh token expires The user is automatically logged out.
Now the app I am developing is a data entry dashboard and I do not want the user to suddenly logout after entering a lot of data even if that happens once a month, so I want to know the industry standard to manage this kind of situation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一种方法可以在没有登录密码对的情况下更新刷新令牌:
它与您的流程一样安全,因为当客户端注销时,它知道其他人已经使用过其刷新令牌一次。因此它必须使用用户名:密码进行身份验证并使最后的刷新令牌无效。
我发现一篇文章解释了这个流程
There is a way to update refresh token without login-password pair:
It is as safe as your flow because when a client gets logged out it understands that someone else already used its refresh token once. So it has to authenticate using username:password and invalidate the last refresh token.
I found an article explaining this flow