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 %} +
+
+
+
+
+ +
+
+ {% block content_table %} + {% endblock %} +
+
+
+
+
+{% endblock %} diff --git a/apps/users/templates/users/_user_detail_nav_header.html b/apps/users/templates/users/_user_detail_nav_header.html new file mode 100644 index 000000000..28079e149 --- /dev/null +++ b/apps/users/templates/users/_user_detail_nav_header.html @@ -0,0 +1,97 @@ +{% load static %} +{% load i18n %} + + + +
  • + {% trans 'User detail' %} +
  • +
  • + + {% trans "User permissions" %} + + + + +
  • + + \ No newline at end of file diff --git a/apps/users/templates/users/user_asset_permission.html b/apps/users/templates/users/user_asset_permission.html index f75196bdd..21ae72722 100644 --- a/apps/users/templates/users/user_asset_permission.html +++ b/apps/users/templates/users/user_asset_permission.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'users/_base_user_detail.html' %} {% load static %} {% load i18n %} @@ -6,75 +6,55 @@ {% endblock %} -{% block content %} -
    -
    -
    -
    - -
    -
    -
    -
    - {{ object.name }} -
    - - - - - - - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - -
    {% trans 'Name' %}{% trans 'User' %}{% trans 'User group' %}{% trans 'Asset' %}{% trans 'Node' %}{% trans 'System user' %}{% trans 'Validity' %}{% trans 'Action' %}
    -
    -
    -
    -
    -
    -
    + + +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    +
    + + + + + + + + + + + + + + + + +
    {% trans 'Name' %}{% trans 'User' %}{% trans 'User group' %}{% trans 'Asset' %}{% trans 'Node' %}{% trans 'System user' %}{% trans 'Validity' %}{% trans 'Action' %}
    +
    - {% include '_filter_dropdown.html' %} +
    + +{% include '_filter_dropdown.html' %} + {% endblock %} + {% block custom_foot_js %} {% endblock %} diff --git a/apps/users/templates/users/user_database_app_permission.html b/apps/users/templates/users/user_database_app_permission.html new file mode 100644 index 000000000..73b3a7972 --- /dev/null +++ b/apps/users/templates/users/user_database_app_permission.html @@ -0,0 +1,168 @@ +{% extends 'users/_base_user_detail.html' %} +{% load static %} +{% load i18n %} + +{% block custom_head_css_js %} + + +{% endblock %} + +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    {% trans 'Name' %}{% trans 'User' %}{% trans 'User group' %}{% trans 'DatabaseApp' %}{% trans 'System user' %}{% trans 'Validity' %}{% trans 'Action' %}
    +
    +
    +
    +{% endblock %} + +{% block custom_foot_js %} + +{% endblock %} diff --git a/apps/users/templates/users/user_detail.html b/apps/users/templates/users/user_detail.html index dab389362..7bac7a454 100644 --- a/apps/users/templates/users/user_detail.html +++ b/apps/users/templates/users/user_detail.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'users/_base_user_detail.html' %} {% load static %} {% load i18n %} @@ -6,311 +6,296 @@ {% endblock %} -{% block content %} -
    -
    -
    -
    - -
    -
    -
    -
    - {{ user_object.name }} -
    - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - {% if user.phone %} - - - - - {% endif %} - {% if user_object.wechat %} - - - - - {% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if user_object.can_update_password %} - - - - - {% endif %} - - - - - -
    - -
    {% 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 'Quick modify' %} -
    -
    - - - - - - - - - - - - - - - {% if user_object.can_update_password %} - - - - - {% endif %} - {% if user_object.can_update_ssh_key %} - - - - - {% endif %} - - - - - -
    {% trans 'Active' %}: -
    -
    - - -
    -
    -
    {% trans 'Force enabled MFA' %}: - -
    -
    - - -
    -
    -
    -
    {% trans 'Reset MFA' %}: - - - -
    {% trans 'Send reset password mail' %}: - - - -
    {% trans 'Send reset ssh key mail' %}: - - - -
    {% trans 'Unblock user' %} - - - -
    -
    -
    - {% if request.user.can_admin_current_org %} +{% block content_nav_delete_update %} +
  • + {% trans 'Update' %} +
  • +
  • + + {% trans 'Delete' %} + +
  • +{% endblock %} - {% if user_object.can_user_current_org or user_object.can_admin_current_org %} -
    -
    - {% trans 'User group' %} -
    -
    - - - - - - - - - - - - {% for group in user_object.groups.all %} - - - - - {% endfor %} - -
    - -
    - -
    - {{ group.name }} - - -
    -
    -
    - {% endif %} - - {% if LICENSE_VALID and LOGIN_CONFIRM_ENABLE %} -
    -
    - {% trans 'Login confirm' %} -
    -
    - - - - - - - - - - - {% if user_object.get_login_confirm_setting %} - {% for u in user_object.login_confirm_setting.reviewers.all %} - - - - - {% endfor %} - {% endif %} - -
    - -
    - -
    - {{ u }} - - -
    -
    -
    - {% endif %} - - {% endif %} -
    -
    +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    +
    + + + + + + + + + + + + + + + + + + {% if user.phone %} + + + + + {% endif %} + {% if object.wechat %} + + + + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% if object.can_update_password %} + + + + + {% endif %} + + + + + +
    + +
    {% 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 }}
    +
    - {% include 'users/_user_update_pk_modal.html' %} +
    +
    +
    + {% trans 'Quick modify' %} +
    +
    + + + + + + + + + + + + + + + {% if object.can_update_password %} + + + + + {% endif %} + {% if object.can_update_ssh_key %} + + + + + {% endif %} + + + + + +
    {% trans 'Active' %}: + +
    +
    + + +
    +
    +
    +
    {% trans 'Force enabled MFA' %}: + +
    +
    + + +
    +
    +
    +
    {% trans 'Reset MFA' %}: + + + +
    {% trans 'Send reset password mail' %}: + + + +
    {% trans 'Send reset ssh key mail' %}: + + + +
    {% trans 'Unblock user' %} + + + +
    +
    +
    + {% if request.user.can_admin_current_org %} + + {% if object.can_user_current_org or object.can_admin_current_org %} +
    +
    + {% trans 'User group' %} +
    +
    + + + + + + + + + + + + {% for group in object.groups.all %} + + + + + {% endfor %} + +
    + +
    + +
    + {{ group.name }} + + +
    +
    +
    + {% endif %} + + {% if LICENSE_VALID and LOGIN_CONFIRM_ENABLE %} +
    +
    + {% trans 'Login confirm' %} +
    +
    + + + + + + + + + + + {% if object.get_login_confirm_setting %} + {% for u in object.login_confirm_setting.reviewers.all %} + + + + + {% endfor %} + {% endif %} + +
    + +
    + +
    + {{ u }} + + +
    +
    +
    + {% endif %} + + {% endif %} +
    + +{% include 'users/_user_update_pk_modal.html' %} + {% endblock %} + {% block custom_foot_js %} {% endblock %} -{% block content %} -
    -
    -
    -
    - -
    - {% include 'users/_granted_assets.html' %} -
    -
    -
    -
    -
    + +{% block content_table %} +{% include 'users/_granted_assets.html' %} {% endblock %} + {% block custom_foot_js %} +{% endblock %} + +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + +
    + + {% trans 'Name' %}{% trans 'Type' %}{% trans 'Host' %}{% trans 'Database' %}{% trans 'Comment' %}
    +
    +
    +
    +{% endblock %} + +{% block custom_foot_js %} + +{% endblock %} diff --git a/apps/users/templates/users/user_granted_remote_app.html b/apps/users/templates/users/user_granted_remote_app.html new file mode 100644 index 000000000..19b8ab22c --- /dev/null +++ b/apps/users/templates/users/user_granted_remote_app.html @@ -0,0 +1,93 @@ +{% extends 'users/_base_user_detail.html' %} +{% load i18n static %} + +{% block custom_head_css_js %} + +{% endblock %} + +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + +
    + + {% trans 'Name' %}{% trans 'App type' %}{% trans 'Asset' %}{% trans 'Comment' %}
    +
    +
    +
    +{% endblock %} + +{% block custom_foot_js %} + +{% endblock %} diff --git a/apps/users/templates/users/user_group_list.html b/apps/users/templates/users/user_group_list.html index d06cbec6b..5e354d3db 100644 --- a/apps/users/templates/users/user_group_list.html +++ b/apps/users/templates/users/user_group_list.html @@ -62,7 +62,7 @@ function initTable() { ], ajax_url: '{% url "api-users:user-group-list" %}', columns: [{data: "id"}, {data: "name" }, {data: "users_amount", orderable: false}, - {data: "comment"}, {data: "id", orderable: false, width:"100px"}], + {data: "comment"}, {data: "id", orderable: false, width: "120px"}], op_html: $('#actions').html() }; groupsTable = jumpserver.initServerSideDataTable(options); diff --git a/apps/users/templates/users/user_list.html b/apps/users/templates/users/user_list.html index 5ba8ac95a..63dd981be 100644 --- a/apps/users/templates/users/user_list.html +++ b/apps/users/templates/users/user_list.html @@ -121,7 +121,7 @@ function initTable() { {data: "groups_display", orderable: false}, {data: "source"}, {data: "is_valid", orderable: false, width: "50px"}, - {data: "id", orderable: false, width: "100px"} + {data: "id", orderable: false, width: "120px"} ], op_html: $('#actions').html() }; diff --git a/apps/users/templates/users/user_remote_app_permission.html b/apps/users/templates/users/user_remote_app_permission.html new file mode 100644 index 000000000..d1f6aabb7 --- /dev/null +++ b/apps/users/templates/users/user_remote_app_permission.html @@ -0,0 +1,168 @@ +{% extends 'users/_base_user_detail.html' %} +{% load static %} +{% load i18n %} + +{% block custom_head_css_js %} + + +{% endblock %} + +{% block content_table %} +
    +
    +
    + {{ object.name }} +
    + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    {% trans 'Name' %}{% trans 'User' %}{% trans 'User group' %}{% trans 'RemoteApp' %}{% trans 'System user' %}{% trans 'Validity' %}{% trans 'Action' %}
    +
    +
    +
    +{% endblock %} + +{% block custom_foot_js %} + +{% endblock %} diff --git a/apps/users/urls/views_urls.py b/apps/users/urls/views_urls.py index cd5888f8c..7773ca7d6 100644 --- a/apps/users/urls/views_urls.py +++ b/apps/users/urls/views_urls.py @@ -36,6 +36,10 @@ urlpatterns = [ path('user//', views.UserDetailView.as_view(), name='user-detail'), path('user//assets/', views.UserGrantedAssetView.as_view(), name='user-granted-asset'), path('user//asset-permissions/', views.UserAssetPermissionListView.as_view(), name='user-asset-permission'), + path('user//remote-apps/', views.UserGrantedRemoteAppView.as_view(), name='user-granted-remote-app'), + path('user//remote-app-permissions/', views.UserRemoteAppPermissionListView.as_view(), name='user-remote-app-permission'), + path('user//database-apps/', views.UserGrantedDatabasesAppView.as_view(), name='user-granted-database-app'), + path('user//database-app-permissions/', views.UserDatabaseAppPermissionListView.as_view(), name='user-database-app-permission'), path('user//login-history/', views.UserDetailView.as_view(), name='user-login-history'), # User group view diff --git a/apps/users/views/user.py b/apps/users/views/user.py index f1230d464..8e6650240 100644 --- a/apps/users/views/user.py +++ b/apps/users/views/user.py @@ -31,8 +31,10 @@ from ..signals import post_user_create __all__ = [ 'UserListView', 'UserCreateView', 'UserDetailView', - 'UserUpdateView', 'UserGrantedAssetView', - 'UserBulkUpdateView', 'UserAssetPermissionListView', + 'UserUpdateView', 'UserBulkUpdateView', + 'UserGrantedAssetView', 'UserAssetPermissionListView', + 'UserGrantedRemoteAppView', 'UserRemoteAppPermissionListView', + 'UserGrantedDatabasesAppView', 'UserDatabaseAppPermissionListView', ] logger = get_logger(__name__) @@ -164,7 +166,7 @@ class UserBulkUpdateView(PermissionsMixin, TemplateView): class UserDetailView(PermissionsMixin, DetailView): model = User template_name = 'users/user_detail.html' - context_object_name = "user_object" + context_object_name = "object" key_prefix_block = "_LOGIN_BLOCK_{}" permission_classes = [IsOrgAdmin] @@ -220,3 +222,59 @@ class UserAssetPermissionListView(PermissionsMixin, DetailView): } kwargs.update(context) return super().get_context_data(**kwargs) + + +class UserGrantedRemoteAppView(PermissionsMixin, DetailView): + model = User + template_name = 'users/user_granted_remote_app.html' + permission_classes = [IsOrgAdmin] + + def get_context_data(self, **kwargs): + context = { + 'app': _('Users'), + 'action': _('User granted RemoteApp'), + } + kwargs.update(context) + return super().get_context_data(**kwargs) + + +class UserRemoteAppPermissionListView(PermissionsMixin, DetailView): + model = User + template_name = 'users/user_remote_app_permission.html' + permission_classes = [IsOrgAdmin] + + def get_context_data(self, **kwargs): + context = { + 'app': _('Users'), + 'action': _('RemoteApp permission'), + } + kwargs.update(context) + return super().get_context_data(**kwargs) + + +class UserGrantedDatabasesAppView(PermissionsMixin, DetailView): + model = User + template_name = 'users/user_granted_database_app.html' + permission_classes = [IsOrgAdmin] + + def get_context_data(self, **kwargs): + context = { + 'app': _('Users'), + 'action': _('User granted DatabaseApp'), + } + kwargs.update(context) + return super().get_context_data(**kwargs) + + +class UserDatabaseAppPermissionListView(PermissionsMixin, DetailView): + model = User + template_name = 'users/user_database_app_permission.html' + permission_classes = [IsOrgAdmin] + + def get_context_data(self, **kwargs): + context = { + 'app': _('Users'), + 'action': _('DatabaseApp permission'), + } + kwargs.update(context) + return super().get_context_data(**kwargs)