Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
7ea03801
Commit
7ea03801
authored
Mar 22, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
[Update] 修改翻译
parents
15179d24
ce8f4b4a
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
445 additions
and
84 deletions
+445
-84
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+96
-47
api.py
apps/settings/api.py
+35
-6
_ldap_list_users_modal.html
apps/settings/templates/settings/_ldap_list_users_modal.html
+90
-0
ldap_setting.html
apps/settings/templates/settings/ldap_setting.html
+30
-1
api_urls.py
apps/settings/urls/api_urls.py
+2
-0
utils.py
apps/settings/utils.py
+152
-0
login-image.jpg
apps/static/img/login/login-image.jpg
+0
-0
login_image_1.png
apps/static/img/login/login_image_1.png
+0
-0
_modal.html
apps/templates/_modal.html
+2
-2
new_login.html
apps/users/templates/users/new_login.html
+38
-28
No files found.
apps/locale/zh/LC_MESSAGES/django.mo
View file @
7ea03801
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
7ea03801
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-22 15:
45
+0800\n"
"POT-Creation-Date: 2019-03-22 15:
57
+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -153,6 +153,7 @@ msgstr "SSH网关,支持代理SSH,RDP和VNC"
#: perms/templates/perms/asset_permission_list.html:53
#: perms/templates/perms/asset_permission_list.html:72
#: perms/templates/perms/asset_permission_user.html:54 settings/models.py:29
#: settings/templates/settings/_ldap_list_users_modal.html:35
#: settings/templates/settings/command_storage_create.html:41
#: settings/templates/settings/replay_storage_create.html:44
#: settings/templates/settings/terminal_setting.html:80
...
...
@@ -187,9 +188,10 @@ msgstr "名称"
#: assets/templates/assets/system_user_list.html:30 audits/models.py:94
#: audits/templates/audits/login_log_list.html:51 authentication/forms.py:11
#: ops/models/adhoc.py:164 perms/templates/perms/asset_permission_list.html:74
#: perms/templates/perms/asset_permission_user.html:55 users/forms.py:13
#: perms/templates/perms/asset_permission_user.html:55
#: settings/templates/settings/_ldap_list_users_modal.html:34 users/forms.py:13
#: users/models/user.py:52 users/templates/users/_select_user_modal.html:14
#: users/templates/users/login.html:64 users/templates/users/new_login.html:
85
#: users/templates/users/login.html:64 users/templates/users/new_login.html:
110
#: users/templates/users/user_detail.html:67
#: users/templates/users/user_list.html:24
#: users/templates/users/user_profile.html:47
...
...
@@ -205,7 +207,7 @@ msgstr "密码或密钥密码"
#: assets/templates/assets/_asset_user_auth_modal.html:21
#: authentication/forms.py:13 settings/forms.py:103 users/forms.py:15
#: users/forms.py:27 users/templates/users/login.html:67
#: users/templates/users/new_login.html:
90
#: users/templates/users/new_login.html:
113
#: users/templates/users/reset_password.html:53
#: users/templates/users/user_create.html:10
#: users/templates/users/user_password_authentication.html:18
...
...
@@ -572,7 +574,7 @@ msgid "Regex"
msgstr "正则表达式"
#: assets/models/cmd_filter.py:39 ops/models/command.py:21
#: ops/templates/ops/command_execution_list.html:6
0
terminal/models.py:161
#: ops/templates/ops/command_execution_list.html:6
1
terminal/models.py:161
#: terminal/templates/terminal/command_list.html:55
#: terminal/templates/terminal/command_list.html:71
#: terminal/templates/terminal/session_detail.html:48
...
...
@@ -677,8 +679,8 @@ msgstr "默认资产组"
#: audits/templates/audits/operate_log_list.html:66
#: audits/templates/audits/password_change_log_list.html:33
#: audits/templates/audits/password_change_log_list.html:50
#: ops/templates/ops/command_execution_list.html:3
4
#: ops/templates/ops/command_execution_list.html:
59
perms/forms.py:36
#: ops/templates/ops/command_execution_list.html:3
5
#: ops/templates/ops/command_execution_list.html:
60
perms/forms.py:36
#: perms/models.py:28
#: perms/templates/perms/asset_permission_create_update.html:41
#: perms/templates/perms/asset_permission_list.html:54
...
...
@@ -1796,7 +1798,7 @@ msgstr "文件名"
#: audits/models.py:23 audits/models.py:90
#: audits/templates/audits/ftp_log_list.html:76
#: ops/templates/ops/command_execution_list.html:6
4
#: ops/templates/ops/command_execution_list.html:6
5
#: ops/templates/ops/task_list.html:31
#: users/templates/users/user_detail.html:458 xpack/plugins/cloud/api.py:62
msgid "Success"
...
...
@@ -1895,7 +1897,7 @@ msgstr "登录日期"
#: audits/templates/audits/ftp_log_list.html:77
#: ops/templates/ops/adhoc_history.html:52
#: ops/templates/ops/adhoc_history_detail.html:61
#: ops/templates/ops/command_execution_list.html:6
5
#: ops/templates/ops/command_execution_list.html:6
6
#: ops/templates/ops/task_history.html:58 perms/models.py:34
#: perms/templates/perms/asset_permission_detail.html:86 terminal/models.py:165
#: terminal/templates/terminal/session_list.html:78
...
...
@@ -1911,8 +1913,8 @@ msgstr "选择用户"
#: audits/templates/audits/login_log_list.html:40
#: audits/templates/audits/operate_log_list.html:58
#: audits/templates/audits/password_change_log_list.html:42
#: ops/templates/ops/command_execution_list.html:4
2
#: ops/templates/ops/command_execution_list.html:4
7
#: ops/templates/ops/command_execution_list.html:4
3
#: ops/templates/ops/command_execution_list.html:4
8
#: ops/templates/ops/task_list.html:13 ops/templates/ops/task_list.html:18
#: templates/_base_list.html:43 templates/_header_bar.html:8
#: terminal/templates/terminal/command_list.html:60
...
...
@@ -1987,7 +1989,7 @@ msgid "Command execution log"
msgstr "命令执行"
#: authentication/api/auth.py:46 users/templates/users/login.html:52
#: users/templates/users/new_login.html:
71
#: users/templates/users/new_login.html:
97
msgid "Log in frequently and try again later"
msgstr "登录频繁, 稍后重试"
...
...
@@ -2189,7 +2191,7 @@ msgid "Options"
msgstr "选项"
#: ops/models/adhoc.py:161 ops/templates/ops/adhoc_detail.html:53
#: ops/templates/ops/command_execution_list.html:5
8
#: ops/templates/ops/command_execution_list.html:5
9
#: ops/templates/ops/task_adhoc.html:59 ops/templates/ops/task_list.html:30
#: settings/templates/settings/command_storage_create.html:49
msgid "Hosts"
...
...
@@ -2285,7 +2287,7 @@ msgstr "执行历史"
#: ops/templates/ops/adhoc_detail.html:72
#: ops/templates/ops/adhoc_detail.html:77
#: ops/templates/ops/command_execution_list.html:6
1
#: ops/templates/ops/command_execution_list.html:6
2
#: ops/templates/ops/task_adhoc.html:61
msgid "Run as"
msgstr "运行用户"
...
...
@@ -2342,7 +2344,7 @@ msgid "Run history detail"
msgstr "执行历史详情"
#: ops/templates/ops/adhoc_history_detail.html:22
#: ops/templates/ops/command_execution_list.html:6
2
#: ops/templates/ops/command_execution_list.html:6
3
#: terminal/backends/command/models.py:16
msgid "Output"
msgstr "输出"
...
...
@@ -2408,7 +2410,7 @@ msgstr "没有选择系统用户"
msgid "Pending"
msgstr ""
#: ops/templates/ops/command_execution_list.html:6
3
#: ops/templates/ops/command_execution_list.html:6
4
msgid "Finished"
msgstr "结束"
...
...
@@ -2639,33 +2641,38 @@ msgstr "资产授权用户列表"
msgid "Asset permission asset list"
msgstr "资产授权资产列表"
#: settings/api.py:2
4
#: settings/api.py:2
3
msgid "Test mail sent to {}, please check"
msgstr "邮件已经发送{}, 请检查"
#: settings/api.py:4
8
#: settings/api.py:4
7
msgid "Test ldap success"
msgstr "连接LDAP成功"
#: settings/api.py:7
8
#: settings/api.py:7
7 settings/utils.py:23
msgid "Search no entry matched in ou {}"
msgstr "在ou:{}中没有匹配条目"
#: settings/api.py:8
7
#: settings/api.py:8
6
msgid "Match {} s users"
msgstr "匹配 {} 个用户"
#: settings/api.py:110 settings/api.py:146
#: settings/api.py:109
msgid ""
"User is not currently selected, please check the user you want to import"
msgstr "当前无勾选用户,请勾选你想要导入的用户"
#: settings/api.py:139 settings/api.py:175
msgid ""
"Error: Account invalid (Please make sure the information such as Access key "
"or Secret key is correct)"
msgstr "错误:账户无效 (请确保 Access key 或 Secret key 等信息正确)"
#: settings/api.py:1
16 settings/api.py:152
#: settings/api.py:1
45 settings/api.py:181
msgid "Create succeed"
msgstr "创建成功"
#: settings/api.py:1
34 settings/api.py:172
#: settings/api.py:1
63 settings/api.py:201
#: settings/templates/settings/terminal_setting.html:151
msgid "Delete succeed"
msgstr "删除成功"
...
...
@@ -2913,6 +2920,20 @@ msgstr "开启后,用户密码修改、重置必须包含特殊字符"
msgid "Setting"
msgstr "设置"
#: settings/templates/settings/_ldap_list_users_modal.html:7
msgid "Ldap users"
msgstr "Ldap 用户列表"
#: settings/templates/settings/_ldap_list_users_modal.html:36
#: users/models/user.py:56 users/templates/users/user_detail.html:71
#: users/templates/users/user_profile.html:59
msgid "Email"
msgstr "邮件"
#: settings/templates/settings/_ldap_list_users_modal.html:37
msgid "Is imported"
msgstr "是否已经导入"
#: settings/templates/settings/basic_setting.html:15
#: settings/templates/settings/email_setting.html:15
#: settings/templates/settings/ldap_setting.html:15
...
...
@@ -2967,6 +2988,10 @@ msgstr "索引"
msgid "Doc type"
msgstr "文档类型"
#: settings/templates/settings/ldap_setting.html:65
msgid "Sync User"
msgstr "同步用户"
#: settings/templates/settings/replay_storage_create.html:66
msgid "Bucket"
msgstr "桶名称"
...
...
@@ -3067,6 +3092,43 @@ msgstr "删除失败"
msgid "Are you sure about deleting it?"
msgstr "您确定删除吗?"
#: settings/utils.py:30
msgid "Have user but attr mapping error"
msgstr "有用户但attr映射错误"
#: settings/utils.py:60
msgid "No"
msgstr "否"
#: settings/utils.py:69
msgid "Yes"
msgstr "是"
#: settings/utils.py:134
msgid ""
"Import {} users successfully; import {} users failed, the database already "
"exists with the same name"
msgstr "导入 {} 个用户成功; 导入 {} 这些用户失败,数据库已经存在同名的用户"
#: settings/utils.py:139
msgid ""
"Import {} users successfully; import {} users failed, the database already "
"exists with the same name; import {}users failed, Because’TypeError' object "
"has no attribute 'keys'"
msgstr ""
"导入 {} 个用户成功; 导入 {} 这些用户失败,数据库已经存在同名的用户; 导入 {} "
"这些用户失败,因为对象没有属性'keys'"
#: settings/utils.py:145
msgid "Import {} users successfully"
msgstr "导入 {} 个用户成功"
#: settings/utils.py:148
msgid ""
"Import {} users successfully;import {} users failed, Because’TypeError' "
"object has no attribute 'keys'"
msgstr "导入 {} 个用户成功; 导入 {} 这些用户失败,因为对象没有属性'keys'"
#: 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:151 templates/_nav.html:107
...
...
@@ -3126,7 +3188,7 @@ msgid "Logout"
msgstr "注销登录"
#: templates/_header_bar.html:101 users/templates/users/login.html:46
#: users/templates/users/login.html:72 users/templates/users/new_login.html:
96
#: users/templates/users/login.html:72 users/templates/users/new_login.html:
119
msgid "Login"
msgstr "登录"
...
...
@@ -3276,7 +3338,7 @@ msgstr "验证码"
#: templates/flash_message_standalone.html:35
#: users/templates/users/login.html:27 users/templates/users/login_otp.html:27
#: users/templates/users/new_login.html:
56
#: users/templates/users/new_login.html:
82
#: users/templates/users/reset_password.html:25
#: xpack/plugins/interface/models.py:36
msgid "Welcome to the Jumpserver open source fortress"
...
...
@@ -3760,11 +3822,6 @@ msgstr "启用"
msgid "Force enable"
msgstr "强制启用"
#: users/models/user.py:56 users/templates/users/user_detail.html:71
#: users/templates/users/user_profile.html:59
msgid "Email"
msgstr "邮件"
#: users/models/user.py:67
msgid "Avatar"
msgstr "头像"
...
...
@@ -3888,7 +3945,7 @@ msgstr "获取更多信息"
#: users/templates/users/forgot_password.html:11
#: users/templates/users/forgot_password.html:31
#: users/templates/users/login.html:83 users/templates/users/new_login.html:1
00
#: users/templates/users/login.html:83 users/templates/users/new_login.html:1
23
msgid "Forgot password"
msgstr "忘记密码"
...
...
@@ -3928,11 +3985,11 @@ msgstr ""
msgid "Changes the world, starting with a little bit."
msgstr "改变世界,从一点点开始。"
#: users/templates/users/login.html:54 users/templates/users/new_login.html:
73
#: users/templates/users/login.html:54 users/templates/users/new_login.html:
99
msgid "The user password has expired"
msgstr "用户密码已过期"
#: users/templates/users/login.html:57 users/templates/users/new_login.html:
76
#: users/templates/users/login.html:57 users/templates/users/new_login.html:
102
msgid "Captcha invalid"
msgstr "验证码错误"
...
...
@@ -3972,7 +4029,7 @@ msgstr "6位数字"
msgid "Can't provide security? Please contact the administrator!"
msgstr "如果不能提供MFA验证码,请联系管理员!"
#: users/templates/users/new_login.html:
61
#: users/templates/users/new_login.html:
87
msgid "Welcome back, please enter username and password to login"
msgstr "欢迎回来,请输入用户名和密码登录"
...
...
@@ -4846,10 +4903,14 @@ msgid "Image of login page"
msgstr "登录页面图片"
#: xpack/plugins/interface/forms.py:27
#, fuzzy
#| msgid ""
#| "Tips: This will be displayed on the enterprise user login page. (suggest "
#| "image size: 492px*472px)"
msgid ""
"Tips: This will be displayed on the enterprise user login page. (suggest "
"image size: 635px*472px)"
msgstr "提示:将会显示在企业版用户登录页面(建议图片大小为:
635
px*472px)"
msgstr "提示:将会显示在企业版用户登录页面(建议图片大小为:
492
px*472px)"
#: xpack/plugins/interface/forms.py:33 xpack/plugins/interface/models.py:23
msgid "Website icon"
...
...
@@ -5023,9 +5084,6 @@ msgstr "创建组织"
msgid "Update org"
msgstr "更新组织"
#~ msgid "Command log"
#~ msgstr "命令日志"
#~ msgid "Cycle perform"
#~ msgstr "周期执行"
...
...
@@ -5108,12 +5166,6 @@ msgstr "更新组织"
#~ msgid "Length"
#~ msgstr "长度"
#~ msgid "Yes"
#~ msgstr "是"
#~ msgid "No"
#~ msgstr "否"
#~ msgid "History of plan"
#~ msgstr "执行历史"
...
...
@@ -5268,9 +5320,6 @@ msgstr "更新组织"
#~ msgid "* required Must set exact system platform, Windows, Linux ..."
#~ msgstr "* required 必须准确设置操作系统平台,如Windows, Linux ..."
#~ msgid "Unblock user successfully. "
#~ msgstr "解除登录限制成功"
#~ msgid "Clear"
#~ msgstr "清除"
...
...
apps/settings/api.py
View file @
7ea03801
...
...
@@ -5,17 +5,16 @@ import os
import
json
import
jms_storage
from
rest_framework.views
import
Response
,
APIView
from
ldap3
import
Server
,
Connection
from
rest_framework.views
import
Response
,
APIView
from
django.conf
import
settings
from
django.core.mail
import
send_mail
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.conf
import
settings
from
common.permissions
import
IsOrgAdmin
,
IsSuperUser
from
.serializers
import
(
MailTestSerializer
,
LDAPTestSerializer
)
from
.models
import
Setting
from
.utils
import
get_ldap_users_list
,
save_user
from
common.permissions
import
IsOrgAdmin
,
IsSuperUser
from
.serializers
import
MailTestSerializer
,
LDAPTestSerializer
class
MailTestingAPI
(
APIView
):
...
...
@@ -91,6 +90,36 @@ class LDAPTestingAPI(APIView):
return
Response
({
"error"
:
str
(
serializer
.
errors
)},
status
=
401
)
class
LDAPSyncAPI
(
APIView
):
permission_classes
=
(
IsOrgAdmin
,)
def
get
(
self
,
request
):
ldap_users_list
=
get_ldap_users_list
()
if
not
isinstance
(
ldap_users_list
,
list
):
return
Response
(
ldap_users_list
,
status
=
401
)
return
Response
(
ldap_users_list
)
class
LDAPConfirmSyncAPI
(
APIView
):
permission_classes
=
(
IsOrgAdmin
,)
def
post
(
self
,
request
):
user_names
=
request
.
data
.
get
(
'user_names'
,
''
)
if
not
user_names
:
error
=
_
(
'User is not currently selected, please check the user '
'you want to import'
)
return
Response
({
'error'
:
error
},
status
=
401
)
ldap_users_list
=
get_ldap_users_list
(
user_names
=
user_names
)
if
not
isinstance
(
ldap_users_list
,
list
):
return
Response
(
ldap_users_list
,
status
=
401
)
save_result
=
save_user
(
ldap_users_list
)
if
'error'
in
save_result
.
keys
():
return
Response
(
save_result
,
status
=
401
)
return
Response
(
save_result
)
class
ReplayStorageCreateAPI
(
APIView
):
permission_classes
=
(
IsSuperUser
,)
...
...
apps/settings/templates/settings/_ldap_list_users_modal.html
0 → 100644
View file @
7ea03801
{% extends '_modal.html' %}
{% load i18n %}
{% load static %}
{% block modal_class %}modal-lg{% endblock %}
{% block modal_id %}ldap_list_users_modal{% endblock %}
{% block modal_title%}{% trans "Ldap users" %}{% endblock %}
{% block modal_body %}
<link
href=
"{% static 'css/plugins/ztree/awesomeStyle/awesome.css' %}"
rel=
"stylesheet"
>
<script
type=
"text/javascript"
src=
"{% static 'js/plugins/ztree/jquery.ztree.all.min.js' %}"
></script>
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
<style>
.inmodal
.modal-header
{
padding
:
10px
10px
;
text-align
:
center
;
}
#assetTree2
.ztree
*
{
background-color
:
#f8fafb
;
}
#assetTree2
.ztree
{
background-color
:
#f8fafb
;
}
</style>
<div
class=
"wrapper wrapper-content"
>
<div
class=
"row"
>
<div
class=
"col-lg-12 animated fadeInRight"
id=
"split-right"
>
<div
class=
"mail-box-header"
>
<table
class=
"table table-striped table-bordered table-hover "
id=
"ldap_list_users_table"
style=
"width: 100%"
>
<thead>
<tr>
<th
class=
"text-center"
><input
type=
"checkbox"
class=
"ipt_check_all"
></th>
<th
class=
"text-center"
>
{% trans 'Username' %}
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Email' %}
</th>
<th
class=
"text-center"
>
{% trans 'Is imported' %}
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
var
ldap_users_table
=
0
;
function
initLdapTable
()
{
if
(
ldap_users_table
){
return
}
var
options
=
{
ele
:
$
(
'#ldap_list_users_table'
),
ajax_url
:
'{% url "api-settings:ldap-sync" %}'
,
columns
:
[
{
data
:
"username"
},{
data
:
"username"
},
{
data
:
"name"
},
{
data
:
"email"
},
{
data
:
'is_imported'
}
],
pageLength
:
10
};
ldap_users_table
=
jumpserver
.
initDataTable
(
options
);
return
ldap_users_table
}
$
(
document
).
ready
(
function
(){
}).
on
(
'show.bs.modal'
,
function
()
{
initLdapTable
();
})
.
on
(
'click'
,
'.close_btn1'
,
function
()
{
window
.
location
.
reload
()
})
.
on
(
'click'
,
'.close_btn2'
,
function
()
{
window
.
location
.
reload
()
})
</script>
{% endblock %}
{% block modal_button %}
{{ block.super }}
{% endblock %}
{% block modal_confirm_id %}btn_ldap_modal_confirm{% endblock %}
apps/settings/templates/settings/ldap_setting.html
View file @
7ea03801
...
...
@@ -31,7 +31,7 @@
<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"
>
<form
id=
"ldap_form"
action=
""
method=
"post"
class=
"form-horizontal"
>
{% if form.non_field_errors %}
<div
class=
"alert alert-danger"
>
{{ form.non_field_errors }}
...
...
@@ -61,6 +61,8 @@
<button
class=
"btn btn-default btn-test"
type=
"button"
>
{% trans 'Test connection' %}
</button>
<button
class=
"btn btn-default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
{#
<button
class=
"btn btn-primary sync_button "
data-toggle=
"modal"
data-target=
"#sync_users_modal"
type=
"button"
>
{% trans 'Synchronization' %}
</button>
#}
<button
class=
"btn btn-primary sync_button "
data-toggle=
"modal"
data-target=
"#ldap_list_users_modal"
type=
"button"
>
{% trans 'Sync User' %}
</button>
</div>
</div>
</form>
...
...
@@ -72,10 +74,12 @@
</div>
</div>
</div>
{% include 'settings/_ldap_list_users_modal.html' %}
{% endblock %}
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
})
.
on
(
"click"
,
".btn-test"
,
function
()
{
var
data
=
{};
...
...
@@ -102,5 +106,30 @@ $(document).ready(function () {
error
:
error
});
})
.
on
(
"click"
,
"#btn_ldap_modal_confirm"
,
function
()
{
var
user_names
=
[];
var
cheked
=
$
(
"tbody input[type='checkbox']:checked"
).
each
(
function
()
{
user_names
.
push
(
$
(
this
).
attr
(
'id'
));
});
var
the_url
=
"{% url "
api
-
settings
:
ldap
-
comfirm
-
sync
" %}"
;
function
error
(
message
)
{
toastr
.
error
(
message
)
}
function
success
(
message
)
{
toastr
.
success
(
message
.
msg
)
}
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
({
'user_names'
:
user_names
}),
method
:
"POST"
,
flash_message
:
false
,
success
:
success
,
error
:
error
});
})
</script>
{% endblock %}
apps/settings/urls/api_urls.py
View file @
7ea03801
...
...
@@ -9,6 +9,8 @@ app_name = 'common'
urlpatterns
=
[
path
(
'mail/testing/'
,
api
.
MailTestingAPI
.
as_view
(),
name
=
'mail-testing'
),
path
(
'ldap/testing/'
,
api
.
LDAPTestingAPI
.
as_view
(),
name
=
'ldap-testing'
),
path
(
'ldap/sync/'
,
api
.
LDAPSyncAPI
.
as_view
(),
name
=
'ldap-sync'
),
path
(
'ldap/comfirm/sync/'
,
api
.
LDAPConfirmSyncAPI
.
as_view
(),
name
=
'ldap-comfirm-sync'
),
path
(
'terminal/replay-storage/create/'
,
api
.
ReplayStorageCreateAPI
.
as_view
(),
name
=
'replay-storage-create'
),
path
(
'terminal/replay-storage/delete/'
,
api
.
ReplayStorageDeleteAPI
.
as_view
(),
name
=
'replay-storage-delete'
),
path
(
'terminal/command-storage/create/'
,
api
.
CommandStorageCreateAPI
.
as_view
(),
name
=
'command-storage-create'
),
...
...
apps/settings/utils.py
0 → 100644
View file @
7ea03801
# -*- coding: utf-8 -*-
#
from
ldap3
import
Server
,
Connection
from
django.utils.translation
import
ugettext_lazy
as
_
from
.models
import
settings
from
users.models
import
User
def
ldap_conn
(
host
,
use_ssl
,
bind_dn
,
password
):
server
=
Server
(
host
,
use_ssl
=
use_ssl
)
conn
=
Connection
(
server
,
bind_dn
,
password
)
return
conn
def
ldap_search
(
conn
,
search_ougroup
,
search_filter
,
attr_map
,
user_names
=
None
):
users_list
=
[]
for
search_ou
in
str
(
search_ougroup
)
.
split
(
"|"
):
ok
=
conn
.
search
(
search_ou
,
search_filter
%
({
"user"
:
"*"
}),
attributes
=
list
(
attr_map
.
values
()))
if
not
ok
:
error
=
_
(
"Search no entry matched in ou {}"
)
.
format
(
search_ou
)
return
{
"error"
:
error
}
ldap_map_users
(
conn
,
attr_map
,
users_list
,
user_names
)
if
len
(
users_list
)
>
0
:
return
users_list
return
{
"error"
:
_
(
"Have user but attr mapping error"
)}
def
get_ldap_users_list
(
user_names
=
None
):
ldap_setting
=
get_ldap_setting
()
conn
=
ldap_conn
(
ldap_setting
[
'host'
],
ldap_setting
[
'use_ssl'
],
ldap_setting
[
'bind_dn'
],
ldap_setting
[
'password'
])
try
:
conn
.
bind
()
except
Exception
as
e
:
return
{
"error"
:
str
(
e
)}
result_search
=
ldap_search
(
conn
,
ldap_setting
[
'search_ougroup'
],
ldap_setting
[
'search_filter'
],
ldap_setting
[
'attr_map'
],
user_names
=
user_names
)
return
result_search
def
ldap_map_users
(
conn
,
attr_map
,
users
,
user_names
=
None
):
for
entry
in
conn
.
entries
:
user
=
entry_user
(
entry
,
attr_map
)
if
user_names
:
if
user
.
get
(
'username'
,
''
)
in
user_names
:
users
.
append
(
user
)
else
:
users
.
append
(
user
)
def
entry_user
(
entry
,
attr_map
):
user
=
{}
user
[
'is_imported'
]
=
_
(
'No'
)
for
attr
,
mapping
in
attr_map
.
items
():
if
not
hasattr
(
entry
,
mapping
):
continue
value
=
getattr
(
entry
,
mapping
)
.
value
user
[
attr
]
=
value
if
value
else
''
if
attr
!=
'username'
:
continue
if
User
.
objects
.
filter
(
username
=
user
[
attr
]):
user
[
'is_imported'
]
=
_
(
'Yes'
)
return
user
def
get_ldap_setting
():
host
=
settings
.
AUTH_LDAP_SERVER_URI
bind_dn
=
settings
.
AUTH_LDAP_BIND_DN
password
=
settings
.
AUTH_LDAP_BIND_PASSWORD
use_ssl
=
settings
.
AUTH_LDAP_START_TLS
search_ougroup
=
settings
.
AUTH_LDAP_SEARCH_OU
search_filter
=
settings
.
AUTH_LDAP_SEARCH_FILTER
attr_map
=
settings
.
AUTH_LDAP_USER_ATTR_MAP
auth_ldap
=
settings
.
AUTH_LDAP
ldap_setting
=
{
'host'
:
host
,
'bind_dn'
:
bind_dn
,
'password'
:
password
,
'search_ougroup'
:
search_ougroup
,
'search_filter'
:
search_filter
,
'attr_map'
:
attr_map
,
'auth_ldap'
:
auth_ldap
,
'use_ssl'
:
use_ssl
,
}
return
ldap_setting
def
save_user
(
users
):
exist
=
[]
username_list
=
[
item
.
get
(
'username'
)
for
item
in
users
]
for
name
in
username_list
:
if
User
.
objects
.
filter
(
username
=
name
)
.
exclude
(
source
=
'ldap'
):
exist
.
append
(
name
)
users
=
[
user
for
user
in
users
if
(
user
.
get
(
'username'
)
not
in
exist
)]
result_save
=
save
(
users
,
exist
)
return
result_save
def
save
(
users
,
exist
):
fail_user
=
[]
for
item
in
users
:
item
=
set_default_item
(
item
)
user
=
User
.
objects
.
filter
(
username
=
item
[
'username'
],
source
=
'ldap'
)
user
=
user
.
first
()
if
not
user
:
try
:
user
=
User
.
objects
.
create
(
**
item
)
except
Exception
as
e
:
fail_user
.
append
(
item
.
get
(
'username'
))
continue
for
key
,
value
in
item
.
items
():
user
.
key
=
value
user
.
save
()
get_msg
=
get_messages
(
users
,
exist
,
fail_user
)
return
get_msg
def
set_default_item
(
item
):
item
[
'source'
]
=
'ldap'
if
not
item
.
get
(
'email'
,
''
):
item
[
'email'
]
=
item
[
'username'
]
+
'@'
+
item
[
'username'
]
+
'.com'
if
'is_imported'
in
item
.
keys
():
item
.
pop
(
'is_imported'
)
return
item
def
get_messages
(
users
,
exist
,
fail_user
):
if
exist
:
info
=
_
(
"Import {} users successfully; import {} users failed, the "
"database already exists with the same name"
)
msg
=
info
.
format
(
len
(
users
),
str
(
exist
))
if
fail_user
:
info
=
_
(
"Import {} users successfully; import {} users failed, "
"the database already exists with the same name; import {}"
"users failed, Because’TypeError' object has no attribute "
"'keys'"
)
msg
=
info
.
format
(
len
(
users
)
-
len
(
fail_user
),
str
(
exist
),
str
(
fail_user
))
else
:
msg
=
_
(
"Import {} users successfully"
)
.
format
(
len
(
users
))
if
fail_user
:
info
=
_
(
"Import {} users successfully;import {} users failed, "
"Because’TypeError' object has no attribute 'keys'"
)
msg
=
info
.
format
(
len
(
users
)
-
len
(
fail_user
),
str
(
fail_user
))
return
{
'msg'
:
msg
}
\ No newline at end of file
apps/static/img/login/login-image.jpg
deleted
100644 → 0
View file @
15179d24
120 KB
apps/static/img/login/login_image_1.png
0 → 100644
View file @
7ea03801
188 KB
apps/templates/_modal.html
View file @
7ea03801
...
...
@@ -8,7 +8,7 @@
<div
class=
"modal-dialog {% block modal_class %}{% endblock %}"
>
<div
class=
"modal-content animated fadeIn"
>
<div
class=
"modal-header"
>
<button
data-dismiss=
"modal"
class=
"close"
type=
"button"
><span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
>
Close
</span></button>
<button
data-dismiss=
"modal"
class=
"close
close_btn1
"
type=
"button"
><span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
>
Close
</span></button>
<h4
class=
"modal-title"
>
{% block modal_title %}{% endblock %}
</h4>
<small>
{% block modal_comment %}{% endblock %}
</small>
</div>
...
...
@@ -18,7 +18,7 @@
</div>
<div
class=
"modal-footer"
>
{% block modal_button %}
<button
data-dismiss=
"modal"
class=
"btn btn-white"
type=
"button"
>
{% trans "Close" %}
</button>
<button
data-dismiss=
"modal"
class=
"btn btn-white
close_btn2
"
type=
"button"
>
{% trans "Close" %}
</button>
<button
class=
"btn btn-primary"
type=
"button"
id=
"{% block modal_confirm_id %}{% endblock %}"
>
{% trans 'Confirm' %}
</button>
{% endblock %}
</div>
...
...
apps/users/templates/users/new_login.html
View file @
7ea03801
...
...
@@ -32,27 +32,53 @@
<script
src=
"{% static 'js/bootstrap.min.js' %}"
></script>
<script
src=
"{% static 'js/plugins/datatables/datatables.min.js' %}"
></script>
{#
<script
src=
"{% static 'js/angular.min.js' %}"
></script>
#}
<style>
.box-1
{
height
:
472px
;
width
:
984px
;
margin-right
:
auto
;
margin-left
:
auto
;
margin-top
:
calc
((
100vh
-
470px
)/
2
);
}
.box-2
{
height
:
100%
;
width
:
50%
;
float
:
right
;
}
.box-3
{
text-align
:
center
;
background-color
:
white
;
height
:
100%
;
width
:
50%
;
}
.captcha
{
float
:
right
;
}
</style>
</head>
<body>
<div
class=
"login-dialog"
>
<div
class=
""
>
<div
class=
"row"
style=
"height: 472px"
>
<div
class=
"col-md-4 col-md-offset-2 input_shadow-1"
style=
"text-align: center;background-color: white; padding-right: 0px;height: 100%"
>
<body
style=
"height: 100%"
>
<div>
<div
class=
"box-1"
>
<div
class=
"box-2"
>
{% if interface.login_image %}
<img
src=
"{{ MEDIA_URL }}{{ interface.login_image }}"
style=
"height: 100%; width: 100%"
/>
{% else %}
<img
src=
"{% static 'img/login/login_image_1.png' %}"
style=
" height: 100%; width: 100%"
/>
{% endif %}
</div>
<div
class=
"box-3"
>
<div
style=
"background-color: white"
>
{% if interface.login_title %}
<div
style=
"margin-top: 40px
"
>
<div
style=
"margin-top: 40px;padding-top: 50px;
"
>
<span
style=
"font-size: 24px;font-weight:400;color: #151515;letter-spacing: 0;"
>
{{ interface.login_title }}
</span>
</div>
{% else %}
<div
style=
"margin-top: 40px
"
>
<div
style=
"margin-top: 40px;padding-top: 50px;
"
>
<span
style=
"font-size: 24px;font-weight:400;color: #151515;letter-spacing: 0;"
>
{% trans 'Welcome to the Jumpserver open source fortress' %}
</span>
</div>
{% endif %}
...
...
@@ -81,15 +107,12 @@
</div>
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
value=
"{% if form.username.value %}{{ form.username.value }}{% endif %}"
style=
"height: 35px"
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
value=
"{% if form.username.value %}{{ form.username.value }}{% endif %}"
style=
"height: 35px"
>
</div>
<div
class=
"form-group"
>
<input
type=
"password"
class=
"form-control"
name=
"{{ form.password.html_name }}"
placeholder=
"{% trans 'Password' %}"
required=
""
>
<input
type=
"password"
class=
"form-control"
name=
"{{ form.password.html_name }}"
placeholder=
"{% trans 'Password' %}"
required=
""
>
</div>
<div
class=
"form-group"
style=
"height: 50px;margin-bottom: 0px
"
>
<div
class=
"form-group"
style=
"height: 50px;margin-bottom: 0
"
>
{{ form.captcha }}
</div>
<div
class=
"form-group"
style=
"margin-top: 10px"
>
...
...
@@ -104,23 +127,11 @@
</div>
<div
class=
"col-md-1"
></div>
</div>
</div>
</div>
</div>
<div
class=
"col-md-4 "
style=
"padding-left: 0px; height: 100%"
>
{% if interface.login_image %}
<img
src=
"{{ MEDIA_URL }}{{ interface.login_image }}"
style=
"width: 100%; height: 100%;"
class=
"input_shadow-1"
/>
{% else %}
<img
src=
"{% static 'img/login/login-image.jpg' %}"
style=
"width: 100%; height: 100%;"
class=
"input_shadow-1"
/>
{% endif %}
</div>
</div>
<div
class=
"col-md-2"
></div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment