身份源配置验证优化

pull/88/head
awenes 2024-06-12 14:55:44 +08:00
parent 22d689f6d9
commit fe066096c8
3 changed files with 33 additions and 14 deletions

View File

@ -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) {
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 = JSONObject.parseObject(param.getConfig().toJSONString(),
DingTalkConfig.class);
DingTalkConfig config = objectMapper
.readValue(param.getConfig().toJSONString(), DingTalkConfig.class);;
yield new DingTalkConfigValidator().validate(config);
}
case FEISHU -> {
FeiShuConfig config = JSONObject.parseObject(param.getConfig().toJSONString(),
FeiShuConfig.class);
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);
}
}
/**

View File

@ -67,4 +67,7 @@ public class DingTalkConfig extends IdentitySourceConfig {
*/
@JsonPropertyEncrypt
private String token;
public DingTalkConfig() {
}
}

View File

@ -63,4 +63,7 @@ public class FeiShuConfig extends IdentitySourceConfig {
*/
@JsonPropertyEncrypt
private String verificationToken;
public FeiShuConfig() {
}
}