mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-16 17:12:53 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb5b390d1d | ||
|
|
16c01733f1 | ||
|
|
b1b63445db | ||
|
|
fca15eae7f | ||
|
|
2c63b56f62 | ||
|
|
ea5e56b33e | ||
|
|
e4819ffe11 | ||
|
|
c34302325f | ||
|
|
3b5ee06535 | ||
|
|
8e5edfd179 |
@@ -53,7 +53,15 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
|||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def get_protocols(self, v):
|
def get_protocols(self, v):
|
||||||
return v.protocols.replace(' ', ', ')
|
""" protocols 是 queryset 中返回的,Post 创建成功后返回序列化时没有这个字段 """
|
||||||
|
if hasattr(v, 'protocols'):
|
||||||
|
protocols = v.protocols
|
||||||
|
elif hasattr(v, 'asset') and v.asset:
|
||||||
|
protocols = v.asset.protocols
|
||||||
|
else:
|
||||||
|
protocols = ''
|
||||||
|
protocols = protocols.replace(' ', ', ')
|
||||||
|
return protocols
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_eager_loading(cls, queryset):
|
def setup_eager_loading(cls, queryset):
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from .utils import validate_password_for_ansible
|
|||||||
|
|
||||||
class AuthSerializer(serializers.ModelSerializer):
|
class AuthSerializer(serializers.ModelSerializer):
|
||||||
password = EncryptedField(required=False, allow_blank=True, allow_null=True, max_length=1024, label=_('Password'))
|
password = EncryptedField(required=False, allow_blank=True, allow_null=True, max_length=1024, label=_('Password'))
|
||||||
private_key = EncryptedField(required=False, allow_blank=True, allow_null=True, max_length=4096, label=_('Private key'))
|
private_key = EncryptedField(required=False, allow_blank=True, allow_null=True, max_length=16384, label=_('Private key'))
|
||||||
|
|
||||||
def gen_keys(self, private_key=None, password=None):
|
def gen_keys(self, private_key=None, password=None):
|
||||||
if private_key is None:
|
if private_key is None:
|
||||||
@@ -38,7 +38,7 @@ class AuthSerializerMixin(serializers.ModelSerializer):
|
|||||||
validators=[validate_password_for_ansible]
|
validators=[validate_password_for_ansible]
|
||||||
)
|
)
|
||||||
private_key = EncryptedField(
|
private_key = EncryptedField(
|
||||||
label=_('SSH private key'), required=False, allow_blank=True, allow_null=True, max_length=4096
|
label=_('SSH private key'), required=False, allow_blank=True, allow_null=True, max_length=16384
|
||||||
)
|
)
|
||||||
passphrase = serializers.CharField(
|
passphrase = serializers.CharField(
|
||||||
allow_blank=True, allow_null=True, required=False, max_length=512,
|
allow_blank=True, allow_null=True, required=False, max_length=512,
|
||||||
|
|||||||
@@ -277,7 +277,6 @@ def on_user_auth_success(sender, user, request, login_type=None, **kwargs):
|
|||||||
check_different_city_login_if_need(user, request)
|
check_different_city_login_if_need(user, request)
|
||||||
data = generate_data(user.username, request, login_type=login_type)
|
data = generate_data(user.username, request, login_type=login_type)
|
||||||
request.session['login_time'] = data['datetime'].strftime("%Y-%m-%d %H:%M:%S")
|
request.session['login_time'] = data['datetime'].strftime("%Y-%m-%d %H:%M:%S")
|
||||||
request.session["MFA_VERIFY_TIME"] = int(time.time())
|
|
||||||
data.update({'mfa': int(user.mfa_enabled), 'status': True})
|
data.update({'mfa': int(user.mfa_enabled), 'status': True})
|
||||||
write_login_log(**data)
|
write_login_log(**data)
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class SessionCookieMiddleware(MiddlewareMixin):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_cookie_public_key(request, response):
|
def set_cookie_public_key(request, response):
|
||||||
|
if request.path.startswith('/api'):
|
||||||
|
return
|
||||||
pub_key_name = settings.SESSION_RSA_PUBLIC_KEY_NAME
|
pub_key_name = settings.SESSION_RSA_PUBLIC_KEY_NAME
|
||||||
public_key = request.session.get(pub_key_name)
|
public_key = request.session.get(pub_key_name)
|
||||||
cookie_key = request.COOKIES.get(pub_key_name)
|
cookie_key = request.COOKIES.get(pub_key_name)
|
||||||
|
|||||||
@@ -153,3 +153,5 @@ ANSIBLE_LOG_DIR = os.path.join(PROJECT_DIR, 'data', 'ansible')
|
|||||||
REDIS_HOST = CONFIG.REDIS_HOST
|
REDIS_HOST = CONFIG.REDIS_HOST
|
||||||
REDIS_PORT = CONFIG.REDIS_PORT
|
REDIS_PORT = CONFIG.REDIS_PORT
|
||||||
REDIS_PASSWORD = CONFIG.REDIS_PASSWORD
|
REDIS_PASSWORD = CONFIG.REDIS_PASSWORD
|
||||||
|
|
||||||
|
DJANGO_REDIS_SCAN_ITERSIZE = 1000
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import copy
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
@@ -77,7 +78,7 @@ class CommandStorage(CommonStorageModelMixin, CommonModelMixin):
|
|||||||
def config(self):
|
def config(self):
|
||||||
config = self.meta
|
config = self.meta
|
||||||
config.update({'TYPE': self.type})
|
config.update({'TYPE': self.type})
|
||||||
return config
|
return copy.deepcopy(config)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def valid_config(self):
|
def valid_config(self):
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class TicketViewSet(CommonApiMixin, viewsets.ModelViewSet):
|
|||||||
}
|
}
|
||||||
filterset_class = TicketFilter
|
filterset_class = TicketFilter
|
||||||
search_fields = [
|
search_fields = [
|
||||||
'title', 'action', 'type', 'status', 'applicant_display'
|
'title', 'type', 'status', 'applicant_display'
|
||||||
]
|
]
|
||||||
ordering_fields = (
|
ordering_fields = (
|
||||||
'title', 'applicant_display', 'status', 'state', 'action_display',
|
'title', 'applicant_display', 'status', 'state', 'action_display',
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ django-celery-beat==2.2.1
|
|||||||
django-filter==2.4.0
|
django-filter==2.4.0
|
||||||
django-formtools==2.2
|
django-formtools==2.2
|
||||||
django-ranged-response==0.2.0
|
django-ranged-response==0.2.0
|
||||||
django-redis-cache==2.1.1
|
|
||||||
django-rest-swagger==2.2.0
|
django-rest-swagger==2.2.0
|
||||||
django-simple-captcha==0.5.13
|
django-simple-captcha==0.5.13
|
||||||
django-timezone-field==4.1.0
|
django-timezone-field==4.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user