From 47c1c207ea80802332dc7521d10f1ad569ec3e69 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Thu, 20 Dec 2018 19:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BLDAP=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=AE=80=E5=8C=96=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=A1=AB=E5=86=99=E5=B1=9E=E6=80=A7=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../www/teleport/static/js/user/user-list.js | 38 ++++++++----- server/www/teleport/view/user/user-list.mako | 57 +++++++++++++++---- .../www/teleport/webroot/app/base/configs.py | 8 ++- .../teleport/webroot/app/controller/system.py | 25 +++++--- .../teleport/webroot/app/logic/auth/ldap.py | 53 ++++++++++------- 5 files changed, 128 insertions(+), 53 deletions(-) diff --git a/server/www/teleport/static/js/user/user-list.js b/server/www/teleport/static/js/user/user-list.js index 91a8abe..50b6b87 100755 --- a/server/www/teleport/static/js/user/user-list.js +++ b/server/www/teleport/static/js/user/user-list.js @@ -36,7 +36,7 @@ $app.on_init = function (cb_stack) { }; $app.test = function (cb) { - cb.add($app.dlg_ldap_import.show); + cb.add($app.dlg_ldap_config.show); cb.exec(); }; @@ -1256,7 +1256,9 @@ $app.create_dlg_ldap_config = function () { password: '', base_dn: '', filter: '', - attr_map: '' + attr_username: '', + attr_surname: '', + attr_email: '' }; // {"server":"192.168.0.101","port":3892,"domain":"apexnas.com","admin":"cn=admin,dc=apexnas,dc=com","password":"Abcd1234","base_dn":"ou=people,dc=apexnas,dc=com","filter":"(&(objectClass=person))","attr_map":"tp.username = uid\ntp.surname = cn111\ntp.email = mail"} @@ -1269,7 +1271,10 @@ $app.create_dlg_ldap_config = function () { password: $('#edit-ldap-password'), base_dn: $('#edit-ldap-base-dn'), filter: $('#edit-ldap-filter'), - attr_map: $('#edit-ldap-attr-map'), + // attr_map: $('#edit-ldap-attr-map'), + attr_username: $('#edit-ldap-attr-username'), + attr_surname: $('#edit-ldap-attr-surname'), + attr_email: $('#edit-ldap-attr-email'), btn_switch_password: $('#btn-switch-ldap-password'), btn_switch_password_icon: $('#btn-switch-ldap-password i'), @@ -1284,12 +1289,6 @@ $app.create_dlg_ldap_config = function () { dlg.dom.btn_test.click(dlg.do_test); dlg.dom.btn_save.click(dlg.do_save); - // dlg.dom.btn_gen_random_password.click(function () { - // dlg.dom.password.val(tp_gen_password(8)); - // dlg.dom.password.attr('type', 'text'); - // dlg.dom.btn_switch_password_icon.removeClass('fa-eye').addClass('fa-eye-slash') - // }); - dlg.dom.btn_switch_password.click(function () { if ('password' === dlg.dom.password.attr('type')) { dlg.dom.password.attr('type', 'text'); @@ -1317,7 +1316,10 @@ $app.create_dlg_ldap_config = function () { dlg.dom.admin.val(dlg.ldap_config.admin); dlg.dom.base_dn.val(dlg.ldap_config.base_dn); dlg.dom.filter.val(dlg.ldap_config.filter); - dlg.dom.attr_map.text(dlg.ldap_config.attr_map); + // dlg.dom.attr_map.text(dlg.ldap_config.attr_map); + dlg.dom.attr_username.val(dlg.ldap_config.attr_username); + dlg.dom.attr_surname.val(dlg.ldap_config.attr_surname); + dlg.dom.attr_email.val(dlg.ldap_config.attr_email); } }; @@ -1334,7 +1336,10 @@ $app.create_dlg_ldap_config = function () { dlg.ldap_config.admin = dlg.dom.admin.val(); dlg.ldap_config.base_dn = dlg.dom.base_dn.val(); dlg.ldap_config.filter = dlg.dom.filter.val(); - dlg.ldap_config.attr_map = dlg.dom.attr_map.val(); + // dlg.ldap_config.attr_map = dlg.dom.attr_map.val(); + dlg.ldap_config.attr_username = dlg.dom.attr_username.val(); + dlg.ldap_config.attr_surname = dlg.dom.attr_surname.val(); + dlg.ldap_config.attr_email = dlg.dom.attr_email.val(); if (!tp_is_host(dlg.ldap_config.server)) { dlg.dom.server.focus(); @@ -1382,9 +1387,14 @@ $app.create_dlg_ldap_config = function () { $tp.notify_error('请填写LDAP的用户过滤器!'); return false; } - if (tp_is_empty_str(dlg.ldap_config.attr_map)) { - dlg.dom.attr_map.focus(); - $tp.notify_error('请填写LDAP的用户属性与teleport用户属性的映射关系!'); + // if (tp_is_empty_str(dlg.ldap_config.attr_map)) { + // dlg.dom.attr_map.focus(); + // $tp.notify_error('请填写LDAP的用户属性与teleport用户属性的映射关系!'); + // return false; + // } + if (tp_is_empty_str(dlg.ldap_config.attr_username)) { + dlg.dom.attr_username.focus(); + $tp.notify_error('请填写映射为teleport登录账号的LDAP用户属性!'); return false; } diff --git a/server/www/teleport/view/user/user-list.mako b/server/www/teleport/view/user/user-list.mako index 29cf348..dab83ca 100644 --- a/server/www/teleport/view/user/user-list.mako +++ b/server/www/teleport/view/user/user-list.mako @@ -505,8 +505,7 @@
-
限制用户DN的范围,例如 ou=dev,ou=company,ou=com。用户的完整DN为 - cn=用户登录名,用户基准DN。 +
限制用户DN的范围,例如 ou=dev,ou=company,ou=com
@@ -522,14 +521,51 @@
- +
- -
将LDAP的属性映射到 teleport 的用户属性,例如 LDAP中的用户属性 sAMAccountName 映射为teleport的登录账号。如果不清楚此LDAP服务的用户属性,可使用下方的“列举属性”按钮进行查询。 +
将LDAP的属性映射到 teleport 的用户属性,例如 LDAP中的用户属性 sAMAccountName 映射为teleport的登录账号。如果不清楚此LDAP服务的用户属性,可使用下方的“列举属性”按钮进行查询。
+
+
+ +
+ +
+ +
+
+
例如sAMAccountName
+
+ +
+ +
+
+
例如uid。 +
+
+
+
+ +
+ +
+
+
例如mail。 +
+
+
+ + +##
+## +##
+## +##
将LDAP的属性映射到 teleport 的用户属性,例如 LDAP中的用户属性 sAMAccountName 映射为teleport的登录账号。如果不清楚此LDAP服务的用户属性,可使用下方的“列举属性”按钮进行查询。
+##
+##
@@ -537,11 +573,12 @@