mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-14 06:19:17 +00:00
perf: 优化公钥设置,让用户可以选择是否开启
This commit is contained in:
@@ -5,6 +5,7 @@ import uuid
|
||||
import base64
|
||||
import string
|
||||
import random
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
@@ -32,6 +33,9 @@ logger = get_logger(__file__)
|
||||
|
||||
|
||||
class AuthMixin:
|
||||
date_password_last_updated: datetime.datetime
|
||||
is_local: bool
|
||||
|
||||
@property
|
||||
def password_raw(self):
|
||||
raise AttributeError('Password raw is not a readable attribute')
|
||||
@@ -63,7 +67,12 @@ class AuthMixin:
|
||||
return self.can_use_ssh_key_login()
|
||||
|
||||
def can_use_ssh_key_login(self):
|
||||
return self.is_local and settings.TERMINAL_PUBLIC_KEY_AUTH
|
||||
if not settings.TERMINAL_PUBLIC_KEY_AUTH:
|
||||
return False
|
||||
if self.is_local or settings.TERMINAL_ONLY_SOURCE_LOCAL_CAN_PUBLIC_KEY_AUTH:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_public_key_valid(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user