Skip to content

Commit

Permalink
bugfix:添加BK_INACTIVE_INTERVEL,提高token验证性能 #1081 (#1082)
Browse files Browse the repository at this point in the history
* bugfix:添加BK_INACTIVE_INTERVEL,提高token验证性能 #1081

* 变更 "更新不活跃状态的时间间隔" 的环境变量名
  • Loading branch information
linxiaowu1992 authored May 11, 2023
1 parent 077b98c commit 36a9321
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion paas2/login/bkauth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def is_bk_token_valid(bk_token): # NOQA

# 更新 无操作有效期
try:
BkToken.objects.filter(token=bk_token).update(inactive_expire_time=now_time + BK_INACTIVE_COOKIE_AGE)
if now_time > 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
3 changes: 2 additions & 1 deletion paas2/login/conf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
BK_TOKEN_OFFSET_ERROR_TIME = 60
# 无操作 失效期,默认2个小时. 长时间误操作, 登录态已过期
BK_INACTIVE_COOKIE_AGE = 60 * 60 * 2

# 更新不活跃状态的时间间隔
BK_INACTIVE_UPDATE_INTERVEL = int(os.getenv("BK_PAAS_LOGIN_INACTIVE_UPDATE_INTERVEL", 60))

# APP_ENGINE 状态查询超时时间
EVENT_STATE_EXPIRE_SECONDS = 180
Expand Down

0 comments on commit 36a9321

Please sign in to comment.