forked from github/dataease
commit
97a4c8bd72
@ -14,20 +14,26 @@ import io.dataease.commons.utils.BeanUtils;
|
|||||||
import io.dataease.commons.utils.CodingUtil;
|
import io.dataease.commons.utils.CodingUtil;
|
||||||
import io.dataease.commons.utils.LogUtil;
|
import io.dataease.commons.utils.LogUtil;
|
||||||
import io.dataease.commons.utils.ServletUtils;
|
import io.dataease.commons.utils.ServletUtils;
|
||||||
|
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||||
import io.dataease.exception.DataEaseException;
|
import io.dataease.exception.DataEaseException;
|
||||||
import io.dataease.i18n.Translator;
|
import io.dataease.i18n.Translator;
|
||||||
|
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||||
import io.dataease.plugins.config.SpringContextUtil;
|
import io.dataease.plugins.config.SpringContextUtil;
|
||||||
import io.dataease.plugins.util.PluginUtils;
|
import io.dataease.plugins.util.PluginUtils;
|
||||||
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
|
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
|
||||||
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
||||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||||
|
import io.dataease.service.sys.SysUserService;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,6 +47,10 @@ public class AuthServer implements AuthApi {
|
|||||||
private AuthUserService authUserService;
|
private AuthUserService authUserService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +58,6 @@ public class AuthServer implements AuthApi {
|
|||||||
String username = loginDto.getUsername();
|
String username = loginDto.getUsername();
|
||||||
String password = loginDto.getPassword();
|
String password = loginDto.getPassword();
|
||||||
|
|
||||||
|
|
||||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||||
// 增加ldap登录方式
|
// 增加ldap登录方式
|
||||||
Integer loginType = loginDto.getLoginType();
|
Integer loginType = loginDto.getLoginType();
|
||||||
@ -56,11 +65,18 @@ public class AuthServer implements AuthApi {
|
|||||||
if (loginType == 1 && isSupportLdap) {
|
if (loginType == 1 && isSupportLdap) {
|
||||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||||
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
|
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
|
||||||
ValidateResult validateResult = ldapXpackService.login(request);
|
ValidateResult<XpackLdapUserEntity> validateResult = ldapXpackService.login(request);
|
||||||
if (!validateResult.isSuccess()) {
|
if (!validateResult.isSuccess()) {
|
||||||
DataEaseException.throwException(validateResult.getMsg());
|
DataEaseException.throwException(validateResult.getMsg());
|
||||||
}
|
}
|
||||||
username = validateResult.getUserName();
|
XpackLdapUserEntity ldapUserEntity = validateResult.getData();
|
||||||
|
LdapAddRequest ldapAddRequest = new LdapAddRequest();
|
||||||
|
ldapAddRequest.setUsers(new ArrayList<XpackLdapUserEntity>(){{add(ldapUserEntity);}});
|
||||||
|
ldapAddRequest.setEnabled(1L);
|
||||||
|
ldapAddRequest.setDeptId(1L);
|
||||||
|
ldapAddRequest.setRoleIds(new ArrayList<Long>(){{add(2L);}});
|
||||||
|
sysUserService.saveLdapUsers(ldapAddRequest);
|
||||||
|
username = validateResult.getData().getUserName();
|
||||||
}
|
}
|
||||||
// 增加ldap登录方式
|
// 增加ldap登录方式
|
||||||
|
|
||||||
|
@ -30,7 +30,11 @@ public class XLdapServer {
|
|||||||
@PostMapping("/testConn")
|
@PostMapping("/testConn")
|
||||||
public void testConn() {
|
public void testConn() {
|
||||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||||
ldapXpackService.testConn();
|
try {
|
||||||
|
ldapXpackService.testConn();
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/users")
|
@PostMapping("/users")
|
||||||
|
@ -26,9 +26,9 @@ UPDATE `chart_view` SET `y_axis_ext` = '[]';
|
|||||||
|
|
||||||
|
|
||||||
ALTER TABLE `sys_user` ADD COLUMN `from` int(4) NOT NULL COMMENT '来源' AFTER `language`;
|
ALTER TABLE `sys_user` ADD COLUMN `from` int(4) NOT NULL COMMENT '来源' AFTER `language`;
|
||||||
|
-- ----------------------------
|
||||||
INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
|
-- INSERT INTO `sys_menu` VALUES (60, 1, 0, 1, '导入LDAP用户', 'system-user-import', 'system/user/imp-ldap', 11, NULL, 'user-ldap', b'0', b'0', b'1', 'user:import', NULL, NULL, NULL, NULL);
|
||||||
|
-- ----------------------------
|
||||||
BEGIN;
|
BEGIN;
|
||||||
INSERT INTO `system_parameter` VALUES ('ldap.url', NULL, 'text', 1);
|
INSERT INTO `system_parameter` VALUES ('ldap.url', NULL, 'text', 1);
|
||||||
INSERT INTO `system_parameter` VALUES ('ldap.dn', NULL, 'text', 2);
|
INSERT INTO `system_parameter` VALUES ('ldap.dn', NULL, 'text', 2);
|
||||||
|
@ -523,7 +523,7 @@ export default {
|
|||||||
input_url_placeholder: 'Please key url (like ldap://localhost:389)',
|
input_url_placeholder: 'Please key url (like ldap://localhost:389)',
|
||||||
input_ou_placeholder: 'Please key OU ',
|
input_ou_placeholder: 'Please key OU ',
|
||||||
input_filter_placeholder: 'Please key filter',
|
input_filter_placeholder: 'Please key filter',
|
||||||
input_mapping_placeholder: 'like:{"username":"uid","name":"sn","email":"mail"}',
|
input_mapping_placeholder: 'like:{"userName":"uid","nickName":"cn","email":"mail"}',
|
||||||
test_connect: 'Test connect',
|
test_connect: 'Test connect',
|
||||||
edit: 'Edit',
|
edit: 'Edit',
|
||||||
login_success: 'Login success',
|
login_success: 'Login success',
|
||||||
|
@ -525,7 +525,7 @@ export default {
|
|||||||
input_url_placeholder: '請輸入LDAP地址 (如 ldap://localhost:389)',
|
input_url_placeholder: '請輸入LDAP地址 (如 ldap://localhost:389)',
|
||||||
input_ou_placeholder: '輸入用戶OU (使用|分隔各OU)',
|
input_ou_placeholder: '輸入用戶OU (使用|分隔各OU)',
|
||||||
input_filter_placeholder: '輸入過濾器 [可能的選項是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
|
input_filter_placeholder: '輸入過濾器 [可能的選項是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
|
||||||
input_mapping_placeholder: '如:{"username":"uid","name":"sn","email":"mail"}, username映射的選項可能是cn或uid或sAMAccountName',
|
input_mapping_placeholder: '如:{"userName":"uid","nickName":"cn","email":"mail"}, username映射的選項可能是cn或uid或sAMAccountName',
|
||||||
test_connect: '測試連接',
|
test_connect: '測試連接',
|
||||||
test_login: '測試登錄',
|
test_login: '測試登錄',
|
||||||
edit: '編輯',
|
edit: '編輯',
|
||||||
|
@ -525,7 +525,7 @@ export default {
|
|||||||
input_url_placeholder: '请输入LDAP地址 (如 ldap://localhost:389)',
|
input_url_placeholder: '请输入LDAP地址 (如 ldap://localhost:389)',
|
||||||
input_ou_placeholder: '输入用户OU (使用|分隔各OU)',
|
input_ou_placeholder: '输入用户OU (使用|分隔各OU)',
|
||||||
input_filter_placeholder: '输入过滤器 [可能的选项是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
|
input_filter_placeholder: '输入过滤器 [可能的选项是cn或uid或sAMAccountName={0}, 如:(uid={0})]',
|
||||||
input_mapping_placeholder: '如:{"username":"uid","name":"sn","email":"mail"}, username映射的选项可能是cn或uid或sAMAccountName',
|
input_mapping_placeholder: '如:{"userName":"uid","nickName":"cn","email":"mail"}, username映射的选项可能是cn或uid或sAMAccountName',
|
||||||
test_connect: '测试连接',
|
test_connect: '测试连接',
|
||||||
test_login: '测试登录',
|
test_login: '测试登录',
|
||||||
edit: '编辑',
|
edit: '编辑',
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<el-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('user.create') }}</el-button>
|
<el-button v-permission="['user:add']" icon="el-icon-circle-plus-outline" @click="create">{{ $t('user.create') }}</el-button>
|
||||||
|
|
||||||
<!-- <el-button v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
|
<!-- <el-button v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
|
||||||
<el-button v-if="openLdap" v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button>
|
<!-- <el-button v-if="openLdap" v-permission="['user:import']" icon="el-icon-download" @click="importLdap">{{ $t('user.import_ldap') }}</el-button> -->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-table-column prop="username" label="ID" />
|
<el-table-column prop="username" label="ID" />
|
||||||
|
Loading…
Reference in New Issue
Block a user