Skip to content

Commit

Permalink
Merge pull request #215 from erupts/develop
Browse files Browse the repository at this point in the history
1.12.7
  • Loading branch information
erupts authored Nov 12, 2023
2 parents 5c59287 + 0c29a62 commit ea5bcf7
Show file tree
Hide file tree
Showing 55 changed files with 131 additions and 106 deletions.
2 changes: 1 addition & 1 deletion erupt-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-annotation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>
</project>
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-cloud/erupt-cloud-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.CaseInsensitiveMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
Expand All @@ -28,6 +30,7 @@
import xyz.erupt.core.config.GsonFactory;
import xyz.erupt.core.constant.EruptConst;
import xyz.erupt.core.constant.EruptMutualConst;
import xyz.erupt.core.constant.EruptReqHeader;
import xyz.erupt.core.constant.EruptRestPath;
import xyz.erupt.core.context.MetaContext;
import xyz.erupt.core.context.MetaErupt;
Expand All @@ -38,6 +41,7 @@
import xyz.erupt.core.view.EruptModel;
import xyz.erupt.security.interceptor.EruptSecurityInterceptor;
import xyz.erupt.security.service.OperationService;
import xyz.erupt.upms.constant.EruptReqHeaderConst;
import xyz.erupt.upms.constant.SessionKey;
import xyz.erupt.upms.service.EruptContextService;
import xyz.erupt.upms.service.EruptSessionService;
Expand All @@ -49,7 +53,6 @@
import javax.servlet.http.Part;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -101,9 +104,20 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
}
if (null == eruptRouter) return true;
if (EruptRouter.VerifyType.ERUPT == eruptRouter.verifyType()) {
String erupt = request.getHeader(EruptMutualConst.ERUPT);
if (erupt == null) {
erupt = request.getParameter("_" + EruptMutualConst.ERUPT);
String erupt = null;
String authErupt = null;
if (eruptRouter.verifyMethod() == EruptRouter.VerifyMethod.HEADER) {
erupt = request.getHeader(EruptReqHeaderConst.ERUPT_HEADER_KEY);
authErupt = request.getHeader(EruptReqHeaderConst.ERUPT_PARENT_HEADER_KEY);
if (StringUtils.isBlank(authErupt)) {
authErupt = request.getHeader(EruptReqHeaderConst.ERUPT_HEADER_KEY);
}
} else if (eruptRouter.verifyMethod() == EruptRouter.VerifyMethod.PARAM) {
erupt = request.getParameter(EruptReqHeaderConst.URL_ERUPT_PARAM_KEY);
authErupt = request.getParameter(EruptReqHeaderConst.URL_ERUPT_PARENT_PARAM_KEY);
if (StringUtils.isBlank(authErupt)) {
authErupt = request.getParameter(EruptReqHeaderConst.URL_ERUPT_PARAM_KEY);
}
}
if (erupt == null) {
return true;
Expand All @@ -117,7 +131,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
response.sendError(HttpStatus.UNAUTHORIZED.value());
return false;
}
if (null == eruptUserService.getEruptMenuByValue(erupt)) {
if (null == eruptUserService.getEruptMenuByValue(authErupt)) {
response.setStatus(HttpStatus.FORBIDDEN.value());
response.sendError(HttpStatus.FORBIDDEN.value());
return false;
Expand Down Expand Up @@ -179,17 +193,26 @@ public HttpResponse httpProxy(HttpServletRequest request, MetaNode metaNode, Str
count = 0;
}
String location = metaNode.getLocations().toArray(new String[0])[metaNode.getLocations().size() <= 1 ? 0 : (count++ % metaNode.getLocations().size())];
Map<String, String> headers = new HashMap<>();
Map<String, String> headers = new CaseInsensitiveMap<>();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
headers.put(name, request.getHeader(name));
}
headers.remove(HttpHeaders.HOST.toLowerCase());
headers.remove(HttpHeaders.HOST);
headers.put(CloudCommonConst.HEADER_ACCESS_TOKEN, metaNode.getAccessToken());
headers.put(EruptMutualConst.TOKEN, eruptContextService.getCurrentToken());
headers.put(EruptMutualConst.ERUPT, eruptName);
headers.put(EruptMutualConst.USER, Base64Encoder.encode(GsonFactory.getGson().toJson(MetaContext.getUser())));
if (headers.containsKey(EruptReqHeader.DRILL_SOURCE_ERUPT)) {
String dse = headers.get(EruptReqHeader.DRILL_SOURCE_ERUPT);
headers.put(EruptReqHeader.DRILL_SOURCE_ERUPT, dse.substring(dse.lastIndexOf(".") + 1));
}
//process drill header
if (headers.containsKey(EruptReqHeader.DRILL_SOURCE_ERUPT)) {
String dse = headers.get(EruptReqHeader.DRILL_SOURCE_ERUPT);
headers.put(EruptReqHeader.DRILL_SOURCE_ERUPT, dse.substring(dse.lastIndexOf(".") + 1));
}
HttpRequest httpRequest = HttpUtil.createRequest(Method.valueOf(request.getMethod()), location + path + (null == request.getQueryString() ? "" : "?" + request.getQueryString()));
try {
if (null != request.getContentType() && request.getContentType().contains("multipart/form-data")) {
Expand All @@ -211,7 +234,7 @@ private void eruptBuildProcess(EruptBuildModel eruptBuildModel, String nodeName)
eruptBuildModel.getEruptModel().setEruptName(prefix + eruptBuildModel.getEruptModel().getEruptName());
//修改Drill的值
JsonArray drills = eruptBuildModel.getEruptModel().getEruptJson().getAsJsonArray("drills");
if (drills.size() > 0) {
if (!drills.isEmpty()) {
for (JsonElement drill : drills) {
JsonObject link = drill.getAsJsonObject().get("link").getAsJsonObject();
link.addProperty("linkErupt", prefix + link.get("linkErupt").getAsString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
title = "查看令牌", icon = "fa fa-shield", mode = RowOperation.Mode.SINGLE,
show = @ExprBool(exprHandler = ViaMenuValueCtrl.class, params = CloudServerConst.CLOUD_ACCESS_TOKEN_PERMISSION),
type = RowOperation.Type.TPL, tpl = @Tpl(path = "/tpl/node-info.ftl")
), layout = @Layout(tableLeftFixed = 1)
), layout = @Layout(tableLeftFixed = 1, pageSize = 30)
)
@Component
@EruptI18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
let arr = paramsArr[i].split('=')
param[arr[0]] = arr[1];
}
axios.get("/erupt-cloud-api/remove-instance/${row.nodeName}?instance=" + item, {
axios.get("${request.contextPath}/erupt-cloud-api/remove-instance/${row.nodeName}?instance=" + item, {
headers: {
token: param["_token"]
}
Expand Down
2 changes: 1 addition & 1 deletion erupt-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import xyz.erupt.core.constant.EruptConst;
import xyz.erupt.core.exception.EruptApiErrorTip;
import xyz.erupt.core.view.EruptApiModel;
import xyz.erupt.core.view.EruptExceptionVo;
Expand All @@ -19,18 +20,18 @@
* @author YuePeng
* date 2020-09-30
*/
@ControllerAdvice
@Slf4j
@Order(Ordered.LOWEST_PRECEDENCE - 1)
@ControllerAdvice(EruptConst.BASE_PACKAGE)
public class EruptExceptionAdvice {
public static final String API_ERROR = "erupt web api error";

private static final String ERE = "erupt exception";

@ExceptionHandler(EruptApiErrorTip.class)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public EruptApiModel eruptApiErrorTip(EruptApiErrorTip e) {
log.error(API_ERROR, e);
log.error(ERE, e);
e.eruptApiModel.setErrorIntercept(false);
return e.eruptApiModel;
}
Expand Down
2 changes: 1 addition & 1 deletion erupt-data/erupt-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-data/erupt-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-excel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-job/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.EruptI18n;
import xyz.erupt.annotation.constant.AnnotationConst;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class EruptJobLog extends BaseModel {
)
private EruptJob eruptJob;

@Column(length = AnnotationConst.REMARK_LENGTH)
@EruptField(
views = @View(title = "任务参数")
)
Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-magic-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-extra/erupt-monitor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public RedisInfo(RedisConnectionFactory redisConnectionFactory) {
StringUtils.substringBetween(commandStats.getProperty(it), "calls=", ",usec"))).collect(Collectors.toList());
});
Optional.ofNullable(redisConnection.info()).ifPresent(properties -> {
this.setKeyNum(redisConnectionFactory.getConnection().serverCommands().dbSize());
this.setKeyNum(redisConnection.serverCommands().dbSize());
this.setVersion(properties.getProperty("redis_version"));
this.setUsedMem(properties.getProperty("used_memory_human"));
if ("0".equals(properties.getProperty("maxmemory"))) {
Expand All @@ -68,5 +68,6 @@ public RedisInfo(RedisConnectionFactory redisConnectionFactory) {
this.setAOF(Integer.parseInt(aofEnabled) != 0);
}
});
redisConnection.close();
}
}
2 changes: 1 addition & 1 deletion erupt-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion erupt-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.erupt.security.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -36,6 +37,7 @@
*/
@Service
@Order
@Slf4j
public class EruptSecurityInterceptor implements AsyncHandlerInterceptor {

@Resource
Expand All @@ -50,10 +52,6 @@ public class EruptSecurityInterceptor implements AsyncHandlerInterceptor {
@Resource
private OperationService operationService;

private static final String ERUPT_PARENT_HEADER_KEY = "eruptParent";

private static final String ERUPT_PARENT_PARAM_KEY = "_eruptParent";

@Resource
private EruptSessionService sessionService;

Expand All @@ -71,11 +69,11 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
if (eruptRouter.verifyMethod() == EruptRouter.VerifyMethod.HEADER) {
token = request.getHeader(EruptReqHeaderConst.ERUPT_HEADER_TOKEN);
eruptName = request.getHeader(EruptReqHeaderConst.ERUPT_HEADER_KEY);
parentEruptName = request.getHeader(ERUPT_PARENT_HEADER_KEY);
parentEruptName = request.getHeader(EruptReqHeaderConst.ERUPT_PARENT_HEADER_KEY);
} else if (eruptRouter.verifyMethod() == EruptRouter.VerifyMethod.PARAM) {
token = request.getParameter(EruptReqHeaderConst.URL_ERUPT_PARAM_TOKEN);
eruptName = request.getParameter(EruptReqHeaderConst.URL_ERUPT_PARAM_KEY);
parentEruptName = request.getHeader(ERUPT_PARENT_PARAM_KEY);
parentEruptName = request.getHeader(EruptReqHeaderConst.URL_ERUPT_PARENT_PARAM_KEY);
}
if (eruptRouter.verifyType().equals(EruptRouter.VerifyType.ERUPT)) {
MetaContext.register(new MetaErupt(eruptName, eruptName));
Expand Down Expand Up @@ -160,8 +158,7 @@ public void afterCompletion(HttpServletRequest request, HttpServletResponse resp
try {
operationService.record(handler, ex);
} catch (Exception e) {
//TODO 失败后抛出异常(版本兼容原因未抛出)
e.printStackTrace();
log.error("operation record error", e);
} finally {
MetaContext.remove();
}
Expand Down
2 changes: 1 addition & 1 deletion erupt-toolkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>xyz.erupt</groupId>
<artifactId>erupt</artifactId>
<version>1.12.5</version>
<version>1.12.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Loading

0 comments on commit ea5bcf7

Please sign in to comment.