From 6eb9986c752c3ecbe5f40b4bf9e807431cb424fe Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 18 May 2023 22:08:41 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/api/connection_token.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 53dffd906..0bc69b025 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -3,6 +3,7 @@ import json import os import urllib.parse +from django.conf import settings from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.utils import timezone @@ -379,19 +380,18 @@ class SuperConnectionTokenViewSet(ConnectionTokenViewSet): expire_now = request.data.get('expire_now', None) asset_type = token.asset.type - asset_category = token.asset.category # 设置默认值 if expire_now is None: # TODO 暂时特殊处理 k8s 不过期 if asset_type in ['k8s', 'kubernetes']: expire_now = False - elif asset_category in ['database', 'db']: - expire_now = False else: - expire_now = True + expire_now = not settings.CONNECTION_TOKEN_REUSABLE - if is_false(expire_now) or token.is_reusable: - logger.debug('Token is reusable or specify, not expire') + if is_false(expire_now): + logger.debug('Api specified, now expire now') + elif token.is_reusable and settings.CONNECTION_TOKEN_REUSABLE: + logger.debug('Token is reusable, not expire now') else: token.expire()