Fix route forbidden not take effect
This commit is contained in:
@@ -408,7 +408,7 @@ public class ApiConfigService implements ApplicationListener<ContextRefreshedEve
|
||||
if (clientCanAccess.isEmpty()) {
|
||||
StringBuilder b = ThreadContext.getStringBuilder();
|
||||
// b.append("app ").append(app).append(" can't access ").append(JacksonUtils.writeValueAsString(apiConfigs));
|
||||
b.append("app ").append(app).append(" can't access matching route");
|
||||
b.append("app ").append(app).append(" can't access matching routes");
|
||||
return Result.fail(b.toString());
|
||||
}
|
||||
ApiConfig bestOne = clientCanAccess.get(0);
|
||||
@@ -431,7 +431,13 @@ public class ApiConfigService implements ApplicationListener<ContextRefreshedEve
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.succ(bestOne);
|
||||
if (bestOne.allowAccess) {
|
||||
return Result.succ(bestOne);
|
||||
} else {
|
||||
StringBuilder b = ThreadContext.getStringBuilder();
|
||||
b.append("app ").append(app).append(" can't access matching route");
|
||||
return Result.fail(b.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public Mono<Result<ApiConfig>> auth(ServerWebExchange exchange) {
|
||||
|
||||
@@ -122,48 +122,48 @@ public class ServiceConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPathPattern(Map<String, Set<ApiConfig>> pathPattern2apiConfigMap, boolean dedicatedLineRequest, String path, ArrayList<ApiConfig> result) {
|
||||
Set<Map.Entry<String, Set<ApiConfig>>> entries = pathPattern2apiConfigMap.entrySet();
|
||||
// boolean clear = false;
|
||||
for (Map.Entry<String, Set<ApiConfig>> entry : entries) {
|
||||
String pathPattern = entry.getKey();
|
||||
Set<ApiConfig> apiConfigs = entry.getValue();
|
||||
if (pathPattern.equals(path)) {
|
||||
for (ApiConfig ac : apiConfigs) {
|
||||
if (ac.allowAccess) {
|
||||
/*if (!clear && !result.isEmpty()) {
|
||||
result.clear();
|
||||
clear = true;
|
||||
}*/
|
||||
if (dedicatedLineRequest) {
|
||||
if (ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
} else {
|
||||
if (!ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
private void checkPathPattern(Map<String, Set<ApiConfig>> pathPattern2apiConfigMap, boolean dedicatedLineRequest, String path, ArrayList<ApiConfig> result) {
|
||||
Set<Map.Entry<String, Set<ApiConfig>>> entries = pathPattern2apiConfigMap.entrySet();
|
||||
// boolean clear = false;
|
||||
for (Map.Entry<String, Set<ApiConfig>> entry : entries) {
|
||||
String pathPattern = entry.getKey();
|
||||
Set<ApiConfig> apiConfigs = entry.getValue();
|
||||
if (pathPattern.equals(path)) {
|
||||
for (ApiConfig ac : apiConfigs) {
|
||||
// if (ac.allowAccess) {
|
||||
/*if (!clear && !result.isEmpty()) {
|
||||
result.clear();
|
||||
clear = true;
|
||||
}*/
|
||||
if (dedicatedLineRequest) {
|
||||
if (ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
} else {
|
||||
if (!ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*if (clear && !result.isEmpty()) {
|
||||
return;
|
||||
}*/
|
||||
} else if (UrlTransformUtils.ANT_PATH_MATCHER.match(pathPattern, path)) {
|
||||
for (ApiConfig ac : apiConfigs) {
|
||||
if (ac.allowAccess) {
|
||||
if (dedicatedLineRequest) {
|
||||
if (ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
} else {
|
||||
if (!ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
} // end for
|
||||
}
|
||||
/*if (clear && !result.isEmpty()) {
|
||||
return;
|
||||
}*/
|
||||
} else if (UrlTransformUtils.ANT_PATH_MATCHER.match(pathPattern, path)) {
|
||||
for (ApiConfig ac : apiConfigs) {
|
||||
// if (ac.allowAccess) {
|
||||
if (dedicatedLineRequest) {
|
||||
if (ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
} else {
|
||||
if (!ac.dedicatedLine) {
|
||||
result.add(ac);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user