diff --git a/apps/assets/filters.py b/apps/assets/filters.py index 94a49a3f5..13d8f9e60 100644 --- a/apps/assets/filters.py +++ b/apps/assets/filters.py @@ -65,7 +65,7 @@ class AssetByNodeFilterBackend(filters.BaseFilterBackend): class LabelFilterBackend(filters.BaseFilterBackend): - sep = '#' + sep = ':' query_arg = 'label' def get_schema_fields(self, view): @@ -84,6 +84,8 @@ class LabelFilterBackend(filters.BaseFilterBackend): q = None for kv in labels_query: + if '#' in kv: + self.sep = '#' if self.sep not in kv: continue key, value = kv.strip().split(self.sep)[:2] diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index a231c640d..60c04676f 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -87,6 +87,7 @@ if settings.DEBUG: # 兼容之前的 old_app_pattern = '|'.join(apps) +old_app_pattern = r'^{}'.format(old_app_pattern) urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)] diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 7889bc373..1fa128c6a 100644 Binary files a/apps/locale/zh/LC_MESSAGES/django.mo and b/apps/locale/zh/LC_MESSAGES/django.mo differ diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index bc137d200..d2612f98a 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-15 20:30+0800\n" +"POT-Creation-Date: 2020-06-16 11:02+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -2720,6 +2720,14 @@ msgstr "角色只能为 {}" msgid "Password does not match security rules" msgstr "密码不满足安全规则" +#: users/serializers/user.py:274 +msgid "The old password is incorrect" +msgstr "旧密码错误" + +#: users/serializers/user.py:288 +msgid "The newly set password is inconsistent" +msgstr "两次密码不一致" + #: users/serializers_v2/user.py:36 msgid "name not unique" msgstr "名称重复" diff --git a/apps/settings/api.py b/apps/settings/api.py index 974e31a4e..35ccd5f5b 100644 --- a/apps/settings/api.py +++ b/apps/settings/api.py @@ -275,7 +275,14 @@ class PublicSettingApi(generics.RetrieveAPIView): "LOGIN_CONFIRM_ENABLE": settings.LOGIN_CONFIRM_ENABLE, "SECURITY_VIEW_AUTH_NEED_MFA": settings.SECURITY_VIEW_AUTH_NEED_MFA, "SECURITY_MFA_VERIFY_TTL": settings.SECURITY_MFA_VERIFY_TTL, - "LOGO_URLS": settings.LOGO_URLS + "LOGO_URLS": settings.LOGO_URLS, + "PASSWORD_RULE": { + 'SECURITY_PASSWORD_MIN_LENGTH': settings.SECURITY_PASSWORD_MIN_LENGTH, + 'SECURITY_PASSWORD_UPPER_CASE': settings.SECURITY_PASSWORD_UPPER_CASE, + 'SECURITY_PASSWORD_LOWER_CASE': settings.SECURITY_PASSWORD_LOWER_CASE, + 'SECURITY_PASSWORD_NUMBER': settings.SECURITY_PASSWORD_NUMBER, + 'SECURITY_PASSWORD_SPECIAL_CHAR': settings.SECURITY_PASSWORD_SPECIAL_CHAR, + } } } return instance diff --git a/apps/terminal/api/command.py b/apps/terminal/api/command.py index a7798ce08..749da4fcb 100644 --- a/apps/terminal/api/command.py +++ b/apps/terminal/api/command.py @@ -26,7 +26,8 @@ class CommandQueryMixin: command_store = get_command_storage() permission_classes = [IsOrgAdminOrAppUser | IsOrgAuditor] filter_fields = [ - "asset", "system_user", "user", "session", + "asset", "system_user", "user", "session", "risk_level", + "input" ] default_days_ago = 5 diff --git a/apps/terminal/api/terminal.py b/apps/terminal/api/terminal.py index b0f6b6bca..705848fe0 100644 --- a/apps/terminal/api/terminal.py +++ b/apps/terminal/api/terminal.py @@ -27,6 +27,7 @@ class TerminalViewSet(viewsets.ModelViewSet): queryset = Terminal.objects.filter(is_deleted=False) serializer_class = serializers.TerminalSerializer permission_classes = (IsSuperUser,) + filter_fields = ['name', 'remote_addr'] def create(self, request, *args, **kwargs): name = request.data.get('name') diff --git a/apps/terminal/backends/command/serializers.py b/apps/terminal/backends/command/serializers.py index 657aa2356..4df584dbb 100644 --- a/apps/terminal/backends/command/serializers.py +++ b/apps/terminal/backends/command/serializers.py @@ -1,18 +1,26 @@ # ~*~ coding: utf-8 ~*~ +from django.utils.translation import ugettext_lazy as _ from rest_framework import serializers +from .models import AbstractSessionCommand + class SessionCommandSerializer(serializers.Serializer): """使用这个类作为基础Command Log Serializer类, 用来序列化""" id = serializers.UUIDField(read_only=True) - user = serializers.CharField(max_length=64) - asset = serializers.CharField(max_length=128) - system_user = serializers.CharField(max_length=64) - input = serializers.CharField(max_length=128) - output = serializers.CharField(max_length=1024, allow_blank=True) - session = serializers.CharField(max_length=36) - risk_level = serializers.IntegerField(required=False) + user = serializers.CharField(max_length=64, label=_("User")) + asset = serializers.CharField(max_length=128, label=_("Asset")) + system_user = serializers.CharField(max_length=64, label=_("System user")) + input = serializers.CharField(max_length=128, label=_("Command")) + output = serializers.CharField(max_length=1024, allow_blank=True, label=_("Output")) + session = serializers.CharField(max_length=36, label=_("Session")) + risk_level = serializers.ChoiceField(required=False, label=_("Risk level"), choices=AbstractSessionCommand.RISK_LEVEL_CHOICES) + risk_level_display = serializers.SerializerMethodField() org_id = serializers.CharField(max_length=36, required=False, default='', allow_null=True, allow_blank=True) timestamp = serializers.IntegerField() + @staticmethod + def get_risk_level_display(obj): + risk_mapper = dict(AbstractSessionCommand.RISK_LEVEL_CHOICES) + return risk_mapper.get(obj.risk_level) diff --git a/apps/tickets/serializers/ticket.py b/apps/tickets/serializers/ticket.py index 0f564ad70..f6c995ae0 100644 --- a/apps/tickets/serializers/ticket.py +++ b/apps/tickets/serializers/ticket.py @@ -23,7 +23,8 @@ class TicketSerializer(serializers.ModelSerializer): ] extra_kwargs = { 'status': {'label': _('Status')}, - 'action': {'label': _('Action')} + 'action': {'label': _('Action')}, + 'user_display': {'label': _('User')} } def create(self, validated_data): diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py index 37d820b65..b01bddf42 100644 --- a/apps/users/serializers/user.py +++ b/apps/users/serializers/user.py @@ -271,7 +271,7 @@ class UserUpdatePasswordSerializer(serializers.ModelSerializer): def validate_old_password(self, value): if not self.instance.check_password(value): - msg = 'The old password is incorrect' + msg = _('The old password is incorrect') raise serializers.ValidationError(msg) return value @@ -285,7 +285,7 @@ class UserUpdatePasswordSerializer(serializers.ModelSerializer): def validate_new_password_again(self, value): if value != self.initial_data.get('new_password', ''): - msg = 'The newly set password is inconsistent' + msg = _('The newly set password is inconsistent') raise serializers.ValidationError(msg) return value diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 64aa9d0dc..932ab3b09 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -14,7 +14,7 @@ coreapi==2.3.3 coreschema==0.0.4 cryptography==2.8 decorator==4.1.2 -Django==2.2.10 +Django==2.2.13 django-auth-ldap==1.7.0 django-bootstrap3==9.1.0 django-celery-beat==1.4.0