Skip to content

Commit

Permalink
Fixes #1082 修复在更新token无操作有效期时的时间判断问题 (#1104)
Browse files Browse the repository at this point in the history
* bugfix: 修复bk_tken在更新无操作有效期时的时间判断问题

* bugfix: 修复在更新token无操作有效期时的时间判断问题和逻辑注释
  • Loading branch information
linxiaowu1992 authored Sep 14, 2023
1 parent 637ee8b commit 8a1b567
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion paas2/login/bkauth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def is_bk_token_valid(bk_token): # NOQA

# 更新 无操作有效期
try:
if now_time > inactive_expire_time + settings.BK_INACTIVE_UPDATE_INTERVEL:
# 为避免每个请求都刷新inactive_expire_time造成性能问题,在对inactive_expire_time续期前,进行更新时间间隔判断
# 表记录中的inactive_expire_time = 上一个now_time + BK_INACTIVE_COOKIE_AGE
# 需判断 (当前时间 + BK_INACTIVE_COOKIE_AGE) > (inactive_expire_time + 更新时间间隔),才进行续期
if now_time + BK_INACTIVE_COOKIE_AGE > inactive_expire_time + settings.BK_INACTIVE_UPDATE_INTERVEL:
BkToken.objects.filter(token=bk_token).update(inactive_expire_time=now_time + BK_INACTIVE_COOKIE_AGE)
except Exception:
logger.exception("update inactive_expire_time fail")
Expand Down

0 comments on commit 8a1b567

Please sign in to comment.