Merge branch 'dev' of github.com:jumpserver/jumpserver into dev

pull/2731/head^2
ibuler 2019-05-24 18:34:35 +08:00
commit b237cbb20f
21 changed files with 630 additions and 293 deletions

View File

@ -28,7 +28,7 @@ REMOTE_APP_TYPE_CHOICES = (
( (
_('Virtualization tools'), _('Virtualization tools'),
( (
(REMOTE_APP_TYPE_VMWARE_CLIENT, 'VMware Client'), (REMOTE_APP_TYPE_VMWARE_CLIENT, 'vSphere Client'),
) )
), ),
(REMOTE_APP_TYPE_CUSTOM, _('Custom')), (REMOTE_APP_TYPE_CUSTOM, _('Custom')),

View File

@ -8,6 +8,7 @@ from orgs.mixins import OrgModelForm
from assets.models import Asset, SystemUser from assets.models import Asset, SystemUser
from ..models import RemoteApp from ..models import RemoteApp
from .. import const
__all__ = [ __all__ = [
@ -109,3 +110,23 @@ class RemoteAppCreateUpdateForm(RemoteAppTypeForms, OrgModelForm):
}) })
} }
def _clean_params(self):
app_type = self.data.get('type')
fields = const.REMOTE_APP_TYPE_MAP_FIELDS.get(app_type, [])
params = {}
for field in fields:
name = field['name']
value = self.cleaned_data[name]
params.update({name: value})
return params
def _save_params(self, instance):
params = self._clean_params()
instance.params = params
instance.save()
return instance
def save(self, commit=True):
instance = super().save(commit=commit)
instance = self._save_params(instance)
return instance

View File

@ -64,28 +64,60 @@
{% block custom_foot_js %} {% block custom_foot_js %}
<script type="text/javascript"> <script type="text/javascript">
var type_id = '#' + '{{ form.type.id_for_label }}'; var app_type_id = '#' + '{{ form.type.id_for_label }}';
var app_path_id = '#' + '{{ form.path.id_for_label }}';
var all_type_fields = [ var all_type_fields = [
'.chrome-fields', '.chrome-fields',
'.mysql_workbench-fields', '.mysql_workbench-fields',
'.vmware_client-fields', '.vmware_client-fields',
'.custom-fields' '.custom-fields'
]; ];
function appTypeChange(){ var app_type_map_default_fields_value = {
'chrome': {
'app_path': 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
},
'mysql_workbench': {
'app_path': 'C:\\Program Files\\MySQL\\MySQL Workbench 8.0 CE\\MySQLWorkbench.exe'
},
'vmware_client': {
'app_path': 'C:\\Program Files (x86)\\VMware\\Infrastructure\\Virtual Infrastructure Client\\Launcher\\VpxClient.exe'
},
'custom': {'app_path': ''}
};
function getAppType(){
return $(app_type_id+ " option:selected").val();
}
function initialDefaultValue(){
var app_type = getAppType();
var app_path = $(app_path_id).val();
if(app_path){
app_type_map_default_fields_value[app_type]['app_path'] = app_path
}
}
function setDefaultValue(){
// 设置类型相关字段的默认值
var app_type = getAppType();
var app_path = app_type_map_default_fields_value[app_type]['app_path'];
$(app_path_id).val(app_path)
}
function hiddenFields(){
var app_type = getAppType();
$.each(all_type_fields, function(index, value){ $.each(all_type_fields, function(index, value){
$(value).addClass('hidden') $(value).addClass('hidden')
}); });
var type = $(type_id+ " option:selected").val(); $('.' + app_type + '-fields').removeClass('hidden');
$('.' + type + '-fields').removeClass('hidden');
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2({ $('.select2').select2({
closeOnSelect: true closeOnSelect: true
}); });
appTypeChange() initialDefaultValue();
hiddenFields();
setDefaultValue();
}) })
.on('change', type_id, function(){ .on('change', app_type_id, function(){
appTypeChange(); hiddenFields();
setDefaultValue();
}); });
</script> </script>
{% endblock %} {% endblock %}

View File

@ -7,6 +7,8 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django_auth_ldap.backend import _LDAPUser, LDAPBackend from django_auth_ldap.backend import _LDAPUser, LDAPBackend
from django_auth_ldap.config import _LDAPConfig, LDAPSearch, LDAPSearchUnion from django_auth_ldap.config import _LDAPConfig, LDAPSearch, LDAPSearchUnion
from users.utils import construct_user_email
logger = _LDAPConfig.get_logger() logger = _LDAPConfig.get_logger()
@ -86,13 +88,18 @@ class LDAPUser(_LDAPUser):
return user_dn return user_dn
def _populate_user_from_attributes(self): def _populate_user_from_attributes(self):
super()._populate_user_from_attributes() for field, attr in self.settings.USER_ATTR_MAP.items():
if not hasattr(self._user, 'email') or '@' not in self._user.email: try:
if '@' not in self._user.username: value = self.attrs[attr][0]
email = '{}@{}'.format(self._user.username, settings.EMAIL_SUFFIX) except LookupError:
logger.warning("{} does not have a value for the attribute {}".format(self.dn, attr))
else: else:
email = self._user.username if not hasattr(self._user, field):
continue
if isinstance(getattr(self._user, field), bool):
value = value.lower() in ['true', '1']
setattr(self._user, field, value)
email = getattr(self._user, 'email', '')
email = construct_user_email(email, self._user.username)
setattr(self._user, 'email', email) setattr(self._user, 'email', email)

View File

@ -357,6 +357,12 @@ EMAIL_USE_SSL = False
EMAIL_USE_TLS = False EMAIL_USE_TLS = False
EMAIL_SUBJECT_PREFIX = '[JMS] ' EMAIL_SUBJECT_PREFIX = '[JMS] '
#Email custom content
EMAIL_CUSTOM_USER_CREATED_SUBJECT = ''
EMAIL_CUSTOM_USER_CREATED_HONORIFIC = ''
EMAIL_CUSTOM_USER_CREATED_BODY = ''
EMAIL_CUSTOM_USER_CREATED_SIGNATURE = ''
REST_FRAMEWORK = { REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions, # Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users. # or allow read-only access for unauthenticated users.

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n" "Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-21 21:09+0800\n" "POT-Creation-Date: 2019-05-24 12:02+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n" "Language-Team: Jumpserver team<ibuler@qq.com>\n"
@ -33,45 +33,45 @@ msgstr "虚拟化工具"
msgid "Custom" msgid "Custom"
msgstr "自定义" msgstr "自定义"
#: applications/forms/remote_app.py:20 #: applications/forms/remote_app.py:21
msgid "Target URL" msgid "Target URL"
msgstr "目标URL" msgstr "目标URL"
#: applications/forms/remote_app.py:23 applications/forms/remote_app.py:52 #: applications/forms/remote_app.py:24 applications/forms/remote_app.py:53
#: applications/forms/remote_app.py:68 #: applications/forms/remote_app.py:69
msgid "Login username" msgid "Login username"
msgstr "登录账号" msgstr "登录账号"
#: applications/forms/remote_app.py:27 applications/forms/remote_app.py:56 #: applications/forms/remote_app.py:28 applications/forms/remote_app.py:57
#: applications/forms/remote_app.py:72 #: applications/forms/remote_app.py:73
msgid "Login password" msgid "Login password"
msgstr "登录密码" msgstr "登录密码"
#: applications/forms/remote_app.py:33 #: applications/forms/remote_app.py:34
msgid "Database IP" msgid "Database IP"
msgstr "数据库IP" msgstr "数据库IP"
#: applications/forms/remote_app.py:36 #: applications/forms/remote_app.py:37
msgid "Database name" msgid "Database name"
msgstr "数据库名" msgstr "数据库名"
#: applications/forms/remote_app.py:39 #: applications/forms/remote_app.py:40
msgid "Database username" msgid "Database username"
msgstr "数据库账号" msgstr "数据库账号"
#: applications/forms/remote_app.py:43 #: applications/forms/remote_app.py:44
msgid "Database password" msgid "Database password"
msgstr "数据库密码" msgstr "数据库密码"
#: applications/forms/remote_app.py:49 applications/forms/remote_app.py:65 #: applications/forms/remote_app.py:50 applications/forms/remote_app.py:66
msgid "Target address" msgid "Target address"
msgstr "目标地址" msgstr "目标地址"
#: applications/forms/remote_app.py:62 #: applications/forms/remote_app.py:63
msgid "Operating parameter" msgid "Operating parameter"
msgstr "运行参数" msgstr "运行参数"
#: applications/forms/remote_app.py:105 applications/models/remote_app.py:23 #: applications/forms/remote_app.py:106 applications/models/remote_app.py:23
#: applications/templates/applications/remote_app_detail.html:57 #: applications/templates/applications/remote_app_detail.html:57
#: applications/templates/applications/remote_app_list.html:22 #: applications/templates/applications/remote_app_list.html:22
#: applications/templates/applications/user_remote_app_list.html:18 #: applications/templates/applications/user_remote_app_list.html:18
@ -101,12 +101,12 @@ msgstr "运行参数"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_subtask_list.html:13 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_subtask_list.html:13
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:14 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:14
#: xpack/plugins/cloud/models.py:187 #: xpack/plugins/cloud/models.py:187
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:63 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:65
#: xpack/plugins/orgs/templates/orgs/org_list.html:16 #: xpack/plugins/orgs/templates/orgs/org_list.html:16
msgid "Asset" msgid "Asset"
msgstr "资产" msgstr "资产"
#: applications/forms/remote_app.py:108 applications/models/remote_app.py:27 #: applications/forms/remote_app.py:109 applications/models/remote_app.py:27
#: applications/templates/applications/remote_app_detail.html:61 #: applications/templates/applications/remote_app_detail.html:61
#: applications/templates/applications/remote_app_list.html:23 #: applications/templates/applications/remote_app_list.html:23
#: applications/templates/applications/user_remote_app_list.html:19 #: applications/templates/applications/user_remote_app_list.html:19
@ -161,8 +161,8 @@ msgstr "系统用户"
#: settings/templates/settings/_ldap_list_users_modal.html:38 #: settings/templates/settings/_ldap_list_users_modal.html:38
#: settings/templates/settings/command_storage_create.html:41 #: settings/templates/settings/command_storage_create.html:41
#: settings/templates/settings/replay_storage_create.html:44 #: settings/templates/settings/replay_storage_create.html:44
#: settings/templates/settings/terminal_setting.html:80 #: settings/templates/settings/terminal_setting.html:83
#: settings/templates/settings/terminal_setting.html:102 terminal/models.py:22 #: settings/templates/settings/terminal_setting.html:105 terminal/models.py:22
#: terminal/models.py:241 terminal/templates/terminal/terminal_detail.html:43 #: terminal/models.py:241 terminal/templates/terminal/terminal_detail.html:43
#: terminal/templates/terminal/terminal_list.html:29 users/models/group.py:14 #: terminal/templates/terminal/terminal_list.html:29 users/models/group.py:14
#: users/models/user.py:61 users/templates/users/_select_user_modal.html:13 #: users/models/user.py:61 users/templates/users/_select_user_modal.html:13
@ -177,9 +177,9 @@ msgstr "系统用户"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:61 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:61
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:12 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:12
#: xpack/plugins/cloud/models.py:49 xpack/plugins/cloud/models.py:119 #: xpack/plugins/cloud/models.py:49 xpack/plugins/cloud/models.py:119
#: xpack/plugins/cloud/templates/cloud/account_detail.html:50 #: xpack/plugins/cloud/templates/cloud/account_detail.html:52
#: xpack/plugins/cloud/templates/cloud/account_list.html:12 #: xpack/plugins/cloud/templates/cloud/account_list.html:12
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:53 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:55
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:12 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:12
#: xpack/plugins/orgs/templates/orgs/org_detail.html:52 #: xpack/plugins/orgs/templates/orgs/org_detail.html:52
#: xpack/plugins/orgs/templates/orgs/org_list.html:12 #: xpack/plugins/orgs/templates/orgs/org_list.html:12
@ -224,6 +224,8 @@ msgstr "参数"
msgid "Created by" msgid "Created by"
msgstr "创建者" msgstr "创建者"
# msgid "Created by"
# msgstr "创建者"
#: applications/models/remote_app.py:46 #: applications/models/remote_app.py:46
#: applications/templates/applications/remote_app_detail.html:73 #: applications/templates/applications/remote_app_detail.html:73
#: assets/models/asset.py:110 assets/models/cluster.py:26 #: assets/models/asset.py:110 assets/models/cluster.py:26
@ -242,12 +244,14 @@ msgstr "创建者"
#: users/templates/users/user_group_detail.html:63 #: users/templates/users/user_group_detail.html:63
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:105 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:105
#: xpack/plugins/cloud/models.py:56 xpack/plugins/cloud/models.py:128 #: xpack/plugins/cloud/models.py:56 xpack/plugins/cloud/models.py:128
#: xpack/plugins/cloud/templates/cloud/account_detail.html:66 #: xpack/plugins/cloud/templates/cloud/account_detail.html:68
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:77 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:79
#: xpack/plugins/orgs/templates/orgs/org_detail.html:60 #: xpack/plugins/orgs/templates/orgs/org_detail.html:60
msgid "Date created" msgid "Date created"
msgstr "创建日期" msgstr "创建日期"
# msgid "Date created"
# msgstr "创建日期"
#: applications/models/remote_app.py:49 #: applications/models/remote_app.py:49
#: applications/templates/applications/remote_app_detail.html:81 #: applications/templates/applications/remote_app_detail.html:81
#: applications/templates/applications/remote_app_list.html:24 #: applications/templates/applications/remote_app_list.html:24
@ -282,9 +286,9 @@ msgstr "创建日期"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:117 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:117
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:19 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:19
#: xpack/plugins/cloud/models.py:54 xpack/plugins/cloud/models.py:125 #: xpack/plugins/cloud/models.py:54 xpack/plugins/cloud/models.py:125
#: xpack/plugins/cloud/templates/cloud/account_detail.html:70 #: xpack/plugins/cloud/templates/cloud/account_detail.html:72
#: xpack/plugins/cloud/templates/cloud/account_list.html:15 #: xpack/plugins/cloud/templates/cloud/account_list.html:15
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:69 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:71
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:16 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:16
#: xpack/plugins/orgs/templates/orgs/org_detail.html:64 #: xpack/plugins/orgs/templates/orgs/org_detail.html:64
#: xpack/plugins/orgs/templates/orgs/org_list.html:22 #: xpack/plugins/orgs/templates/orgs/org_list.html:22
@ -315,13 +319,14 @@ msgstr "远程应用"
#: assets/templates/assets/label_create_update.html:18 #: assets/templates/assets/label_create_update.html:18
#: perms/templates/perms/asset_permission_create_update.html:83 #: perms/templates/perms/asset_permission_create_update.html:83
#: perms/templates/perms/remote_app_permission_create_update.html:83 #: perms/templates/perms/remote_app_permission_create_update.html:83
#: settings/templates/settings/basic_setting.html:61 #: settings/templates/settings/basic_setting.html:64
#: settings/templates/settings/command_storage_create.html:79 #: settings/templates/settings/command_storage_create.html:79
#: settings/templates/settings/email_setting.html:62 #: settings/templates/settings/email_content_setting.html:54
#: settings/templates/settings/ldap_setting.html:61 #: settings/templates/settings/email_setting.html:65
#: settings/templates/settings/ldap_setting.html:64
#: settings/templates/settings/replay_storage_create.html:152 #: settings/templates/settings/replay_storage_create.html:152
#: settings/templates/settings/security_setting.html:70 #: settings/templates/settings/security_setting.html:73
#: settings/templates/settings/terminal_setting.html:68 #: settings/templates/settings/terminal_setting.html:71
#: terminal/templates/terminal/terminal_update.html:45 #: terminal/templates/terminal/terminal_update.html:45
#: users/templates/users/_user.html:50 #: users/templates/users/_user.html:50
#: users/templates/users/user_bulk_update.html:23 #: users/templates/users/user_bulk_update.html:23
@ -353,13 +358,14 @@ msgstr "重置"
#: audits/templates/audits/login_log_list.html:89 #: audits/templates/audits/login_log_list.html:89
#: perms/templates/perms/asset_permission_create_update.html:84 #: perms/templates/perms/asset_permission_create_update.html:84
#: perms/templates/perms/remote_app_permission_create_update.html:84 #: perms/templates/perms/remote_app_permission_create_update.html:84
#: settings/templates/settings/basic_setting.html:62 #: settings/templates/settings/basic_setting.html:65
#: settings/templates/settings/command_storage_create.html:80 #: settings/templates/settings/command_storage_create.html:80
#: settings/templates/settings/email_setting.html:63 #: settings/templates/settings/email_content_setting.html:55
#: settings/templates/settings/ldap_setting.html:64 #: settings/templates/settings/email_setting.html:66
#: settings/templates/settings/ldap_setting.html:67
#: settings/templates/settings/replay_storage_create.html:153 #: settings/templates/settings/replay_storage_create.html:153
#: settings/templates/settings/security_setting.html:71 #: settings/templates/settings/security_setting.html:74
#: settings/templates/settings/terminal_setting.html:70 #: settings/templates/settings/terminal_setting.html:73
#: terminal/templates/terminal/command_list.html:103 #: terminal/templates/terminal/command_list.html:103
#: terminal/templates/terminal/session_list.html:126 #: terminal/templates/terminal/session_list.html:126
#: terminal/templates/terminal/terminal_update.html:46 #: terminal/templates/terminal/terminal_update.html:46
@ -437,11 +443,11 @@ msgstr "详情"
#: users/templates/users/user_profile.html:187 #: users/templates/users/user_profile.html:187
#: users/templates/users/user_profile.html:196 #: users/templates/users/user_profile.html:196
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:29 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:29
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:55 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:54
#: xpack/plugins/cloud/templates/cloud/account_detail.html:23 #: xpack/plugins/cloud/templates/cloud/account_detail.html:25
#: xpack/plugins/cloud/templates/cloud/account_list.html:39 #: xpack/plugins/cloud/templates/cloud/account_list.html:38
#: xpack/plugins/orgs/templates/orgs/org_detail.html:25 #: xpack/plugins/orgs/templates/orgs/org_detail.html:25
#: xpack/plugins/orgs/templates/orgs/org_list.html:87 #: xpack/plugins/orgs/templates/orgs/org_list.html:85
msgid "Update" msgid "Update"
msgstr "更新" msgstr "更新"
@ -466,8 +472,8 @@ msgstr "更新"
#: perms/templates/perms/asset_permission_list.html:182 #: perms/templates/perms/asset_permission_list.html:182
#: perms/templates/perms/remote_app_permission_detail.html:34 #: perms/templates/perms/remote_app_permission_detail.html:34
#: perms/templates/perms/remote_app_permission_list.html:60 #: perms/templates/perms/remote_app_permission_list.html:60
#: settings/templates/settings/terminal_setting.html:90 #: settings/templates/settings/terminal_setting.html:93
#: settings/templates/settings/terminal_setting.html:112 #: settings/templates/settings/terminal_setting.html:115
#: terminal/templates/terminal/terminal_list.html:74 #: terminal/templates/terminal/terminal_list.html:74
#: users/templates/users/user_detail.html:30 #: users/templates/users/user_detail.html:30
#: users/templates/users/user_group_detail.html:32 #: users/templates/users/user_group_detail.html:32
@ -475,13 +481,13 @@ msgstr "更新"
#: users/templates/users/user_list.html:104 #: users/templates/users/user_list.html:104
#: users/templates/users/user_list.html:108 #: users/templates/users/user_list.html:108
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:33 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:33
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:57 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:56
#: xpack/plugins/cloud/templates/cloud/account_detail.html:27 #: xpack/plugins/cloud/templates/cloud/account_detail.html:29
#: xpack/plugins/cloud/templates/cloud/account_list.html:41 #: xpack/plugins/cloud/templates/cloud/account_list.html:40
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:30 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:32
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:55 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:54
#: xpack/plugins/orgs/templates/orgs/org_detail.html:29 #: xpack/plugins/orgs/templates/orgs/org_detail.html:29
#: xpack/plugins/orgs/templates/orgs/org_list.html:89 #: xpack/plugins/orgs/templates/orgs/org_list.html:87
msgid "Delete" msgid "Delete"
msgstr "删除" msgstr "删除"
@ -528,8 +534,8 @@ msgstr "创建远程应用"
#: perms/templates/perms/asset_permission_list.html:60 #: perms/templates/perms/asset_permission_list.html:60
#: perms/templates/perms/asset_permission_list.html:134 #: perms/templates/perms/asset_permission_list.html:134
#: perms/templates/perms/remote_app_permission_list.html:19 #: perms/templates/perms/remote_app_permission_list.html:19
#: settings/templates/settings/terminal_setting.html:82 #: settings/templates/settings/terminal_setting.html:85
#: settings/templates/settings/terminal_setting.html:104 #: settings/templates/settings/terminal_setting.html:107
#: terminal/templates/terminal/session_list.html:81 #: terminal/templates/terminal/session_list.html:81
#: terminal/templates/terminal/terminal_list.html:36 #: terminal/templates/terminal/terminal_list.html:36
#: users/templates/users/user_group_list.html:38 #: users/templates/users/user_group_list.html:38
@ -618,7 +624,7 @@ msgstr "节点管理"
#: assets/models/cluster.py:19 assets/models/user.py:91 #: assets/models/cluster.py:19 assets/models/user.py:91
#: assets/templates/assets/asset_detail.html:80 templates/_nav.html:24 #: assets/templates/assets/asset_detail.html:80 templates/_nav.html:24
#: xpack/plugins/cloud/models.py:124 #: xpack/plugins/cloud/models.py:124
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:65 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:67
#: xpack/plugins/orgs/templates/orgs/org_list.html:18 #: xpack/plugins/orgs/templates/orgs/org_list.html:18
msgid "Admin user" msgid "Admin user"
msgstr "管理用户" msgstr "管理用户"
@ -655,8 +661,8 @@ msgstr "网域"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_list.html:55 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_execution_list.html:55
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:15 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:15
#: xpack/plugins/cloud/models.py:123 #: xpack/plugins/cloud/models.py:123
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:61 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:63
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:64 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:66
msgid "Node" msgid "Node"
msgstr "节点" msgstr "节点"
@ -1069,8 +1075,8 @@ msgstr "过滤器"
#: perms/templates/perms/remote_app_permission_remote_app.html:54 #: perms/templates/perms/remote_app_permission_remote_app.html:54
#: settings/templates/settings/command_storage_create.html:31 #: settings/templates/settings/command_storage_create.html:31
#: settings/templates/settings/replay_storage_create.html:31 #: settings/templates/settings/replay_storage_create.html:31
#: settings/templates/settings/terminal_setting.html:81 #: settings/templates/settings/terminal_setting.html:84
#: settings/templates/settings/terminal_setting.html:103 #: settings/templates/settings/terminal_setting.html:106
msgid "Type" msgid "Type"
msgstr "类型" msgstr "类型"
@ -1382,7 +1388,7 @@ msgstr "需要二次认证来查看账号信息"
#: assets/templates/assets/system_user_asset.html:112 #: assets/templates/assets/system_user_asset.html:112
#: assets/templates/assets/system_user_detail.html:182 #: assets/templates/assets/system_user_detail.html:182
#: assets/templates/assets/system_user_list.html:168 #: assets/templates/assets/system_user_list.html:168
#: settings/templates/settings/terminal_setting.html:165 #: settings/templates/settings/terminal_setting.html:168
#: templates/_modal.html:23 terminal/templates/terminal/session_detail.html:108 #: templates/_modal.html:23 terminal/templates/terminal/session_detail.html:108
#: users/templates/users/user_detail.html:388 #: users/templates/users/user_detail.html:388
#: users/templates/users/user_detail.html:414 #: users/templates/users/user_detail.html:414
@ -1409,7 +1415,7 @@ msgstr "获取认证信息错误"
#: assets/templates/assets/_asset_user_view_auth_modal.html:139 #: assets/templates/assets/_asset_user_view_auth_modal.html:139
#: assets/templates/assets/_user_asset_detail_modal.html:23 #: assets/templates/assets/_user_asset_detail_modal.html:23
#: settings/templates/settings/_ldap_list_users_modal.html:96 #: settings/templates/settings/_ldap_list_users_modal.html:99
#: templates/_modal.html:22 #: templates/_modal.html:22
msgid "Close" msgid "Close"
msgstr "关闭" msgstr "关闭"
@ -1578,7 +1584,7 @@ msgstr "导出"
#: assets/templates/assets/admin_user_list.html:24 #: assets/templates/assets/admin_user_list.html:24
#: assets/templates/assets/asset_list.html:81 #: assets/templates/assets/asset_list.html:81
#: assets/templates/assets/system_user_list.html:28 #: assets/templates/assets/system_user_list.html:28
#: settings/templates/settings/_ldap_list_users_modal.html:97 #: settings/templates/settings/_ldap_list_users_modal.html:100
#: users/templates/users/user_group_list.html:15 #: users/templates/users/user_group_list.html:15
#: users/templates/users/user_list.html:15 #: users/templates/users/user_list.html:15
#: xpack/plugins/license/templates/license/license_detail.html:110 #: xpack/plugins/license/templates/license/license_detail.html:110
@ -1799,7 +1805,7 @@ msgstr "删除选择资产"
#: assets/templates/assets/asset_list.html:698 #: assets/templates/assets/asset_list.html:698
#: assets/templates/assets/system_user_list.html:166 #: assets/templates/assets/system_user_list.html:166
#: settings/templates/settings/terminal_setting.html:163 #: settings/templates/settings/terminal_setting.html:166
#: users/templates/users/user_detail.html:386 #: users/templates/users/user_detail.html:386
#: users/templates/users/user_detail.html:412 #: users/templates/users/user_detail.html:412
#: users/templates/users/user_detail.html:480 #: users/templates/users/user_detail.html:480
@ -1903,8 +1909,8 @@ msgstr "创建网关"
#: assets/templates/assets/domain_gateway_list.html:99 #: assets/templates/assets/domain_gateway_list.html:99
#: assets/templates/assets/domain_gateway_list.html:101 #: assets/templates/assets/domain_gateway_list.html:101
#: settings/templates/settings/email_setting.html:61 #: settings/templates/settings/email_setting.html:64
#: settings/templates/settings/ldap_setting.html:62 #: settings/templates/settings/ldap_setting.html:65
msgid "Test connection" msgid "Test connection"
msgstr "测试连接" msgstr "测试连接"
@ -2227,7 +2233,7 @@ msgstr "原因"
#: audits/models.py:101 audits/templates/audits/login_log_list.html:58 #: audits/models.py:101 audits/templates/audits/login_log_list.html:58
#: xpack/plugins/cloud/models.py:171 xpack/plugins/cloud/models.py:188 #: xpack/plugins/cloud/models.py:171 xpack/plugins/cloud/models.py:188
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:70 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:70
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:65 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:67
msgid "Status" msgid "Status"
msgstr "状态" msgstr "状态"
@ -2267,7 +2273,7 @@ msgstr "选择用户"
#: terminal/templates/terminal/command_list.html:60 #: terminal/templates/terminal/command_list.html:60
#: terminal/templates/terminal/session_list.html:61 #: terminal/templates/terminal/session_list.html:61
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:52 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:52
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:48 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:50
msgid "Search" msgid "Search"
msgstr "搜索" msgstr "搜索"
@ -2277,7 +2283,7 @@ msgstr "搜索"
#: ops/templates/ops/task_detail.html:56 #: ops/templates/ops/task_detail.html:56
#: terminal/templates/terminal/session_list.html:70 #: terminal/templates/terminal/session_list.html:70
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:64 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:64
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:60 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:62
msgid "ID" msgid "ID"
msgstr "ID" msgstr "ID"
@ -2679,7 +2685,7 @@ msgid "Become"
msgstr "Become" msgstr "Become"
#: ops/models/adhoc.py:166 users/templates/users/user_group_detail.html:59 #: ops/models/adhoc.py:166 users/templates/users/user_group_detail.html:59
#: xpack/plugins/cloud/templates/cloud/account_detail.html:62 #: xpack/plugins/cloud/templates/cloud/account_detail.html:64
#: xpack/plugins/orgs/templates/orgs/org_detail.html:56 #: xpack/plugins/orgs/templates/orgs/org_detail.html:56
msgid "Create by" msgid "Create by"
msgstr "创建者" msgstr "创建者"
@ -2925,8 +2931,8 @@ msgstr "版本"
#: ops/templates/ops/task_list.html:63 #: ops/templates/ops/task_list.html:63
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:137 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:137
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:53 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:52
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:53 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:52
msgid "Run" msgid "Run"
msgstr "执行" msgstr "执行"
@ -3050,8 +3056,8 @@ msgstr "添加资产"
#: perms/templates/perms/remote_app_permission_remote_app.html:96 #: perms/templates/perms/remote_app_permission_remote_app.html:96
#: perms/templates/perms/remote_app_permission_user.html:96 #: perms/templates/perms/remote_app_permission_user.html:96
#: perms/templates/perms/remote_app_permission_user.html:124 #: perms/templates/perms/remote_app_permission_user.html:124
#: settings/templates/settings/terminal_setting.html:95 #: settings/templates/settings/terminal_setting.html:98
#: settings/templates/settings/terminal_setting.html:117 #: settings/templates/settings/terminal_setting.html:120
#: users/templates/users/user_group_detail.html:95 #: users/templates/users/user_group_detail.html:95
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:93 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_asset_list.html:93
#: xpack/plugins/orgs/templates/orgs/org_detail.html:93 #: xpack/plugins/orgs/templates/orgs/org_detail.html:93
@ -3111,7 +3117,7 @@ msgstr "创建授权规则"
#: perms/templates/perms/asset_permission_list.html:73 #: perms/templates/perms/asset_permission_list.html:73
#: perms/templates/perms/remote_app_permission_list.html:18 #: perms/templates/perms/remote_app_permission_list.html:18
#: users/templates/users/user_list.html:40 xpack/plugins/cloud/models.py:53 #: users/templates/users/user_list.html:40 xpack/plugins/cloud/models.py:53
#: xpack/plugins/cloud/templates/cloud/account_detail.html:58 #: xpack/plugins/cloud/templates/cloud/account_detail.html:60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14 #: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity" msgid "Validity"
msgstr "有效" msgstr "有效"
@ -3246,7 +3252,7 @@ msgid "Create succeed"
msgstr "创建成功" msgstr "创建成功"
#: settings/api.py:166 settings/api.py:204 #: settings/api.py:166 settings/api.py:204
#: settings/templates/settings/terminal_setting.html:151 #: settings/templates/settings/terminal_setting.html:154
msgid "Delete succeed" msgid "Delete succeed"
msgstr "删除成功" msgstr "删除成功"
@ -3484,6 +3490,40 @@ msgid ""
"characters" "characters"
msgstr "开启后,用户密码修改、重置必须包含特殊字符" msgstr "开启后,用户密码修改、重置必须包含特殊字符"
#: settings/forms.py:248
msgid "Create user email subject"
msgstr "创建用户邮件的主题"
#: settings/forms.py:249
msgid ""
"Tips: When creating a user, send the subject of the email (eg:Create account "
"successfully)"
msgstr "提示: 创建用户时,发送设置密码邮件的主题 (例如: 创建用户成功)"
#: settings/forms.py:253
msgid "Create user honorific"
msgstr "创建用户邮件的敬语"
#: settings/forms.py:254
msgid "Tips: When creating a user, send the honorific of the email (eg:Hello)"
msgstr "提示: 创建用户时,发送设置密码邮件的敬语 (例如: 您好)"
#: settings/forms.py:259
msgid "Create user email content"
msgstr "创建用户邮件的内容"
#: settings/forms.py:260
msgid "Tips:When creating a user, send the content of the email"
msgstr "提示: 创建用户时,发送设置密码邮件的内容"
#: settings/forms.py:263
msgid "Signature"
msgstr "署名"
#: settings/forms.py:264
msgid "Tips: Email signature (eg:jumpserver)"
msgstr "提示: 邮件的署名 (例如: jumpserver)"
#: settings/models.py:128 users/templates/users/reset_password.html:68 #: settings/models.py:128 users/templates/users/reset_password.html:68
#: users/templates/users/user_profile.html:20 #: users/templates/users/user_profile.html:20
msgid "Setting" msgid "Setting"
@ -3508,15 +3548,17 @@ msgid "Existing"
msgstr "已存在" msgstr "已存在"
#: settings/templates/settings/basic_setting.html:15 #: settings/templates/settings/basic_setting.html:15
#: settings/templates/settings/email_content_setting.html:15
#: settings/templates/settings/email_setting.html:15 #: settings/templates/settings/email_setting.html:15
#: settings/templates/settings/ldap_setting.html:15 #: settings/templates/settings/ldap_setting.html:15
#: settings/templates/settings/security_setting.html:15 #: settings/templates/settings/security_setting.html:15
#: settings/templates/settings/terminal_setting.html:16 #: settings/templates/settings/terminal_setting.html:16
#: settings/templates/settings/terminal_setting.html:46 settings/views.py:19 #: settings/templates/settings/terminal_setting.html:49 settings/views.py:19
msgid "Basic setting" msgid "Basic setting"
msgstr "基本设置" msgstr "基本设置"
#: settings/templates/settings/basic_setting.html:18 #: settings/templates/settings/basic_setting.html:18
#: settings/templates/settings/email_content_setting.html:18
#: settings/templates/settings/email_setting.html:18 #: settings/templates/settings/email_setting.html:18
#: settings/templates/settings/ldap_setting.html:18 #: settings/templates/settings/ldap_setting.html:18
#: settings/templates/settings/security_setting.html:18 #: settings/templates/settings/security_setting.html:18
@ -3525,27 +3567,39 @@ msgid "Email setting"
msgstr "邮件设置" msgstr "邮件设置"
#: settings/templates/settings/basic_setting.html:21 #: settings/templates/settings/basic_setting.html:21
#: settings/templates/settings/email_content_setting.html:21
#: settings/templates/settings/email_setting.html:21 #: settings/templates/settings/email_setting.html:21
#: settings/templates/settings/ldap_setting.html:21 #: settings/templates/settings/ldap_setting.html:21
#: settings/templates/settings/security_setting.html:21 #: settings/templates/settings/security_setting.html:21
#: settings/templates/settings/terminal_setting.html:24 settings/views.py:71 #: settings/templates/settings/terminal_setting.html:23 settings/views.py:178
msgid "LDAP setting" msgid "Email content setting"
msgstr "LDAP设置" msgstr "邮件内容设置"
#: settings/templates/settings/basic_setting.html:24 #: settings/templates/settings/basic_setting.html:24
#: settings/templates/settings/email_content_setting.html:24
#: settings/templates/settings/email_setting.html:24 #: settings/templates/settings/email_setting.html:24
#: settings/templates/settings/ldap_setting.html:24 #: settings/templates/settings/ldap_setting.html:24
#: settings/templates/settings/security_setting.html:24 #: settings/templates/settings/security_setting.html:24
#: settings/templates/settings/terminal_setting.html:28 settings/views.py:100 #: settings/templates/settings/terminal_setting.html:27 settings/views.py:71
msgid "Terminal setting" msgid "LDAP setting"
msgstr "终端设置" msgstr "LDAP设置"
#: settings/templates/settings/basic_setting.html:27 #: settings/templates/settings/basic_setting.html:27
#: settings/templates/settings/email_content_setting.html:27
#: settings/templates/settings/email_setting.html:27 #: settings/templates/settings/email_setting.html:27
#: settings/templates/settings/ldap_setting.html:27 #: settings/templates/settings/ldap_setting.html:27
#: settings/templates/settings/security_setting.html:27 #: settings/templates/settings/security_setting.html:27
#: settings/templates/settings/security_setting.html:42 #: settings/templates/settings/terminal_setting.html:31 settings/views.py:100
#: settings/templates/settings/terminal_setting.html:31 settings/views.py:152 msgid "Terminal setting"
msgstr "终端设置"
#: settings/templates/settings/basic_setting.html:30
#: settings/templates/settings/email_content_setting.html:30
#: settings/templates/settings/email_setting.html:30
#: settings/templates/settings/ldap_setting.html:30
#: settings/templates/settings/security_setting.html:30
#: settings/templates/settings/security_setting.html:45
#: settings/templates/settings/terminal_setting.html:34 settings/views.py:152
msgid "Security setting" msgid "Security setting"
msgstr "安全设置" msgstr "安全设置"
@ -3561,11 +3615,15 @@ msgstr "索引"
msgid "Doc type" msgid "Doc type"
msgstr "文档类型" msgstr "文档类型"
#: settings/templates/settings/ldap_setting.html:65 #: settings/templates/settings/email_content_setting.html:45
msgid "Create User setting"
msgstr "创建用户设置"
#: settings/templates/settings/ldap_setting.html:68
msgid "Bulk import" msgid "Bulk import"
msgstr "一键导入" msgstr "一键导入"
#: settings/templates/settings/ldap_setting.html:116 #: settings/templates/settings/ldap_setting.html:119
msgid "" msgid ""
"User is not currently selected, please check the user you want to import" "User is not currently selected, please check the user you want to import"
msgstr "当前无勾选用户,请勾选你想要导入的用户" msgstr "当前无勾选用户,请勾选你想要导入的用户"
@ -3627,8 +3685,8 @@ msgstr "端点后缀"
#: settings/templates/settings/replay_storage_create.html:136 #: settings/templates/settings/replay_storage_create.html:136
#: xpack/plugins/cloud/models.py:186 #: xpack/plugins/cloud/models.py:186
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:81 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:83
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:62 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:64
msgid "Region" msgid "Region"
msgstr "地域" msgstr "地域"
@ -3652,48 +3710,48 @@ msgstr "提交中"
msgid "Endpoint need contain protocol, ex: http" msgid "Endpoint need contain protocol, ex: http"
msgstr "端点需要包含协议,如 http" msgstr "端点需要包含协议,如 http"
#: settings/templates/settings/security_setting.html:46 #: settings/templates/settings/security_setting.html:49
msgid "Password check rule" msgid "Password check rule"
msgstr "密码校验规则" msgstr "密码校验规则"
#: settings/templates/settings/terminal_setting.html:76 terminal/forms.py:27 #: settings/templates/settings/terminal_setting.html:79 terminal/forms.py:27
#: terminal/models.py:26 #: terminal/models.py:26
msgid "Command storage" msgid "Command storage"
msgstr "命令存储" msgstr "命令存储"
#: settings/templates/settings/terminal_setting.html:98 terminal/forms.py:32 #: settings/templates/settings/terminal_setting.html:101 terminal/forms.py:32
#: terminal/models.py:27 #: terminal/models.py:27
msgid "Replay storage" msgid "Replay storage"
msgstr "录像存储" msgstr "录像存储"
#: settings/templates/settings/terminal_setting.html:154 #: settings/templates/settings/terminal_setting.html:157
msgid "Delete failed" msgid "Delete failed"
msgstr "删除失败" msgstr "删除失败"
#: settings/templates/settings/terminal_setting.html:159 #: settings/templates/settings/terminal_setting.html:162
msgid "Are you sure about deleting it?" msgid "Are you sure about deleting it?"
msgstr "您确定删除吗?" msgstr "您确定删除吗?"
#: settings/utils.py:69 #: settings/utils.py:71
msgid "User does not exist" msgid "User does not exist"
msgstr "用户不存在" msgstr "用户不存在"
#: settings/utils.py:72 #: settings/utils.py:74
msgid "The user source is not LDAP" msgid "The user source is not LDAP"
msgstr "用户来源不是LDAP" msgstr "用户来源不是LDAP"
#: settings/utils.py:146 #: settings/utils.py:155
msgid "Search no entry matched in ou {}" msgid "Search no entry matched in ou {}"
msgstr "在ou:{}中没有匹配条目" msgstr "在ou:{}中没有匹配条目"
#: settings/views.py:18 settings/views.py:44 settings/views.py:70 #: settings/views.py:18 settings/views.py:44 settings/views.py:70
#: settings/views.py:99 settings/views.py:126 settings/views.py:138 #: settings/views.py:99 settings/views.py:126 settings/views.py:138
#: settings/views.py:151 templates/_nav.html:118 #: settings/views.py:151 settings/views.py:177 templates/_nav.html:118
msgid "Settings" msgid "Settings"
msgstr "系统设置" msgstr "系统设置"
#: settings/views.py:29 settings/views.py:55 settings/views.py:81 #: settings/views.py:29 settings/views.py:55 settings/views.py:81
#: settings/views.py:112 settings/views.py:162 #: settings/views.py:112 settings/views.py:162 settings/views.py:188
msgid "Update setting successfully" msgid "Update setting successfully"
msgstr "更新设置成功" msgstr "更新设置成功"
@ -4464,7 +4522,7 @@ msgstr "安全令牌验证"
#: users/templates/users/_base_otp.html:44 users/templates/users/_user.html:13 #: users/templates/users/_base_otp.html:44 users/templates/users/_user.html:13
#: users/templates/users/user_profile_update.html:51 #: users/templates/users/user_profile_update.html:51
#: xpack/plugins/cloud/models.py:120 #: xpack/plugins/cloud/models.py:120
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:57 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:59
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:13 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:13
msgid "Account" msgid "Account"
msgstr "账户" msgstr "账户"
@ -4572,7 +4630,7 @@ msgid "Always young, always with tears in my eyes. Stay foolish Stay hungry"
msgstr "永远年轻,永远热泪盈眶 stay foolish stay hungry" msgstr "永远年轻,永远热泪盈眶 stay foolish stay hungry"
#: users/templates/users/reset_password.html:46 #: users/templates/users/reset_password.html:46
#: users/templates/users/user_detail.html:373 users/utils.py:77 #: users/templates/users/user_detail.html:373 users/utils.py:98
msgid "Reset password" msgid "Reset password"
msgstr "重置密码" msgstr "重置密码"
@ -4893,55 +4951,60 @@ msgid ""
msgstr "新的公钥已设置成功,请下载对应的私钥" msgstr "新的公钥已设置成功,请下载对应的私钥"
#: users/utils.py:38 #: users/utils.py:38
msgid "Create account successfully"
msgstr "创建账户成功"
#: users/utils.py:40
#, python-format #, python-format
msgid "" msgid ""
"\n" "\n"
" Hello %(name)s:\n" " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
" </br>\n" "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
" Your account has been created successfully\n" " <p style=\"text-indent:2em;\">\n"
" </br>\n" " <span>\n"
" Username: %(username)s\n" " Username: %(username)s.\n"
" </br>\n" " </span>\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">click " " <span>\n"
"here to set your password</a>\n" " <a href=\"%(rest_password_url)s?token=%(rest_password_token)s"
" </br>\n" "\">click here to set your password</a>\n"
" </span> \n"
" <span>\n"
" This link is valid for 1 hour. After it expires, <a href=" " This link is valid for 1 hour. After it expires, <a href="
"\"%(forget_password_url)s?email=%(email)s\">request new one</a>\n" "\"%(forget_password_url)s?email=%(email)s\">request new one</a>\n"
"\n" " </span> \n"
" </br>\n" " <span>\n"
" ---\n"
"\n"
" </br>\n"
" <a href=\"%(login_url)s\">Login direct</a>\n" " <a href=\"%(login_url)s\">Login direct</a>\n"
"\n" " </span>\n"
" </br>\n" " </p>\n"
" " " "
msgstr "" msgstr ""
"\n" "\n"
" 你好 %(name)s:\n" " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
" </br>\n" "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
" 恭喜您,您的账号已经创建成功 </br>\n" " <p style=\"text-indent:2em;\">\n"
" 用户名: %(username)s\n" " <span>\n"
" </br>\n" " 用户名: %(username)s.\n"
" <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">请点击这" " </span>\n"
"里设置密码</a> </br>\n" " <span>\n"
" 这个链接有效期1小时, 超过时间您可以 <a href=\"%(forget_password_url)s?" " <a href=\"%(rest_password_url)s?token=%(rest_password_token)s\">"
"email=%(email)s\">重新申请</a>\n" "请点击这里设置密码</a>\n"
"\n" " </span> \n"
" </br>\n" " <span>\n"
" ---\n" " 这个链接有效期1小时, 超过时间您可以 <a href="
"\n" "\"%(forget_password_url)s?email=%(email)s\">重新申请</a>\n"
" </br>\n" " </span> \n"
" <a href=\"%(login_url)s\">Login direct</a>\n" " <span>\n"
"\n" " <a href=\"%(login_url)s\">---登录页面</a>\n"
" </br>\n" " </span>\n"
" </p>\n"
" " " "
#: users/utils.py:79 #: users/utils.py:73
msgid "Create account successfully"
msgstr "创建账户成功"
#: users/utils.py:77
#, python-format
msgid "Hello %(name)s"
msgstr "您好 %(name)s"
#: users/utils.py:100
#, python-format #, python-format
msgid "" msgid ""
"\n" "\n"
@ -4985,11 +5048,11 @@ msgstr ""
" </br>\n" " </br>\n"
" " " "
#: users/utils.py:110 #: users/utils.py:131
msgid "Security notice" msgid "Security notice"
msgstr "安全通知" msgstr "安全通知"
#: users/utils.py:112 #: users/utils.py:133
#, python-format #, python-format
msgid "" msgid ""
"\n" "\n"
@ -5038,11 +5101,11 @@ msgstr ""
" </br>\n" " </br>\n"
" " " "
#: users/utils.py:148 #: users/utils.py:169
msgid "SSH Key Reset" msgid "SSH Key Reset"
msgstr "重置ssh密钥" msgstr "重置ssh密钥"
#: users/utils.py:150 #: users/utils.py:171
#, python-format #, python-format
msgid "" msgid ""
"\n" "\n"
@ -5067,15 +5130,15 @@ msgstr ""
" </br>\n" " </br>\n"
" " " "
#: users/utils.py:183 #: users/utils.py:204
msgid "User not exist" msgid "User not exist"
msgstr "用户不存在" msgstr "用户不存在"
#: users/utils.py:185 #: users/utils.py:206
msgid "Disabled or expired" msgid "Disabled or expired"
msgstr "禁用或失效" msgstr "禁用或失效"
#: users/utils.py:198 #: users/utils.py:219
msgid "Password or SSH public key invalid" msgid "Password or SSH public key invalid"
msgstr "密码或密钥不合法" msgstr "密码或密钥不合法"
@ -5341,7 +5404,7 @@ msgid "Run plan manually"
msgstr "手动执行计划" msgstr "手动执行计划"
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:179 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_detail.html:179
#: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:102 #: xpack/plugins/change_auth_plan/templates/change_auth_plan/plan_list.html:101
msgid "Execute failed" msgid "Execute failed"
msgstr "执行失败" msgstr "执行失败"
@ -5427,7 +5490,7 @@ msgid "Unavailable"
msgstr "无效" msgstr "无效"
#: xpack/plugins/cloud/models.py:50 #: xpack/plugins/cloud/models.py:50
#: xpack/plugins/cloud/templates/cloud/account_detail.html:54 #: xpack/plugins/cloud/templates/cloud/account_detail.html:56
#: xpack/plugins/cloud/templates/cloud/account_list.html:13 #: xpack/plugins/cloud/templates/cloud/account_list.html:13
msgid "Provider" msgid "Provider"
msgstr "云服务商" msgstr "云服务商"
@ -5453,7 +5516,7 @@ msgid "Instances"
msgstr "实例" msgstr "实例"
#: xpack/plugins/cloud/models.py:126 #: xpack/plugins/cloud/models.py:126
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:73 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:75
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:17 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:17
msgid "Date last sync" msgid "Date last sync"
msgstr "最后同步日期" msgstr "最后同步日期"
@ -5472,7 +5535,7 @@ msgstr ""
#: xpack/plugins/cloud/models.py:173 xpack/plugins/cloud/models.py:189 #: xpack/plugins/cloud/models.py:173 xpack/plugins/cloud/models.py:189
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:71 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:71
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:66 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:68
msgid "Date sync" msgid "Date sync"
msgstr "同步日期" msgstr "同步日期"
@ -5489,8 +5552,8 @@ msgid "Sync instance task history"
msgstr "同步实例任务历史" msgstr "同步实例任务历史"
#: xpack/plugins/cloud/models.py:185 #: xpack/plugins/cloud/models.py:185
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:89 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:91
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:61 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:63
msgid "Instance" msgid "Instance"
msgstr "实例" msgstr "实例"
@ -5510,7 +5573,7 @@ msgstr "AWS (国际)"
msgid "Qcloud" msgid "Qcloud"
msgstr "腾讯云" msgstr "腾讯云"
#: xpack/plugins/cloud/templates/cloud/account_detail.html:20 #: xpack/plugins/cloud/templates/cloud/account_detail.html:22
#: xpack/plugins/cloud/views.py:72 #: xpack/plugins/cloud/views.py:72
msgid "Account detail" msgid "Account detail"
msgstr "账户详情" msgstr "账户详情"
@ -5528,23 +5591,23 @@ msgstr "加载中..."
msgid "Load failed" msgid "Load failed"
msgstr "加载失败" msgstr "加载失败"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:20 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:22
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:25 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:25
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:21 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:23
#: xpack/plugins/cloud/views.py:122 #: xpack/plugins/cloud/views.py:122
msgid "Sync task detail" msgid "Sync task detail"
msgstr "同步任务详情" msgstr "同步任务详情"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:23 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:25
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:28 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:28
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:24 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:26
#: xpack/plugins/cloud/views.py:137 #: xpack/plugins/cloud/views.py:137
msgid "Sync task history" msgid "Sync task history"
msgstr "同步历史列表" msgstr "同步历史列表"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:26 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:28
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:31 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_history.html:31
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:27 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_instance.html:29
#: xpack/plugins/cloud/views.py:188 #: xpack/plugins/cloud/views.py:188
msgid "Sync instance list" msgid "Sync instance list"
msgstr "同步实例列表" msgstr "同步实例列表"
@ -5577,7 +5640,7 @@ msgstr "执行次数"
msgid "Instance count" msgid "Instance count"
msgstr "实例个数" msgstr "实例个数"
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:93 #: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:92
msgid "Sync success" msgid "Sync success"
msgstr "同步成功" msgstr "同步成功"
@ -5661,7 +5724,6 @@ msgid "This will restore default Settings of the interface !!!"
msgstr "您确定要恢复默认初始化吗?" msgstr "您确定要恢复默认初始化吗?"
#: xpack/plugins/interface/templates/interface/interface.html:107 #: xpack/plugins/interface/templates/interface/interface.html:107
#: xpack/plugins/interface/views.py:53
msgid "Restore default successfully." msgid "Restore default successfully."
msgstr "恢复默认成功!" msgstr "恢复默认成功!"
@ -5674,9 +5736,13 @@ msgid "Interface"
msgstr "界面" msgstr "界面"
#: xpack/plugins/interface/views.py:49 #: xpack/plugins/interface/views.py:49
msgid "It is already in the default setting state!" msgid "It is already in the default setting state"
msgstr "当前已经是初始化状态!" msgstr "当前已经是初始化状态!"
#: xpack/plugins/interface/views.py:53
msgid "Restore default successfully"
msgstr "恢复默认成功!"
#: xpack/plugins/license/meta.py:11 xpack/plugins/license/models.py:94 #: xpack/plugins/license/meta.py:11 xpack/plugins/license/models.py:94
#: xpack/plugins/license/templates/license/license_detail.html:50 #: xpack/plugins/license/templates/license/license_detail.html:50
#: xpack/plugins/license/templates/license/license_detail.html:55 #: xpack/plugins/license/templates/license/license_detail.html:55
@ -5817,6 +5883,45 @@ msgstr "更新组织"
#~ msgid "Update user groups" #~ msgid "Update user groups"
#~ msgstr "更新用户组" #~ msgstr "更新用户组"
# msgid "Update user"
# msgstr "更新用户"
#~ msgid ""
#~ "\n"
#~ " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
#~ "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
#~ " <p style=\"text-indent:2em;\">\n"
#~ " <span>\n"
#~ " <a href=\"%(rest_password_url)s?token="
#~ "%(rest_password_token)s\">click here to set your password</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " This link is valid for 1 hour. After it expires, <a href="
#~ "\"%(forget_password_url)s?email=%(email)s\">request new one</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " <a href=\"%(login_url)s\">Login direct</a>\n"
#~ " </span>\n"
#~ " </p>\n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " <link rel=\"stylesheet\" href=\"//maxcdn.bootstrapcdn.com/"
#~ "bootstrap/3.2.0/css/bootstrap.min.css\">\n"
#~ " <p style=\"text-indent:2em;\">\n"
#~ " <span>\n"
#~ " <a href=\"%(rest_password_url)s?token="
#~ "%(rest_password_token)s\">请点击这里设置密码</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " 这个链接有效期1小时, 超过时间您可以, <a href="
#~ "\"%(forget_password_url)s?email=%(email)s\">重新申请</a>\n"
#~ " </span> \n"
#~ " <span>\n"
#~ " <a href=\"%(login_url)s\">Login direct</a>\n"
#~ " </span>\n"
#~ " </p>\n"
#~ " "
#~ msgid "Template" #~ msgid "Template"
#~ msgstr "模板" #~ msgstr "模板"
@ -5851,9 +5956,6 @@ msgstr "更新组织"
#~ msgid "Select host" #~ msgid "Select host"
#~ msgstr "选择资产" #~ msgstr "选择资产"
#~ msgid "Restore default successfully"
#~ msgstr "恢复默认成功!"
#~ msgid "Beijing Duizhan Tech, Inc." #~ msgid "Beijing Duizhan Tech, Inc."
#~ msgstr "北京堆栈科技有限公司" #~ msgstr "北京堆栈科技有限公司"

View File

@ -512,6 +512,7 @@ class UserGrantedRemoteAppsAsTreeApi(ListAPIView):
class ValidateUserRemoteAppPermissionApi(APIView): class ValidateUserRemoteAppPermissionApi(APIView):
permission_classes = (IsOrgAdminOrAppUser,)
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
user_id = request.query_params.get('user_id', '') user_id = request.query_params.get('user_id', '')

View File

@ -79,7 +79,7 @@ class LDAPTestingAPI(APIView):
util = self.get_ldap_util(serializer) util = self.get_ldap_util(serializer)
try: try:
users = util.get_search_user_items() users = util.search_user_items()
except Exception as e: except Exception as e:
return Response({"error": str(e)}, status=401) return Response({"error": str(e)}, status=401)
@ -95,7 +95,7 @@ class LDAPUserListApi(APIView):
def get(self, request): def get(self, request):
util = LDAPUtil() util = LDAPUtil()
try: try:
users = util.get_search_user_items() users = util.search_user_items()
except Exception as e: except Exception as e:
users = [] users = []
logger.error(e, exc_info=True) logger.error(e, exc_info=True)
@ -108,11 +108,11 @@ class LDAPUserSyncAPI(APIView):
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
def post(self, request): def post(self, request):
user_names = request.data.get('user_names', '') username_list = request.data.get('username_list', [])
util = LDAPUtil() util = LDAPUtil()
try: try:
result = util.sync_users(username_set=user_names) result = util.sync_users(username_list)
except Exception as e: except Exception as e:
logger.error(e, exc_info=True) logger.error(e, exc_info=True)
return Response({'error': str(e)}, status=401) return Response({'error': str(e)}, status=401)

View File

@ -242,3 +242,26 @@ class SecuritySettingForm(BaseForm):
'and resets must contain special characters') 'and resets must contain special characters')
) )
class EmailContentSettingForm(BaseForm):
EMAIL_CUSTOM_USER_CREATED_SUBJECT = forms.CharField(
max_length=1024, required=False, label=_("Create user email subject"),
help_text=_("Tips: When creating a user, send the subject of the email"
" (eg:Create account successfully)")
)
EMAIL_CUSTOM_USER_CREATED_HONORIFIC = forms.CharField(
max_length=1024, required=False, label=_("Create user honorific"),
help_text=_("Tips: When creating a user, send the honorific of the "
"email (eg:Hello)")
)
EMAIL_CUSTOM_USER_CREATED_BODY = forms.CharField(
max_length=4096, required=False, widget=forms.Textarea(),
label=_('Create user email content'),
help_text=_('Tips:When creating a user, send the content of the email')
)
EMAIL_CUSTOM_USER_CREATED_SIGNATURE = forms.CharField(
max_length=512, required=False, label=_("Signature"),
help_text=_("Tips: Email signature (eg:jumpserver)")
)

View File

@ -58,6 +58,9 @@ function initLdapUsersTable() {
ele: $('#ldap_list_users_table'), ele: $('#ldap_list_users_table'),
ajax_url: '{% url "api-settings:ldap-user-list" %}', ajax_url: '{% url "api-settings:ldap-user-list" %}',
columnDefs: [ columnDefs: [
{targets: 0, createdCell: function (td, cellData, rowData) {
$(td).html("<input type='checkbox' class='text-center ipt_check' id='ID_USERNAME'>".replace("ID_USERNAME", cellData))
}},
{targets: 4, createdCell: function (td, cellData, rowData) { {targets: 4, createdCell: function (td, cellData, rowData) {
if(cellData){ if(cellData){
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')

View File

@ -17,6 +17,9 @@
<li> <li>
<a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a> <a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li> </li>
<li>
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li>
<li> <li>
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a> <a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a>
</li> </li>

View File

@ -0,0 +1,72 @@
{% extends 'base.html' %}
{% load static %}
{% load bootstrap3 %}
{% load i18n %}
{% load common_tags %}
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="panel-options">
<ul class="nav nav-tabs">
<li>
<a href="{% url 'settings:basic-setting' %}" class="text-center"><i class="fa fa-cubes"></i> {% trans 'Basic setting' %}</a>
</li>
<li>
<a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li>
<li class="active">
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li>
<li>
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a>
</li>
<li>
<a href="{% url 'settings:terminal-setting' %}" class="text-center"><i class="fa fa-hdd-o"></i> {% trans 'Terminal setting' %} </a>
</li>
<li>
<a href="{% url 'settings:security-setting' %}" class="text-center"><i class="fa fa-lock"></i> {% trans 'Security setting' %} </a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="col-sm-12" style="padding-left:0">
<div class="ibox-content" style="border-width: 0;padding-top: 40px;">
<form action="" method="post" class="form-horizontal">
{% if form.non_field_errors %}
<div class="alert alert-danger">
{{ form.non_field_errors }}
</div>
{% endif %}
{% csrf_token %}
<h3>{% trans "Create User setting" %}</h3>
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_SUBJECT layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_HONORIFIC layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_BODY layout="horizontal" %}
{% bootstrap_field form.EMAIL_CUSTOM_USER_CREATED_SIGNATURE layout="horizontal" %}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-default" type="reset"> {% trans 'Reset' %}</button>
<button id="submit_button" class="btn btn-primary" type="submit">{% trans 'Submit' %}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
</script>
{% endblock %}

View File

@ -17,6 +17,9 @@
<li class="active"> <li class="active">
<a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a> <a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li> </li>
<li>
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li>
<li> <li>
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a> <a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a>
</li> </li>

View File

@ -17,6 +17,9 @@
<li> <li>
<a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a> <a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li> </li>
<li>
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li>
<li class="active"> <li class="active">
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a> <a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a>
</li> </li>
@ -107,13 +110,13 @@ $(document).ready(function () {
}); });
}) })
.on("click","#btn_ldap_modal_confirm",function () { .on("click","#btn_ldap_modal_confirm",function () {
var user_names=[]; var username_list=[];
$("tbody input[type='checkbox']:checked").each(function () { $("tbody input[type='checkbox']:checked").each(function () {
user_names.push($(this).attr('id')); username_list.push($(this).attr('id'));
}); });
if (user_names.length === 0){ if (username_list.length === 0){
var msg = "{% trans 'User is not currently selected, please check the user you want to import'%}" var msg = "{% trans 'User is not currently selected, please check the user you want to import'%}";
toastr.error(msg); toastr.error(msg);
return return
} }
@ -129,7 +132,7 @@ $(document).ready(function () {
} }
APIUpdateAttr({ APIUpdateAttr({
url: the_url, url: the_url,
body: JSON.stringify({'user_names':user_names}), body: JSON.stringify({'username_list':username_list}),
method: "POST", method: "POST",
flash_message: false, flash_message: false,
success: success, success: success,

View File

@ -16,6 +16,9 @@
</li> </li>
<li> <li>
<a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a> <a href="{% url 'settings:email-setting' %}" class="text-center"><i class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li>
<li>
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li> </li>
<li> <li>
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a> <a href="{% url 'settings:ldap-setting' %}" class="text-center"><i class="fa fa-archive"></i> {% trans 'LDAP setting' %} </a>

View File

@ -18,6 +18,9 @@
<li> <li>
<a href="{% url 'settings:email-setting' %}" class="text-center"><i <a href="{% url 'settings:email-setting' %}" class="text-center"><i
class="fa fa-envelope"></i> {% trans 'Email setting' %} </a> class="fa fa-envelope"></i> {% trans 'Email setting' %} </a>
</li>
<li>
<a href="{% url 'settings:email-content-setting' %}" class="text-center"><i class="fa fa-file-text"></i> {% trans 'Email content setting' %} </a>
</li> </li>
<li> <li>
<a href="{% url 'settings:ldap-setting' %}" class="text-center"><i <a href="{% url 'settings:ldap-setting' %}" class="text-center"><i

View File

@ -9,6 +9,7 @@ app_name = 'common'
urlpatterns = [ urlpatterns = [
url(r'^$', views.BasicSettingView.as_view(), name='basic-setting'), url(r'^$', views.BasicSettingView.as_view(), name='basic-setting'),
url(r'^email/$', views.EmailSettingView.as_view(), name='email-setting'), url(r'^email/$', views.EmailSettingView.as_view(), name='email-setting'),
url(r'^email-content/$', views.EmailContentSettingView.as_view(), name='email-content-setting'),
url(r'^ldap/$', views.LDAPSettingView.as_view(), name='ldap-setting'), url(r'^ldap/$', views.LDAPSettingView.as_view(), name='ldap-setting'),
url(r'^terminal/$', views.TerminalSettingView.as_view(), name='terminal-setting'), url(r'^terminal/$', views.TerminalSettingView.as_view(), name='terminal-setting'),
url(r'^terminal/replay-storage/create$', views.ReplayStorageCreateView.as_view(), name='replay-storage-create'), url(r'^terminal/replay-storage/create$', views.ReplayStorageCreateView.as_view(), name='replay-storage-create'),

View File

@ -5,7 +5,9 @@ from ldap3 import Server, Connection
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from users.models import User from users.models import User
from users.utils import construct_user_email
from common.utils import get_logger from common.utils import get_logger
from .models import settings from .models import settings
@ -17,11 +19,11 @@ class LDAPOUGroupException(Exception):
class LDAPUtil: class LDAPUtil:
_conn = None
def __init__(self, use_settings_config=True, server_uri=None, bind_dn=None, def __init__(self, use_settings_config=True, server_uri=None, bind_dn=None,
password=None, use_ssl=None, search_ougroup=None, password=None, use_ssl=None, search_ougroup=None,
search_filter=None, attr_map=None, auth_ldap=None): search_filter=None, attr_map=None, auth_ldap=None):
# config # config
if use_settings_config: if use_settings_config:
self._load_config_from_settings() self._load_config_from_settings()
@ -45,6 +47,15 @@ class LDAPUtil:
self.attr_map = settings.AUTH_LDAP_USER_ATTR_MAP self.attr_map = settings.AUTH_LDAP_USER_ATTR_MAP
self.auth_ldap = settings.AUTH_LDAP self.auth_ldap = settings.AUTH_LDAP
@property
def connection(self):
if self._conn is None:
server = Server(self.server_uri, use_ssl=self.use_ssl)
conn = Connection(server, self.bind_dn, self.password)
conn.bind()
self._conn = conn
return self._conn
@staticmethod @staticmethod
def get_user_by_username(username): def get_user_by_username(username):
try: try:
@ -55,70 +66,6 @@ class LDAPUtil:
else: else:
return user return user
@staticmethod
def _update_user(user, user_item):
for field, value in user_item.items():
if not hasattr(user, field):
continue
setattr(user, field, value)
user.save()
def update_user(self, user_item):
user = self.get_user_by_username(user_item['username'])
if not user:
msg = _('User does not exist')
return False, msg
if user.source != User.SOURCE_LDAP:
msg = _('The user source is not LDAP')
return False, msg
try:
self._update_user(user, user_item)
except Exception as e:
logger.error(e, exc_info=True)
return False, str(e)
else:
return True, None
@staticmethod
def create_user(user_item):
user_item['source'] = User.SOURCE_LDAP
try:
User.objects.create(**user_item)
except Exception as e:
logger.error(e, exc_info=True)
return False, str(e)
else:
return True, None
@staticmethod
def get_or_construct_email(user_item):
if not user_item.get('email', None):
if '@' in user_item['username']:
email = user_item['username']
else:
email = '{}@{}'.format(
user_item['username'], settings.EMAIL_SUFFIX)
else:
email = user_item['email']
return email
def create_or_update_users(self, user_items, force_update=True):
succeed = failed = 0
for user_item in user_items:
user_item['email'] = self.get_or_construct_email(user_item)
exist = user_item.pop('existing', None)
if exist:
ok, error = self.update_user(user_item)
else:
ok, error = self.create_user(user_item)
if not ok:
failed += 1
else:
succeed += 1
result = {'total': len(user_items), 'succeed': succeed, 'failed': failed}
return result
def _ldap_entry_to_user_item(self, entry): def _ldap_entry_to_user_item(self, entry):
user_item = {} user_item = {}
for attr, mapping in self.attr_map.items(): for attr, mapping in self.attr_map.items():
@ -127,36 +74,86 @@ class LDAPUtil:
user_item[attr] = getattr(entry, mapping).value or '' user_item[attr] = getattr(entry, mapping).value or ''
return user_item return user_item
def get_connection(self): def search_user_items(self):
server = Server(self.server_uri, use_ssl=self.use_ssl)
conn = Connection(server, self.bind_dn, self.password)
conn.bind()
return conn
def get_search_user_items(self):
conn = self.get_connection()
user_items = [] user_items = []
search_ougroup = str(self.search_ougroup).split("|") for search_ou in str(self.search_ougroup).split("|"):
for search_ou in search_ougroup: ok = self.connection.search(
ok = conn.search(
search_ou, self.search_filter % ({"user": "*"}), search_ou, self.search_filter % ({"user": "*"}),
attributes=list(self.attr_map.values()) attributes=list(self.attr_map.values())
) )
if not ok: if not ok:
error = _("Search no entry matched in ou {}".format(search_ou)) error = _("Search no entry matched in ou {}".format(search_ou))
raise LDAPOUGroupException(error) raise LDAPOUGroupException(error)
for entry in self.connection.entries:
for entry in conn.entries:
user_item = self._ldap_entry_to_user_item(entry) user_item = self._ldap_entry_to_user_item(entry)
user = self.get_user_by_username(user_item['username']) user = self.get_user_by_username(user_item['username'])
user_item['existing'] = bool(user) user_item['existing'] = bool(user)
user_items.append(user_item) user_items.append(user_item)
return user_items return user_items
def sync_users(self, username_set): def search_filter_user_items(self, username_list):
user_items = self.get_search_user_items() user_items = self.search_user_items()
if username_set: if username_list:
user_items = [u for u in user_items if u['username'] in username_set] user_items = [u for u in user_items if u['username'] in username_list]
return user_items
@staticmethod
def save_user(user, user_item):
for field, value in user_item.items():
if not hasattr(user, field):
continue
if isinstance(getattr(user, field), bool):
value = value.lower() in ['true', 1]
setattr(user, field, value)
user.save()
def update_user(self, user_item):
user = self.get_user_by_username(user_item['username'])
if user.source != User.SOURCE_LDAP:
msg = _('The user source is not LDAP')
return False, msg
try:
self.save_user(user, user_item)
except Exception as e:
logger.error(e, exc_info=True)
return False, str(e)
else:
return True, None
def create_user(self, user_item):
user = User(source=User.SOURCE_LDAP)
try:
self.save_user(user, user_item)
except Exception as e:
logger.error(e, exc_info=True)
return False, str(e)
else:
return True, None
@staticmethod
def construct_user_email(user_item):
username = user_item['username']
email = user_item.get('email', '')
email = construct_user_email(username, email)
return email
def create_or_update_users(self, user_items, force_update=True):
succeed = failed = 0
for user_item in user_items:
exist = user_item.pop('existing', False)
user_item['email'] = self.construct_user_email(user_item)
if not exist:
ok, error = self.create_user(user_item)
else:
ok, error = self.update_user(user_item)
if not ok:
failed += 1
else:
succeed += 1
result = {'total': len(user_items), 'succeed': succeed, 'failed': failed}
return result
def sync_users(self, username_list):
user_items = self.search_filter_user_items(username_list)
result = self.create_or_update_users(user_items) result = self.create_or_update_users(user_items)
return result return result

View File

@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _
from common.permissions import SuperUserRequiredMixin from common.permissions import SuperUserRequiredMixin
from common import utils from common import utils
from .forms import EmailSettingForm, LDAPSettingForm, BasicSettingForm, \ from .forms import EmailSettingForm, LDAPSettingForm, BasicSettingForm, \
TerminalSettingForm, SecuritySettingForm TerminalSettingForm, SecuritySettingForm, EmailContentSettingForm
class BasicSettingView(SuperUserRequiredMixin, TemplateView): class BasicSettingView(SuperUserRequiredMixin, TemplateView):
@ -166,3 +166,29 @@ class SecuritySettingView(SuperUserRequiredMixin, TemplateView):
context = self.get_context_data() context = self.get_context_data()
context.update({"form": form}) context.update({"form": form})
return render(request, self.template_name, context) return render(request, self.template_name, context)
class EmailContentSettingView(SuperUserRequiredMixin, TemplateView):
template_name = "settings/email_content_setting.html"
form_class = EmailContentSettingForm
def get_context_data(self, **kwargs):
context = {
'app': _('Settings'),
'action': _('Email content setting'),
'form': self.form_class(),
}
kwargs.update(context)
return super().get_context_data(**kwargs)
def post(self, request):
form = self.form_class(request.POST)
if form.is_valid():
form.save()
msg = _("Update setting successfully")
messages.success(request, msg)
return redirect('settings:email-content-setting')
else:
context = self.get_context_data()
context.update({"form": form})
return render(request, self.template_name, context)

View File

@ -34,29 +34,24 @@ class AdminUserRequiredMixin(UserPassesTestMixin):
return True return True
def send_user_created_mail(user): def construct_user_created_email_body(user):
subject = _('Create account successfully') default_body = _("""
recipient_list = [user.email] <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
message = _(""" <p style="text-indent:2em;">
Hello %(name)s: <span>
</br> Username: %(username)s.
Your account has been created successfully </span>
</br> <span>
Username: %(username)s
</br>
<a href="%(rest_password_url)s?token=%(rest_password_token)s">click here to set your password</a> <a href="%(rest_password_url)s?token=%(rest_password_token)s">click here to set your password</a>
</br> </span>
<span>
This link is valid for 1 hour. After it expires, <a href="%(forget_password_url)s?email=%(email)s">request new one</a> This link is valid for 1 hour. After it expires, <a href="%(forget_password_url)s?email=%(email)s">request new one</a>
</span>
</br> <span>
---
</br>
<a href="%(login_url)s">Login direct</a> <a href="%(login_url)s">Login direct</a>
</span>
</br> </p>
""") % { """) % {
'name': user.name,
'username': user.username, 'username': user.username,
'rest_password_url': reverse('users:reset-password', external=True), 'rest_password_url': reverse('users:reset-password', external=True),
'rest_password_token': user.generate_reset_token(), 'rest_password_token': user.generate_reset_token(),
@ -64,6 +59,32 @@ def send_user_created_mail(user):
'email': user.email, 'email': user.email,
'login_url': reverse('authentication:login', external=True), 'login_url': reverse('authentication:login', external=True),
} }
if settings.EMAIL_CUSTOM_USER_CREATED_BODY:
custom_body = '<p style="text-indent:2em">' + settings.EMAIL_CUSTOM_USER_CREATED_BODY + '</p>'
else:
custom_body = ''
body = custom_body + default_body
return body
def send_user_created_mail(user):
recipient_list = [user.email]
subject = _('Create account successfully')
if settings.EMAIL_CUSTOM_USER_CREATED_SUBJECT:
subject = settings.EMAIL_CUSTOM_USER_CREATED_SUBJECT
honorific = '<p>' + _('Hello %(name)s') % {'name': user.name} + ':</p>'
if settings.EMAIL_CUSTOM_USER_CREATED_HONORIFIC:
honorific = '<p>' + settings.EMAIL_CUSTOM_USER_CREATED_HONORIFIC + ':</p>'
body = construct_user_created_email_body(user)
signature = '<p style="float:right">jumpserver</p>'
if settings.EMAIL_CUSTOM_USER_CREATED_SIGNATURE:
signature = '<p style="float:right">' + settings.EMAIL_CUSTOM_USER_CREATED_SIGNATURE + '</p>'
message = honorific + body + signature
if settings.DEBUG: if settings.DEBUG:
try: try:
print(message) print(message)
@ -313,3 +334,13 @@ def is_need_unblock(key_block):
if not cache.get(key_block): if not cache.get(key_block):
return False return False
return True return True
def construct_user_email(username, email):
if '@' not in email:
if '@' in username:
email = username
else:
email = '{}@{}'.format(username, settings.EMAIL_SUFFIX)
return email