【发布时间】:2019-02-27 21:01:09
【问题描述】:
我的 Django REST 应用程序和 JWT 身份验证模块 (https://jpadilla.github.io/django-rest-framework-jwt) 在刷新令牌阶段出现问题。
刷新令牌的默认逻辑是non-expired tokens can be "refreshed" to obtain a brand new token with renewed expiration time。过期时间设置为 BE。
JWT 框架为刷新令牌提供了一个 API,您应该使用它来获取新令牌,因此过期时间会重置 Web 应用程序上的每个“用户操作”。 这意味着每次从我的 Angular6 SPA 调用 BE 都必须重置令牌的过期时间。
我想到了三种方法:
1) FE 对 BE 的每次调用都必须回调 api 来刷新 token。这意味着呼叫次数总是重复的。 不优雅!
2) 根据算法(在 FE 中)调用 api 刷新令牌,以避免重复调用。 哪种算法?
3) 将令牌的过期时间重置为后端每次来自 FE 的调用,并使用来自 FE 的相同令牌。 我不能这样做!
有什么建议吗?
谢谢
【问题讨论】:
标签: django angular algorithm authentication jwt