From e18e76002c9134e0ed9c0a5ee2a044e68a2a02bd Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Tue, 15 Mar 2022 12:56:10 +0800 Subject: [PATCH 01/17] =?UTF-8?q?fix:=20=E6=9A=82=E6=97=B6=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E4=BC=9A=E8=AF=9D=E5=88=86=E4=BA=AB=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/const.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/rbac/const.py b/apps/rbac/const.py index 88adf1199..d625c8a0a 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -79,6 +79,7 @@ exclude_permissions = ( ('terminal', 'status', 'delete,change', 'status'), ('terminal', 'sessionjoinrecord', 'delete', 'sessionjoinrecord'), ('terminal', 'sessionreplay', 'add,change,delete', 'sessionreplay'), + ('terminal', 'sessionsharing', 'view,add,change,delete', 'sessionsharing'), ('terminal', 'session', 'delete', 'session'), ('terminal', 'session', 'delete,change', 'command'), ) From 40aca2615518e97063a0ec0f59ad17ff8672fa08 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Tue, 15 Mar 2022 13:11:47 +0800 Subject: [PATCH 02/17] =?UTF-8?q?fix:=20=E6=9A=82=E6=97=B6=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E4=BC=9A=E8=AF=9D=E5=88=86=E4=BA=AB=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/rbac/const.py b/apps/rbac/const.py index d625c8a0a..f907e4c81 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -80,7 +80,7 @@ exclude_permissions = ( ('terminal', 'sessionjoinrecord', 'delete', 'sessionjoinrecord'), ('terminal', 'sessionreplay', 'add,change,delete', 'sessionreplay'), ('terminal', 'sessionsharing', 'view,add,change,delete', 'sessionsharing'), - ('terminal', 'session', 'delete', 'session'), + ('terminal', 'session', 'delete,share', 'session'), ('terminal', 'session', 'delete,change', 'command'), ) From 2042c7a6e5bf63dc6b6867dc60ddd582772c18b0 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Tue, 15 Mar 2022 14:09:14 +0800 Subject: [PATCH 03/17] =?UTF-8?q?fix:=20=E4=BA=91=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=98=BE=E7=A4=BA=E5=88=9B=E5=BB=BA=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/const.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/rbac/const.py b/apps/rbac/const.py index f907e4c81..a5a390306 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -71,8 +71,8 @@ exclude_permissions = ( ('xpack', 'interface', '*', '*'), ('xpack', 'license', '*', '*'), ('xpack', 'syncinstancedetail', 'add,delete,change', 'syncinstancedetail'), - ('xpack', 'syncinstancetaskexecution', 'add,delete,change', 'syncinstancetaskexecution'), - ('xpack', 'changeauthplanexecution', 'add,delete,change', 'changeauthplanexecution'), + ('xpack', 'syncinstancetaskexecution', 'delete,change', 'syncinstancetaskexecution'), + ('xpack', 'changeauthplanexecution', 'delete,change', 'changeauthplanexecution'), ('xpack', 'changeauthplantask', 'add,delete', 'changeauthplantask'), ('common', 'permission', 'add,delete,view,change', 'permission'), ('terminal', 'command', 'delete,change', 'command'), From d77e84e6f871858845428825533259de7bb18242 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Tue, 15 Mar 2022 16:50:51 +0800 Subject: [PATCH 04/17] fix: ticket comment bug (#7854) Co-authored-by: feng626 <1304903146@qq.com> --- apps/tickets/api/comment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tickets/api/comment.py b/apps/tickets/api/comment.py index 382ad2c99..3bdf55079 100644 --- a/apps/tickets/api/comment.py +++ b/apps/tickets/api/comment.py @@ -15,7 +15,7 @@ __all__ = ['CommentViewSet'] class CommentViewSet(mixins.CreateModelMixin, viewsets.ReadOnlyModelViewSet): serializer_class = serializers.CommentSerializer - permission_classes = (RBACPermission| IsSwagger | IsAssignee | IsApplicant) + permission_classes = (RBACPermission, IsSwagger | IsAssignee | IsApplicant) @lazyproperty def ticket(self): From ee44ae2e1282ecf37b89b4fb17778db298caa02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Tue, 15 Mar 2022 13:06:04 +0800 Subject: [PATCH 05/17] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 63 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index a013c074d..421f95b20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ WORKDIR /opt/jumpserver ADD . . RUN cd utils && bash -ixeu build.sh -# 构建运行时环境 FROM python:3.8-slim ARG PIP_MIRROR=https://pypi.douban.com/simple ENV PIP_MIRROR=$PIP_MIRROR @@ -17,38 +16,66 @@ ENV PIP_JMS_MIRROR=$PIP_JMS_MIRROR WORKDIR /opt/jumpserver -COPY ./requirements/deb_requirements.txt ./requirements/deb_requirements.txt +ARG BUILD_DEPENDENCIES=" \ + g++ \ + make \ + pkg-config" + +ARG DEPENDENCIES=" \ + default-libmysqlclient-dev \ + freetds-dev \ + libpq-dev \ + libffi-dev \ + libldap2-dev \ + libsasl2-dev \ + libxml2-dev \ + libxmlsec1-dev \ + libxmlsec1-openssl \ + libaio-dev \ + sshpass" + +ARG TOOLS=" \ + curl \ + default-mysql-client \ + iproute2 \ + iputils-ping \ + locales \ + procps \ + redis-tools \ + telnet \ + vim \ + wget" + RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ && sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list \ && apt update \ - && apt -y install telnet iproute2 redis-tools default-mysql-client vim wget curl locales procps \ - && apt -y install $(cat requirements/deb_requirements.txt) \ - && rm -rf /var/lib/apt/lists/* \ + && apt -y install ${BUILD_DEPENDENCIES} \ + && apt -y install ${DEPENDENCIES} \ + && apt -y install ${TOOLS} \ && localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8 \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && sed -i "s@# alias l@alias l@g" ~/.bashrc \ - && echo "set mouse-=a" > ~/.vimrc - -COPY ./requirements/requirements.txt ./requirements/requirements.txt -RUN pip install --upgrade pip==20.2.4 setuptools==49.6.0 wheel==0.34.2 -i ${PIP_MIRROR} \ - && pip install --no-cache-dir $(grep -E 'jms|jumpserver' requirements/requirements.txt) -i ${PIP_JMS_MIRROR} \ - && pip install --no-cache-dir -r requirements/requirements.txt -i ${PIP_MIRROR} \ - && rm -rf ~/.cache/pip - -COPY --from=stage-build /opt/jumpserver/release/jumpserver /opt/jumpserver -RUN mkdir -p /root/.ssh/ \ + && mkdir -p /root/.ssh/ \ && echo "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /root/.ssh/config \ + && sed -i "s@# alias l@alias l@g" ~/.bashrc \ + && echo "set mouse-=a" > ~/.vimrc \ + && rm -rf /var/lib/apt/lists/* \ && mv /bin/sh /bin/sh.bak \ && ln -s /bin/bash /bin/sh RUN mkdir -p /opt/jumpserver/oracle/ \ - && wget https://download.jumpserver.org/public/instantclient-basiclite-linux.x64-21.1.0.0.0.tar > /dev/null \ + && wget https://download.jumpserver.org/public/instantclient-basiclite-linux.x64-21.1.0.0.0.tar \ && tar xf instantclient-basiclite-linux.x64-21.1.0.0.0.tar -C /opt/jumpserver/oracle/ \ && echo "/opt/jumpserver/oracle/instantclient_21_1" > /etc/ld.so.conf.d/oracle-instantclient.conf \ && ldconfig \ && rm -f instantclient-basiclite-linux.x64-21.1.0.0.0.tar -RUN echo > config.yml +COPY --from=stage-build /opt/jumpserver/release/jumpserver /opt/jumpserver + +RUN echo > config.yml \ + && pip install --upgrade pip==20.2.4 setuptools==49.6.0 wheel==0.34.2 -i ${PIP_MIRROR} \ + && pip install --no-cache-dir $(grep -E 'jms|jumpserver' requirements/requirements.txt) -i ${PIP_JMS_MIRROR} \ + && pip install --no-cache-dir -r requirements/requirements.txt -i ${PIP_MIRROR} \ + && rm -rf ~/.cache/pip VOLUME /opt/jumpserver/data VOLUME /opt/jumpserver/logs From e1a238b778ebb6e42acc48cbab5dbfc26169ed78 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Tue, 15 Mar 2022 14:24:55 +0800 Subject: [PATCH 06/17] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E6=8E=88=E6=9D=83=E7=BC=93=E5=AD=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/api/asset/user_permission/common.py | 7 ------- apps/perms/urls/asset_permission.py | 2 -- 2 files changed, 9 deletions(-) diff --git a/apps/perms/api/asset/user_permission/common.py b/apps/perms/api/asset/user_permission/common.py index 609fb52c3..1594cedb9 100644 --- a/apps/perms/api/asset/user_permission/common.py +++ b/apps/perms/api/asset/user_permission/common.py @@ -22,7 +22,6 @@ from perms import serializers logger = get_logger(__name__) __all__ = [ - 'RefreshAssetPermissionCacheApi', 'UserGrantedAssetSystemUsersForAdminApi', 'ValidateUserAssetPermissionApi', 'GetUserAssetPermissionActionsApi', @@ -97,12 +96,6 @@ class ValidateUserAssetPermissionApi(APIView): return Response(data, status=status_code) -# TODO 删除 -class RefreshAssetPermissionCacheApi(RetrieveAPIView): - def retrieve(self, request, *args, **kwargs): - return Response({'msg': True}, status=200) - - class UserGrantedAssetSystemUsersForAdminApi(ListAPIView): serializer_class = serializers.AssetSystemUserSerializer only_fields = serializers.AssetSystemUserSerializer.Meta.only_fields diff --git a/apps/perms/urls/asset_permission.py b/apps/perms/urls/asset_permission.py index 7b251dea7..f24b1b8ba 100644 --- a/apps/perms/urls/asset_permission.py +++ b/apps/perms/urls/asset_permission.py @@ -100,8 +100,6 @@ permission_urlpatterns = [ path('user/validate/', api.ValidateUserAssetPermissionApi.as_view(), name='validate-user-asset-permission'), path('user/actions/', api.GetUserAssetPermissionActionsApi.as_view(), name='get-user-asset-permission-actions'), - # 刷新缓存 - path('cache/refresh/', api.RefreshAssetPermissionCacheApi.as_view(), name='refresh-asset-permission-cache'), ] asset_permission_urlpatterns = [ From a18b9bad0a775b29c4e2002cc5045fd3d9c771c7 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Tue, 15 Mar 2022 17:32:54 +0800 Subject: [PATCH 07/17] =?UTF-8?q?fix:=20=C2=A0=E4=BF=AE=E5=A4=8Dticketsess?= =?UTF-8?q?ion=20(#7857)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng626 <1304903146@qq.com> --- apps/tickets/api/relation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/tickets/api/relation.py b/apps/tickets/api/relation.py index 674be316c..cbb661259 100644 --- a/apps/tickets/api/relation.py +++ b/apps/tickets/api/relation.py @@ -17,6 +17,7 @@ class TicketSessionRelationViewSet(CreateModelMixin, JMSGenericViewSet): # Todo: 放到上面的 ViewSet 中 class TicketSessionApi(views.APIView): + perm_model = TicketSession def get(self, request, *args, **kwargs): with tmp_to_root_org(): From 90840a4417bcacd09c92f9f235ea64604284a3c2 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Tue, 15 Mar 2022 18:22:13 +0800 Subject: [PATCH 08/17] =?UTF-8?q?fix:=20=E5=B7=A5=E5=8D=95=E5=88=9B?= =?UTF-8?q?=E5=BB=BAbug=20(#7858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng626 <1304903146@qq.com> --- apps/perms/serializers/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/perms/serializers/base.py b/apps/perms/serializers/base.py index 63cdd8d72..3d48447fb 100644 --- a/apps/perms/serializers/base.py +++ b/apps/perms/serializers/base.py @@ -12,7 +12,7 @@ class ActionsField(serializers.MultipleChoiceField): super().__init__(*args, **kwargs) def run_validation(self, data=empty): - data = super(ActionsField, self).run_validation() + data = super(ActionsField, self).run_validation(data) if isinstance(data, list): data = Action.choices_to_value(value=data) return data From 4f887b1b1138f706379f170ad7ca9a19ae8b63b5 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 Mar 2022 18:40:31 +0800 Subject: [PATCH 09/17] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20tree=20node?= =?UTF-8?q?=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/tree.py | 58 +++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/apps/rbac/tree.py b/apps/rbac/tree.py index 092f6ce90..6a40365f5 100644 --- a/apps/rbac/tree.py +++ b/apps/rbac/tree.py @@ -151,6 +151,21 @@ def sort_nodes(node): class PermissionTreeUtil: get_permissions: Callable + action_mapper = { + 'add': ugettext('Create'), + 'view': ugettext('View'), + 'change': ugettext('Update'), + 'delete': ugettext('Delete') + } + action_icon = { + 'add': 'add', + 'view': 'view', + 'change': 'change', + 'delete': 'delete', + 'invite': 'invite', + 'match': 'match', + 'remove': 'remove' + } def __init__(self, permissions, scope, check_disabled=False): self.permissions = self.prefetch_permissions(permissions) @@ -262,38 +277,17 @@ class PermissionTreeUtil: nodes.append(node) return nodes - @staticmethod - def _get_permission_name(p, content_types_name_mapper): - p: Permission - code_name = p.codename - action_mapper = { - 'add': ugettext('Create'), - 'view': ugettext('View'), - 'change': ugettext('Update'), - 'delete': ugettext('Delete') - } - name = '' - ct = '' - if 'add_' in p.codename: - name = action_mapper['add'] - ct = code_name.replace('add_', '') - elif 'view_' in p.codename: - name = action_mapper['view'] - ct = code_name.replace('view_', '') - elif 'change_' in p.codename: - name = action_mapper['change'] - ct = code_name.replace('change_', '') - elif 'delete' in code_name: - name = action_mapper['delete'] - ct = code_name.replace('delete_', '') - - app_model = '%s.%s' % (p.content_type.app_label, ct) - if app_model in content_types_name_mapper: - name += content_types_name_mapper[app_model] + def _get_permission_name_icon(self, p: Permission, content_types_name_mapper: dict): + action, resource = p.codename.split('_', 1) + app_model = '%s.%s' % (p.content_type.app_label, resource) + if action in self.action_mapper and app_model in content_types_name_mapper: + action_name = self.action_mapper[action] + name = action_name + content_types_name_mapper[app_model] else: name = gettext(p.name) - name = name.replace('Can ', '').replace('可以', '') - return name + icon = self.action_icon.get(action, 'file') + name = name.replace('Can ', '').replace('可以', '') + return name, icon def _create_perms_nodes(self): permissions_id = self.permissions.values_list('id', flat=True) @@ -306,7 +300,7 @@ class PermissionTreeUtil: if not self._check_model_xpack(model_id): continue # name 要特殊处理,解决 i18n 问题 - name = self._get_permission_name(p, content_types_name_mapper) + name, icon = self._get_permission_name_icon(p, content_types_name_mapper) if settings.DEBUG: name += '[{}]'.format(p.app_label_codename) @@ -328,7 +322,7 @@ class PermissionTreeUtil: 'pId': pid, 'isParent': False, 'chkDisabled': self.check_disabled, - 'iconSkin': 'file', + 'iconSkin': icon, 'checked': p.id in permissions_id, 'open': False, 'meta': { From 8839e6293ba44542a2509e57d15a4e41cf83fa75 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 15 Mar 2022 15:42:10 +0800 Subject: [PATCH 10/17] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20mfa=20?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/mfa/sms.py | 6 +++--- apps/users/templates/users/mfa_setting.html | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/authentication/mfa/sms.py b/apps/authentication/mfa/sms.py index 670e49378..d23b68766 100644 --- a/apps/authentication/mfa/sms.py +++ b/apps/authentication/mfa/sms.py @@ -44,13 +44,13 @@ class MFASms(BaseMFA): return settings.SMS_ENABLED def get_enable_url(self) -> str: - return '/ui/#/users/profile/?activeTab=ProfileUpdate' + return '/ui/#/profile/setting?activeTab=ProfileUpdate' def can_disable(self) -> bool: return True def disable(self): - return '/ui/#/users/profile/?activeTab=ProfileUpdate' + return '/ui/#/profile/setting?activeTab=ProfileUpdate' @staticmethod def help_text_of_enable(): @@ -61,4 +61,4 @@ class MFASms(BaseMFA): return _("Clear phone number to disable") def get_disable_url(self) -> str: - return '/ui/#/users/profile/?activeTab=ProfileUpdate' + return '/ui/#/profile/setting?activeTab=ProfileUpdate' diff --git a/apps/users/templates/users/mfa_setting.html b/apps/users/templates/users/mfa_setting.html index e1c6067f3..cb7b5a313 100644 --- a/apps/users/templates/users/mfa_setting.html +++ b/apps/users/templates/users/mfa_setting.html @@ -49,8 +49,9 @@
{% for b in mfa_backends %}
-
  • {{ b.display_name }} - {{ b.enable }}
  • +
  • + {{ b.display_name }} +
  • {% if b.is_active %}