mirror of
https://github.com/dataease/dataease.git
synced 2026-05-23 22:08:34 +08:00
@@ -14,20 +14,26 @@ import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import io.dataease.plugins.xpack.ldap.dto.request.LdapValidateRequest;
|
||||
import io.dataease.plugins.xpack.ldap.dto.response.ValidateResult;
|
||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||
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.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -41,6 +47,10 @@ public class AuthServer implements AuthApi {
|
||||
private AuthUserService authUserService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -48,7 +58,6 @@ public class AuthServer implements AuthApi {
|
||||
String username = loginDto.getUsername();
|
||||
String password = loginDto.getPassword();
|
||||
|
||||
|
||||
String pwd = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, password);
|
||||
// 增加ldap登录方式
|
||||
Integer loginType = loginDto.getLoginType();
|
||||
@@ -56,11 +65,18 @@ public class AuthServer implements AuthApi {
|
||||
if (loginType == 1 && isSupportLdap) {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
LdapValidateRequest request = LdapValidateRequest.builder().userName(username).password(pwd).build();
|
||||
ValidateResult validateResult = ldapXpackService.login(request);
|
||||
ValidateResult<XpackLdapUserEntity> validateResult = ldapXpackService.login(request);
|
||||
if (!validateResult.isSuccess()) {
|
||||
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登录方式
|
||||
|
||||
|
||||
@@ -30,7 +30,11 @@ public class XLdapServer {
|
||||
@PostMapping("/testConn")
|
||||
public void testConn() {
|
||||
LdapXpackService ldapXpackService = SpringContextUtil.getBean(LdapXpackService.class);
|
||||
ldapXpackService.testConn();
|
||||
try {
|
||||
ldapXpackService.testConn();
|
||||
}catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@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`;
|
||||
|
||||
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;
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.url', NULL, 'text', 1);
|
||||
INSERT INTO `system_parameter` VALUES ('ldap.dn', NULL, 'text', 2);
|
||||
|
||||
Reference in New Issue
Block a user