Skip to content

Commit 2016029

Browse files
Thomasludomikula
Thomas
authored andcommitted
add check for published/marketplace app to anonymous user
1 parent e5211e2 commit 2016029

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/application/ApplicationApiServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,12 @@ private Mono<Boolean> updateApplicationStatus(String applicationId, ApplicationS
246246

247247
@Override
248248
public Mono<ApplicationView> getEditingApplication(String applicationId) {
249-
return checkPermissionWithReadableErrorMsg(applicationId, EDIT_APPLICATIONS)
249+
return applicationService.findById(applicationId).filter(application -> application.isPublicToAll() && application.isPublicToMarketplace())
250+
.map(application -> {
251+
ResourcePermission permission = ResourcePermission.builder().resourceRole(ResourceRole.VIEWER).build();
252+
return permission;
253+
})
254+
.switchIfEmpty(checkPermissionWithReadableErrorMsg(applicationId, EDIT_APPLICATIONS))
250255
.zipWhen(permission -> applicationService.findById(applicationId)
251256
.delayUntil(application -> checkApplicationStatus(application, NORMAL)))
252257
.zipWhen(tuple -> applicationService.getAllDependentModulesFromApplication(tuple.getT2(), false), TupleUtils::merge)

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/security/SecurityConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
9191
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL), // system config
9292
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, SERVER_SETTING_URL), // system env
9393
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, CONFIG_URL + "/deploymentId"), // system config
94+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/*"), // application view
9495
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/*/view"), // application view
9596
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/*/view_marketplace"), // application view
9697
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, APPLICATION_URL + "/marketplace-apps"), // marketplace apps
@@ -121,6 +122,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
121122
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.CONFIG_URL + "/deploymentId"),
122123
ServerWebExchangeMatchers.pathMatchers(HttpMethod.HEAD, NewUrl.STATE_URL + "/healthCheck"),
123124
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.PREFIX + "/status/**"),
125+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/*"),
124126
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/*/view"),
125127
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/*/view_marketplace"),
126128
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.APPLICATION_URL + "/marketplace-apps"), // marketplace apps
@@ -172,6 +174,7 @@ private CorsConfigurationSource buildCorsConfigurationSource() {
172174
source.registerCorsConfiguration(CONFIG_URL, skipCheckCorsForAll);
173175
source.registerCorsConfiguration(GROUP_URL + "/list", skipCheckCorsForAll);
174176
source.registerCorsConfiguration(QUERY_URL + "/execute", skipCheckCorsForAll);
177+
source.registerCorsConfiguration(APPLICATION_URL + "/*", skipCheckCorsForAll);
175178
source.registerCorsConfiguration(APPLICATION_URL + "/*/view", skipCheckCorsForAll);
176179
source.registerCorsConfiguration(APPLICATION_URL + "/*/view_marketplace", skipCheckCorsForAll);
177180
source.registerCorsConfiguration(APPLICATION_URL + "/marketplace-apps", skipCheckCorsForAll);
@@ -183,6 +186,7 @@ private CorsConfigurationSource buildCorsConfigurationSource() {
183186
source.registerCorsConfiguration(NewUrl.CONFIG_URL, skipCheckCorsForAll);
184187
source.registerCorsConfiguration(NewUrl.GROUP_URL + "/list", skipCheckCorsForAll);
185188
source.registerCorsConfiguration(NewUrl.QUERY_URL + "/execute", skipCheckCorsForAll);
189+
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/*", skipCheckCorsForAll);
186190
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/*/view", skipCheckCorsForAll);
187191
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/*/view_marketplace", skipCheckCorsForAll);
188192
source.registerCorsConfiguration(NewUrl.APPLICATION_URL + "/marketplace-apps", skipCheckCorsForAll);

0 commit comments

Comments
 (0)