From 829e1f4cac603d47a8957fb84b6e27bd99bfcb8a Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Fri, 20 Dec 2019 15:55:59 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=20(#3555)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Update] 用户详情添加远程应用授权页面 * [Update] 用户详情添加授权的远程应用页面 * [Update] 用户详情添加授权的数据库应用页面 * [Update] 用户详情添加数据库应用授权页面 * [Update] 修改用户详情nav的active属性设置 * [Update] 修改用户详情页面导航 * [Update] 抽象用户详情页面 * [Update] 修改用户详情页面 * [Update] 修改用户详情页面nav header --- .../applications/database_app_list.html | 2 +- .../applications/remote_app_list.html | 2 +- .../templates/assets/admin_user_list.html | 2 +- apps/assets/templates/assets/asset_list.html | 2 +- .../templates/assets/cmd_filter_list.html | 2 +- apps/assets/templates/assets/domain_list.html | 2 +- apps/assets/templates/assets/label_list.html | 2 +- .../templates/assets/platform_list.html | 2 +- .../templates/assets/system_user_list.html | 2 +- .../authentication/_access_key_modal.html | 4 +- apps/perms/api/database_app_permission.py | 5 +- apps/perms/api/remote_app_permission.py | 6 +- .../serializers/database_app_permission.py | 20 +- .../serializers/remote_app_permission.py | 15 + .../perms/asset_permission_list.html | 2 +- .../perms/database_app_permission_list.html | 2 +- .../perms/remote_app_permission_list.html | 2 +- apps/static/js/jumpserver.js | 2 +- .../templates/users/_base_user_detail.html | 26 + .../users/_user_detail_nav_header.html | 97 +++ .../users/user_asset_permission.html | 135 ++-- .../users/user_database_app_permission.html | 168 +++++ apps/users/templates/users/user_detail.html | 593 +++++++++--------- .../templates/users/user_granted_asset.html | 31 +- .../users/user_granted_database_app.html | 100 +++ .../users/user_granted_remote_app.html | 93 +++ .../templates/users/user_group_list.html | 2 +- apps/users/templates/users/user_list.html | 2 +- .../users/user_remote_app_permission.html | 168 +++++ apps/users/urls/views_urls.py | 4 + apps/users/views/user.py | 64 +- 31 files changed, 1126 insertions(+), 433 deletions(-) create mode 100644 apps/users/templates/users/_base_user_detail.html create mode 100644 apps/users/templates/users/_user_detail_nav_header.html create mode 100644 apps/users/templates/users/user_database_app_permission.html create mode 100644 apps/users/templates/users/user_granted_database_app.html create mode 100644 apps/users/templates/users/user_granted_remote_app.html create mode 100644 apps/users/templates/users/user_remote_app_permission.html diff --git a/apps/applications/templates/applications/database_app_list.html b/apps/applications/templates/applications/database_app_list.html index ebe14f9b5..5b60467b1 100644 --- a/apps/applications/templates/applications/database_app_list.html +++ b/apps/applications/templates/applications/database_app_list.html @@ -65,7 +65,7 @@ function initTable() { {data: "port"}, {data: "database"}, {data: "comment"}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/applications/templates/applications/remote_app_list.html b/apps/applications/templates/applications/remote_app_list.html index cb406c805..72ba0186b 100644 --- a/apps/applications/templates/applications/remote_app_list.html +++ b/apps/applications/templates/applications/remote_app_list.html @@ -69,7 +69,7 @@ function initTable() { {data: "get_type_display", orderable: false}, {data: "asset_info", orderable: false}, {data: "comment"}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/assets/templates/assets/admin_user_list.html b/apps/assets/templates/assets/admin_user_list.html index f86352862..93477474c 100644 --- a/apps/assets/templates/assets/admin_user_list.html +++ b/apps/assets/templates/assets/admin_user_list.html @@ -51,7 +51,7 @@ function initTable() { columns: [ {data: function(){return ""}}, {data: "name"}, {data: "username" }, {data: "assets_amount", orderable: false}, {#{data: "connectivity_amount"}, {data: "connectivity_amount"}, {data: "connectivity_amount"},#} - {data: "comment"}, {data: "id", orderable: false, width: "100px"} + {data: "comment"}, {data: "id", orderable: false, width: "120px"} ] }; return jumpserver.initServerSideDataTable(options); diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index bf4186412..2b990619c 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -99,7 +99,7 @@ function initTable() { data: "connectivity", orderable: false, width: '60px' - }, {data: "id", orderable: false, width: "100px"} + }, {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/assets/templates/assets/cmd_filter_list.html b/apps/assets/templates/assets/cmd_filter_list.html index 658c8266f..1d98d5500 100644 --- a/apps/assets/templates/assets/cmd_filter_list.html +++ b/apps/assets/templates/assets/cmd_filter_list.html @@ -62,7 +62,7 @@ function initTable() { columns: [ {data: "id"}, {data: "name" }, {data: "rules", orderable: false}, {data: "system_users", orderable: false}, {data: "comment"}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/assets/templates/assets/domain_list.html b/apps/assets/templates/assets/domain_list.html index e9fb528e1..623f1bea2 100644 --- a/apps/assets/templates/assets/domain_list.html +++ b/apps/assets/templates/assets/domain_list.html @@ -55,7 +55,7 @@ function initTable() { ajax_url: '{% url "api-assets:domain-list" %}', columns: [ {data: "id"}, {data: "name" }, {data: "asset_count", orderable: false }, - {data: "gateway_count", orderable: false }, {data: "comment" }, {data: "id", orderable: false, width: "100px"} + {data: "gateway_count", orderable: false }, {data: "comment" }, {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/assets/templates/assets/label_list.html b/apps/assets/templates/assets/label_list.html index 9ab735f7a..104e5820b 100644 --- a/apps/assets/templates/assets/label_list.html +++ b/apps/assets/templates/assets/label_list.html @@ -45,7 +45,7 @@ function initTable() { columns: [ {data: "id"}, {data: "name" }, {data: "value" }, {data: "asset_count", orderable: false}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/assets/templates/assets/platform_list.html b/apps/assets/templates/assets/platform_list.html index 44f19f1d3..cb1eef5bc 100644 --- a/apps/assets/templates/assets/platform_list.html +++ b/apps/assets/templates/assets/platform_list.html @@ -50,7 +50,7 @@ function initTable() { ajax_url: '{% url "api-assets:platform-list" %}', columns: [ {data: "id"}, {data: "name"}, {data: "base" }, - {data: "comment"}, {data: "id", orderable: false, width: "100px"} + {data: "comment"}, {data: "id", orderable: false, width: "120px"} ] }; platformTable = jumpserver.initServerSideDataTable(options); diff --git a/apps/assets/templates/assets/system_user_list.html b/apps/assets/templates/assets/system_user_list.html index ff282ab81..0e88b6461 100644 --- a/apps/assets/templates/assets/system_user_list.html +++ b/apps/assets/templates/assets/system_user_list.html @@ -62,7 +62,7 @@ function initTable() { columns: [ {data: "id" }, {data: "name" }, {data: "username" }, {data: "protocol"}, {data: "login_mode"}, {data: "assets_amount", orderable: false }, - {data: "comment" }, {data: "id", orderable: false, width: "100px"} + {data: "comment" }, {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/authentication/templates/authentication/_access_key_modal.html b/apps/authentication/templates/authentication/_access_key_modal.html index ac5b26d54..f0b34cf30 100644 --- a/apps/authentication/templates/authentication/_access_key_modal.html +++ b/apps/authentication/templates/authentication/_access_key_modal.html @@ -62,7 +62,7 @@ function initAccessKeyTable() { }}, {targets: 5, createdCell: function (td, cellData, rowData) { var btn = ''; - var btn_del = '{% trans "Delete" %}'; + var btn_del = '{% trans "Delete" %}'; var btn_inactive = '{% trans "Disable" %}'; var btn_active = '{% trans "Enable" %}'; @@ -107,7 +107,7 @@ $(document).ready(function () { }).on("click", ".btn-secret", function () { var $this = $(this); $this.parent().html($this.data("secret")) -}).on("click", ".btn-del", function () { +}).on("click", ".btn-api-key-del", function () { var url = "{% url "api-auth:access-key-detail" pk=DEFAULT_PK %}"; url = url.replace("{{ DEFAULT_PK }}", $(this).data("id")) ; objectDelete($(this), $(this).data("id"), url); diff --git a/apps/perms/api/database_app_permission.py b/apps/perms/api/database_app_permission.py index c7ef54fb3..4b43d347f 100644 --- a/apps/perms/api/database_app_permission.py +++ b/apps/perms/api/database_app_permission.py @@ -12,7 +12,10 @@ __all__ = ['DatabaseAppPermissionViewSet'] class DatabaseAppPermissionViewSet(OrgBulkModelViewSet): model = models.DatabaseAppPermission - serializer_class = serializers.DatabaseAppPermissionSerializer + serializer_classes = { + 'default': serializers.DatabaseAppPermissionSerializer, + 'display': serializers.DatabaseAppPermissionListSerializer + } filter_fields = ('name',) search_fields = filter_fields permission_classes = (IsOrgAdmin,) diff --git a/apps/perms/api/remote_app_permission.py b/apps/perms/api/remote_app_permission.py index 6ced7f0ae..b7fa6de19 100644 --- a/apps/perms/api/remote_app_permission.py +++ b/apps/perms/api/remote_app_permission.py @@ -11,6 +11,7 @@ from ..serializers import ( RemoteAppPermissionSerializer, RemoteAppPermissionUpdateUserSerializer, RemoteAppPermissionUpdateRemoteAppSerializer, + RemoteAppPermissionListSerializer, ) @@ -25,7 +26,10 @@ class RemoteAppPermissionViewSet(OrgModelViewSet): model = RemoteAppPermission filter_fields = ('name', ) search_fields = filter_fields - serializer_class = RemoteAppPermissionSerializer + serializer_classes = { + 'default': RemoteAppPermissionSerializer, + 'display': RemoteAppPermissionListSerializer, + } permission_classes = (IsOrgAdmin,) diff --git a/apps/perms/serializers/database_app_permission.py b/apps/perms/serializers/database_app_permission.py index 75cdea0c9..a8b8bafcd 100644 --- a/apps/perms/serializers/database_app_permission.py +++ b/apps/perms/serializers/database_app_permission.py @@ -1,11 +1,16 @@ # coding: utf-8 # +from rest_framework import serializers + +from common.fields import StringManyToManyField from common.serializers import AdaptedBulkListSerializer from orgs.mixins.serializers import BulkOrgResourceModelSerializer from .. import models -__all__ = ['DatabaseAppPermissionSerializer'] +__all__ = [ + 'DatabaseAppPermissionSerializer', 'DatabaseAppPermissionListSerializer' +] class DatabaseAppPermissionSerializer(BulkOrgResourceModelSerializer): @@ -19,3 +24,16 @@ class DatabaseAppPermissionSerializer(BulkOrgResourceModelSerializer): 'created_by', 'date_created' ] read_only_fields = ['created_by', 'date_created'] + + +class DatabaseAppPermissionListSerializer(BulkOrgResourceModelSerializer): + users = StringManyToManyField(many=True, read_only=True) + user_groups = StringManyToManyField(many=True, read_only=True) + database_apps = StringManyToManyField(many=True, read_only=True) + system_users = StringManyToManyField(many=True, read_only=True) + is_valid = serializers.BooleanField() + is_expired = serializers.BooleanField() + + class Meta: + model = models.DatabaseAppPermission + fields = '__all__' diff --git a/apps/perms/serializers/remote_app_permission.py b/apps/perms/serializers/remote_app_permission.py index 4361cff88..41c5d7022 100644 --- a/apps/perms/serializers/remote_app_permission.py +++ b/apps/perms/serializers/remote_app_permission.py @@ -3,6 +3,7 @@ from rest_framework import serializers +from common.fields import StringManyToManyField from common.serializers import AdaptedBulkListSerializer from orgs.mixins.serializers import BulkOrgResourceModelSerializer from ..models import RemoteAppPermission @@ -12,6 +13,7 @@ __all__ = [ 'RemoteAppPermissionSerializer', 'RemoteAppPermissionUpdateUserSerializer', 'RemoteAppPermissionUpdateRemoteAppSerializer', + 'RemoteAppPermissionListSerializer', ] @@ -27,6 +29,19 @@ class RemoteAppPermissionSerializer(BulkOrgResourceModelSerializer): read_only_fields = ['created_by', 'date_created'] +class RemoteAppPermissionListSerializer(BulkOrgResourceModelSerializer): + users = StringManyToManyField(many=True, read_only=True) + user_groups = StringManyToManyField(many=True, read_only=True) + remote_apps = StringManyToManyField(many=True, read_only=True) + system_users = StringManyToManyField(many=True, read_only=True) + is_valid = serializers.BooleanField() + is_expired = serializers.BooleanField() + + class Meta: + model = RemoteAppPermission + fields = '__all__' + + class RemoteAppPermissionUpdateUserSerializer(serializers.ModelSerializer): class Meta: model = RemoteAppPermission diff --git a/apps/perms/templates/perms/asset_permission_list.html b/apps/perms/templates/perms/asset_permission_list.html index 36d6bcc80..5b507350a 100644 --- a/apps/perms/templates/perms/asset_permission_list.html +++ b/apps/perms/templates/perms/asset_permission_list.html @@ -156,7 +156,7 @@ function initTable() { {data: "id"}, {data: "name"}, {data: "users", orderable: false}, {data: "user_groups", orderable: false}, {data: "assets", orderable: false}, {data: "nodes", orderable: false}, {data: "system_users", orderable: false}, - {data: "is_valid", orderable: false}, {data: "id", orderable: false, width: "100px"} + {data: "is_valid", orderable: false}, {data: "id", orderable: false, width: "120px"} ], select: {}, op_html: $('#actions').html() diff --git a/apps/perms/templates/perms/database_app_permission_list.html b/apps/perms/templates/perms/database_app_permission_list.html index cad068929..b85454cb8 100644 --- a/apps/perms/templates/perms/database_app_permission_list.html +++ b/apps/perms/templates/perms/database_app_permission_list.html @@ -75,7 +75,7 @@ function initTable() { {data: "database_apps", orderable: false}, {data: "system_users", orderable: false}, {data: "is_valid", orderable: false}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/perms/templates/perms/remote_app_permission_list.html b/apps/perms/templates/perms/remote_app_permission_list.html index 6436c6981..f6071430a 100644 --- a/apps/perms/templates/perms/remote_app_permission_list.html +++ b/apps/perms/templates/perms/remote_app_permission_list.html @@ -75,7 +75,7 @@ function initTable() { {data: "remote_apps", orderable: false}, {data: "system_users", orderable: false}, {data: "is_valid", orderable: false}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/static/js/jumpserver.js b/apps/static/js/jumpserver.js index 0bd5ad7ca..af9a032a0 100644 --- a/apps/static/js/jumpserver.js +++ b/apps/static/js/jumpserver.js @@ -158,7 +158,7 @@ function activeNav(prefix) { } else { $("#" + app).addClass('active'); $('#' + app + ' #' + resource).addClass('active'); - $('#' + app + ' #' + resource.replaceAll('-', '_')).addClass('active'); + $('#' + app + ' #' + resource.replace(/-/g, '_')).addClass('active'); } } diff --git a/apps/users/templates/users/_base_user_detail.html b/apps/users/templates/users/_base_user_detail.html new file mode 100644 index 000000000..936037ab8 --- /dev/null +++ b/apps/users/templates/users/_base_user_detail.html @@ -0,0 +1,26 @@ +{% extends 'base.html' %} +{% load static %} +{% load i18n %} + +{% block content %} +
- - | -|
{% trans 'Name' %}: | -{{ user_object.name }} | -
{% trans 'Username' %}: | -{{ user_object.username }} | -
{% trans 'Email' %}: | -{{ user_object.email }} | -
{% trans 'Phone' %}: | -{{ user_object.phone }} | -
{% trans 'Wechat' %}: | -{{ user_object.wechat }} | -
{% trans 'Role' %}: | -{{ user_object.role_display }} | -
{% trans 'MFA certification' %}: | -- {% if user_object.mfa_force_enabled %} - {% trans 'Force enabled' %} - {% elif user_object.mfa_enabled%} - {% trans 'Enabled' %} - {% else %} - {% trans 'Disabled' %} - {% endif %} - | -
{% trans 'Source' %}: | -{{ user_object.get_source_display }} | -
{% trans 'Date expired' %}: | -{{ user_object.date_expired|date:"Y-m-j H:i:s" }} | -
{% trans 'Created by' %}: | -{{ user_object.created_by }} | -
{% trans 'Date joined' %}: | -{{ user_object.date_joined|date:"Y-m-j H:i:s" }} | -
{% trans 'Last login' %}: | -{{ user_object.last_login|date:"Y-m-j H:i:s" }} | -
{% trans 'Last password updated' %}: | -{{ user_object.date_password_last_updated|date:"Y-m-j H:i:s" }} | -
{% trans 'Comment' %}: | -{{ user_object.comment }} | -
{% trans 'Active' %}: | -
-
-
-
-
-
-
- |
-
{% trans 'Force enabled MFA' %}: | -
-
-
-
-
-
-
-
-
- |
-
{% trans 'Reset MFA' %}: | -- - - - | -
{% trans 'Send reset password mail' %}: | -- - - - | -
{% trans 'Send reset ssh key mail' %}: | -- - - - | -
- {{ group.name }} - | -- - | -
- {{ u }} - | -- - | -
+ + | +|
{% trans 'Name' %}: | +{{ object.name }} | +
{% trans 'Username' %}: | +{{ object.username }} | +
{% trans 'Email' %}: | +{{ object.email }} | +
{% trans 'Phone' %}: | +{{ object.phone }} | +
{% trans 'Wechat' %}: | +{{ object.wechat }} | +
{% trans 'Role' %}: | +{{ object.role_display }} | +
{% trans 'MFA certification' %}: | ++ {% if object.mfa_force_enabled %} + {% trans 'Force enabled' %} + {% elif object.mfa_enabled%} + {% trans 'Enabled' %} + {% else %} + {% trans 'Disabled' %} + {% endif %} + | +
{% trans 'Source' %}: | +{{ object.get_source_display }} | +
{% trans 'Date expired' %}: | +{{ object.date_expired|date:"Y-m-j H:i:s" }} | +
{% trans 'Created by' %}: | +{{ object.created_by }} | +
{% trans 'Date joined' %}: | +{{ object.date_joined|date:"Y-m-j H:i:s" }} | +
{% trans 'Last login' %}: | +{{ object.last_login|date:"Y-m-j H:i:s" }} | +
{% trans 'Last password updated' %}: | +{{ object.date_password_last_updated|date:"Y-m-j H:i:s" }} | +
{% trans 'Comment' %}: | +{{ object.comment }} | +
{% trans 'Active' %}: | +
+
+
+
+
+
+
+
+
+ |
+
{% trans 'Force enabled MFA' %}: | +
+
+
+
+
+
+
+
+
+ |
+
{% trans 'Reset MFA' %}: | ++ + + + | +
{% trans 'Send reset password mail' %}: | ++ + + + | +
{% trans 'Send reset ssh key mail' %}: | ++ + + + | +
+ {{ group.name }} + | ++ + | +
+ {{ u }} + | ++ + | +