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))