fix(LDAP): 修复LDAP登陆失败的问题
This commit is contained in:
parent
a4ddf766be
commit
613555101e
|
@ -4,6 +4,9 @@ import io.metersphere.base.domain.User;
|
|||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.UserSource;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.RsaKey;
|
||||
import io.metersphere.commons.utils.RsaUtil;
|
||||
import io.metersphere.controller.ResultHolder;
|
||||
import io.metersphere.controller.request.LoginRequest;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
@ -16,6 +19,7 @@ import org.springframework.ldap.core.DirContextOperations;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/ldap")
|
||||
|
@ -29,7 +33,7 @@ public class LdapController {
|
|||
private SystemParameterService systemParameterService;
|
||||
|
||||
@PostMapping(value = "/signin")
|
||||
public ResultHolder login(@RequestBody LoginRequest request) {
|
||||
public ResultHolder login(@RequestBody LoginRequest request) throws NoSuchAlgorithmException {
|
||||
|
||||
String isOpen = systemParameterService.getValue(ParamConstants.LDAP.OPEN.getValue());
|
||||
if (StringUtils.isBlank(isOpen) || StringUtils.equals(Boolean.FALSE.toString(), isOpen)) {
|
||||
|
@ -71,7 +75,8 @@ public class LdapController {
|
|||
|
||||
// 执行 ShiroDBRealm 中 LDAP 登录逻辑
|
||||
LoginRequest loginRequest = new LoginRequest();
|
||||
loginRequest.setUsername(userId);
|
||||
RsaKey rsaKey = CommonBeanFactory.getBean(RsaKey.class);
|
||||
loginRequest.setUsername(RsaUtil.publicEncrypt(userId,rsaKey.getPublicKey()));
|
||||
return userService.login(loginRequest);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue