From 01fcdad489fb6d2dc3e45dbef9d9ef58a4dcc3eb Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 12 Dec 2023 15:28:24 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E6=B4=BB=E8=B7=83=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/conf.py | 2 +- apps/users/tasks.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index a0ecff1d1..c3622b61c 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -503,7 +503,7 @@ class Config(dict): 'SECURITY_LUNA_REMEMBER_AUTH': True, 'SECURITY_WATERMARK_ENABLED': True, 'SECURITY_MFA_VERIFY_TTL': 3600, - 'SECURITY_UNCOMMON_USERS_TTL': 90, + 'SECURITY_UNCOMMON_USERS_TTL': 999, 'VERIFY_CODE_TTL': 60, 'SECURITY_SESSION_SHARE': True, 'SECURITY_CHECK_DIFFERENT_CITY_LOGIN': True, diff --git a/apps/users/tasks.py b/apps/users/tasks.py index 4c7887c0f..d716806b2 100644 --- a/apps/users/tasks.py +++ b/apps/users/tasks.py @@ -86,6 +86,13 @@ def check_user_expired_periodic(): @tmp_to_root_org() def check_unused_users(): uncommon_users_ttl = settings.SECURITY_UNCOMMON_USERS_TTL + if not uncommon_users_ttl or not uncommon_users_ttl.isdigit(): + return + + uncommon_users_ttl = int(uncommon_users_ttl) + if uncommon_users_ttl <= 0 or uncommon_users_ttl >= 999: + return + seconds_to_subtract = uncommon_users_ttl * 24 * 60 * 60 t = timezone.now() - timedelta(seconds=seconds_to_subtract) last_login_q = Q(last_login__lte=t) | (Q(last_login__isnull=True) & Q(date_joined__lte=t))