Skip to content

Commit ff83ede

Browse files
authored
API / WFSHarvesterApi / Restrict to Editor (#8757)
1 parent d06fbf2 commit ff83ede

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

workers/wfsfeature-harvester/src/main/java/org/fao/geonet/harvester/wfsfeatures/WFSHarvesterApi.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.context.ConfigurableApplicationContext;
4040
import org.springframework.http.HttpStatus;
4141
import org.springframework.http.MediaType;
42+
import org.springframework.security.access.prepost.PreAuthorize;
4243
import org.springframework.web.bind.annotation.*;
4344

4445
import java.util.HashMap;
@@ -63,11 +64,11 @@ public class WFSHarvesterApi {
6364
produces = MediaType.APPLICATION_JSON_VALUE,
6465
method = RequestMethod.PUT)
6566
@ResponseStatus(value = HttpStatus.OK)
67+
@PreAuthorize("hasAuthority('Editor')")
6668
@ResponseBody
6769
public JSONObject indexWfs(
6870
@RequestBody WFSHarvesterParameter config) throws Exception {
6971

70-
// TODO: Check user is authenticated ?
7172
JSONObject result = new JSONObject();
7273
result.put("success", true);
7374
result.put("indexedFeatures",
@@ -85,6 +86,7 @@ public JSONObject indexWfs(
8586
produces = MediaType.ALL_VALUE,
8687
method = RequestMethod.DELETE)
8788
@ResponseStatus(value = HttpStatus.OK)
89+
@PreAuthorize("hasAuthority('Editor')")
8890
@ResponseBody
8991
public JSONObject deleteWfs(
9092
@RequestParam
@@ -95,12 +97,9 @@ public JSONObject deleteWfs(
9597
EsWFSFeatureIndexer indexer = ApplicationContextHolder.get().getBean(EsWFSFeatureIndexer.class);
9698
indexer.deleteFeatures(serviceUrl, typeName, client);
9799

98-
// TODO: Check user is authenticated ?
99100
JSONObject result = new JSONObject();
100101
result.put("success", true);
101-
// result.put("indexedFeatures",
102-
// sendMessage(config));
103-
102+
104103
return result;
105104
}
106105

0 commit comments

Comments
 (0)