mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
优化Restful接口校验
This commit is contained in:
@@ -70,6 +70,11 @@ public class ApiInfoDTO implements Serializable {
|
||||
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 接口模式,1-open接口,2-Restful模式
|
||||
*/
|
||||
private Integer apiMode;
|
||||
|
||||
public String buildApiNameVersion() {
|
||||
return apiName + apiVersion;
|
||||
}
|
||||
|
@@ -85,6 +85,11 @@ public class ApiInfo {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 接口模式,1-open接口,2-Restful模式
|
||||
*/
|
||||
private Integer apiMode;
|
||||
|
||||
private LocalDateTime addTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
@@ -15,6 +15,7 @@ import com.gitee.sop.gateway.service.manager.IsvApiPermissionManager;
|
||||
import com.gitee.sop.gateway.service.manager.IsvManager;
|
||||
import com.gitee.sop.gateway.service.manager.SecretManager;
|
||||
import com.gitee.sop.gateway.service.manager.dto.IsvDTO;
|
||||
import com.gitee.sop.support.enums.ApiModeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -31,6 +32,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 负责校验,校验工作都在这里
|
||||
@@ -111,6 +113,11 @@ public class ApiValidator implements Validator {
|
||||
ApiInfoDTO apiInfo = apiManager.get(apiRequest.getMethod(), apiRequest.getVersion());
|
||||
// 检查接口信息
|
||||
checkApiInfo(apiRequestContext, apiInfo);
|
||||
|
||||
if (!Objects.equals(apiInfo.getApiMode(), ApiModeEnum.RESTFUL.getValue())) {
|
||||
log.error("Open模式接口不允许使用Restful进行访问, apiInfo={}", apiInfo);
|
||||
throw new ApiException(ErrorEnum.ISV_INVALID_METHOD, apiRequestContext.getLocale());
|
||||
}
|
||||
// IP能否访问
|
||||
checkIP(apiRequestContext);
|
||||
// 检查上传文件
|
||||
|
Reference in New Issue
Block a user