Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9d9716

Browse files
authored
Merge branch 'dev' into fix/app_search
2 parentse6415d2 +3a7fe83 commitb9d9716

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

‎server/api-service/lowcoder-infra/src/main/java/org/lowcoder/infra/constant/NewUrl.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ private NewUrl() {
3434
publicstaticfinalStringMATERIAL_URL =PREFIX +"/materials";
3535
publicstaticfinalStringCONTACT_SYNC =PREFIX +"/sync";
3636
publicstaticfinalStringNPM_REGISTRY =PREFIX +"/npm";
37+
38+
publicstaticfinalStringPLUGINS_URL =PREFIX +"/plugins";
3739
}

‎server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/exception/BizError.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum BizError {
1111

1212
// 5000 - 5100 general errorCode
1313
INTERNAL_SERVER_ERROR(500,5000,VERBOSE),
14-
NOT_AUTHORIZED(500,5001),
14+
NOT_AUTHORIZED(401,5001),
1515
INVALID_PARAMETER(500,5002),
1616
UNSUPPORTED_OPERATION(400,5003),
1717
DUPLICATE_KEY(409,5004,VERBOSE),
@@ -113,6 +113,7 @@ public enum BizError {
113113
PLUGIN_EXECUTION_TIMEOUT(504,5800),
114114
INVALID_DATASOURCE_TYPE(500,5801),
115115
PLUGIN_EXECUTION_TIMEOUT_WITHOUT_TIME(504,5802,VERBOSE),
116+
PLUGIN_ENDPOINT_ERROR(500,5850),
116117

117118
// business related, code range 5900 - 5999
118119
NOT_RELEASE(423,5901),

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/exception/GlobalExceptionHandler.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
importjava.util.Map;
99
importjava.util.concurrent.TimeoutException;
1010

11+
importorg.apache.commons.lang3.StringUtils;
1112
importorg.lowcoder.api.framework.view.ResponseView;
13+
importorg.lowcoder.infra.constant.NewUrl;
1214
importorg.lowcoder.infra.util.LogUtils;
1315
importorg.lowcoder.sdk.exception.BaseException;
1416
importorg.lowcoder.sdk.exception.BizError;
@@ -26,6 +28,7 @@
2628
importorg.springframework.web.bind.annotation.ExceptionHandler;
2729
importorg.springframework.web.bind.annotation.ResponseBody;
2830
importorg.springframework.web.bind.support.WebExchangeBindException;
31+
importorg.springframework.web.server.ResponseStatusException;
2932
importorg.springframework.web.server.ServerWebExchange;
3033
importorg.springframework.web.server.ServerWebInputException;
3134

@@ -133,6 +136,23 @@ public Mono<ResponseView<?>> catchServerException(ServerException e, ServerWebEx
133136
});
134137
}
135138

139+
@ExceptionHandler
140+
@ResponseBody
141+
publicMono<ResponseView<?>>catchResponseStatusException(ResponseStatusExceptione,ServerWebExchangeexchange) {
142+
if (StringUtils.startsWith(exchange.getRequest().getPath().toString(),NewUrl.PLUGINS_URL +"/")) {
143+
BizErrorbizError =BizError.PLUGIN_ENDPOINT_ERROR;
144+
exchange.getResponse().setStatusCode(e.getStatusCode());
145+
returnMono.deferContextual(ctx -> {
146+
apiPerfHelper.perf(bizError,exchange.getRequest().getPath());
147+
doLog(e,ctx,bizError.logVerbose());
148+
returnMono.just(error(bizError.getBizErrorCode(),e.getMessage() +" - path: " +exchange.getRequest().getPath()));
149+
});
150+
151+
}else {
152+
returncatchException(e,exchange);
153+
}
154+
}
155+
136156
@ExceptionHandler
137157
@ResponseBody
138158
publicMono<ResponseView<?>>catchException(java.lang.Exceptione,ServerWebExchangeexchange) {

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/plugin/endpoint/PluginEndpointHandlerImpl.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ public Mono<ServerResponse> runPluginEndpointMethod(PluginEndpoint endpoint, End
132132
});
133133

134134
returndecisionMono.<EndpointResponse>handle((authorizationDecision,sink) -> {
135-
if(!authorizationDecision.isGranted())sink.error(newBizException(NOT_AUTHORIZED,"NOT_AUTHORIZED"));
135+
if(!authorizationDecision.isGranted()) {
136+
sink.error(newBizException(NOT_AUTHORIZED,"NOT_AUTHORIZED"));
137+
return;
138+
}
136139
try {
137140
sink.next((EndpointResponse)handler.invoke(endpoint,PluginServerRequest.fromServerRequest(request)));
138141
}catch (IllegalAccessException |InvocationTargetExceptione) {

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/plugin/security/PluginAuthorizationManager.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ public PluginAuthorizationManager()
3131
publicMono<AuthorizationDecision>check(Mono<Authentication>authentication,MethodInvocationinvocation)
3232
{
3333
log.info("Checking plugin reactive endpoint invocation security for {}",invocation.getMethod().getName());
34-
34+
3535
EndpointExtensionendpointExtension = (EndpointExtension)invocation.getArguments()[1];
3636
if (endpointExtension ==null ||StringUtils.isBlank(endpointExtension.authorize()))
3737
{
38-
returnMono.empty();
38+
log.debug("Authorization expression is empty, proceeding without authorization - authorization granted.");
39+
returnMono.just(newAuthorizationDecision(true));
3940
}
4041

4142
ExpressionauthorizeExpression =this.expressionHandler.getExpressionParser()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp