mirror of https://gitee.com/topiam/eiam
⚡ 身份源配置验证优化
parent
22d689f6d9
commit
fe066096c8
|
@ -20,6 +20,11 @@ package cn.topiam.employee.console.service.identitysource.impl;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
@ -245,20 +250,28 @@ public class IdentitySourceServiceImpl implements IdentitySourceService {
|
|||
*/
|
||||
@Override
|
||||
public Boolean identitySourceConfigValidator(IdentitySourceConfigValidatorParam param) {
|
||||
return switch (param.getProvider()) {
|
||||
//钉钉
|
||||
case DINGTALK -> {
|
||||
DingTalkConfig config = JSONObject.parseObject(param.getConfig().toJSONString(),
|
||||
DingTalkConfig.class);
|
||||
yield new DingTalkConfigValidator().validate(config);
|
||||
}
|
||||
case FEISHU -> {
|
||||
FeiShuConfig config = JSONObject.parseObject(param.getConfig().toJSONString(),
|
||||
FeiShuConfig.class);
|
||||
yield new FeiShuConfigValidator().validate(config);
|
||||
}
|
||||
default -> throw new TopIamException("暂未支持此提供商连接验证");
|
||||
};
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
try {
|
||||
return switch (param.getProvider()) {
|
||||
//钉钉
|
||||
case DINGTALK -> {
|
||||
DingTalkConfig config = objectMapper
|
||||
.readValue(param.getConfig().toJSONString(), DingTalkConfig.class);;
|
||||
yield new DingTalkConfigValidator().validate(config);
|
||||
}
|
||||
case FEISHU -> {
|
||||
FeiShuConfig config = objectMapper
|
||||
.readValue(param.getConfig().toJSONString(), FeiShuConfig.class);
|
||||
yield new FeiShuConfigValidator().validate(config);
|
||||
}
|
||||
default -> throw new TopIamException("暂未支持此提供商连接验证");
|
||||
};
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,4 +67,7 @@ public class DingTalkConfig extends IdentitySourceConfig {
|
|||
*/
|
||||
@JsonPropertyEncrypt
|
||||
private String token;
|
||||
|
||||
public DingTalkConfig() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,4 +63,7 @@ public class FeiShuConfig extends IdentitySourceConfig {
|
|||
*/
|
||||
@JsonPropertyEncrypt
|
||||
private String verificationToken;
|
||||
|
||||
public FeiShuConfig() {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue