You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2024/05/06 20:31:16 UTC
(streampipes) 01/01: refactor: Refactor rest api
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch refactor-rest-api
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 0bbe0d39c1f664c5c7f1727576957e79d97c0af2
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Mon May 6 22:31:06 2024 +0200
refactor: Refactor rest api
---
.../streampipes/rest/impl/PipelineResource.java | 21 +++++++++++----------
.../rest/impl/connect/DescriptionResource.java | 7 +++++++
.../rest/impl/connect/GuessResource.java | 4 ++++
.../impl/connect/RuntimeResolvableResource.java | 3 +++
.../streampipes/rest/impl/connect/UnitResource.java | 3 +++
.../impl/dashboard/AbstractDashboardResource.java | 4 ++--
.../rest/impl/dashboard/DashboardWidget.java | 9 +++++++++
.../dashboard/VisualizablePipelineResource.java | 2 +-
.../rest/impl/datalake/DataLakeWidgetResource.java | 17 +++++++++++++++--
.../impl/datalake/PersistedDataStreamResource.java | 2 +-
.../rest/impl/pe/DataProcessorResource.java | 4 ++--
.../streampipes/rest/impl/pe/DataSinkResource.java | 4 ++--
.../rest/impl/pe/DataStreamResource.java | 4 ++--
13 files changed, 62 insertions(+), 22 deletions(-)
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
index 4afe07c171..fbff7631c2 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
@@ -89,7 +89,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
array = @ArraySchema(schema = @Schema(implementation = Pipeline.class))
)})})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.pipelineId, 'READ')")
+ @PostFilter("hasPermission(filterObject.pipelineId, '')")
public List<Pipeline> get() {
return PipelineManager.getAllPipelines();
}
@@ -98,7 +98,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
path = "{pipelineId}/status",
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get the pipeline status of a given pipeline", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public List<PipelineStatusMessage> getPipelineStatus(@PathVariable("pipelineId") String pipelineId) {
return PipelineStatusManager.getPipelineStatus(pipelineId, 5);
}
@@ -107,7 +107,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
path = "/{pipelineId}",
produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Delete a pipeline with a given id", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_DELETE_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public Message removeOwn(@PathVariable("pipelineId") String pipelineId) {
PipelineManager.deletePipeline(pipelineId);
return Notifications.success("Pipeline deleted");
@@ -115,7 +115,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/{pipelineId}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get a specific pipeline with the given id", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public ResponseEntity<Pipeline> getElement(@PathVariable("pipelineId") String pipelineId) {
Pipeline foundPipeline = PipelineManager.getPipeline(pipelineId);
@@ -128,9 +128,10 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/{pipelineId}/start", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Start the pipeline with the given id", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public ResponseEntity<?> start(@PathVariable("pipelineId") String pipelineId) {
try {
+
PipelineOperationStatus status = PipelineManager.startPipeline(pipelineId);
return ok(status);
@@ -142,7 +143,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/{pipelineId}/stop", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Stop the pipeline with the given id", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public ResponseEntity<?> stop(@PathVariable("pipelineId") String pipelineId,
@RequestParam(value = "forceStop", defaultValue = "false") boolean forceStop) {
try {
@@ -174,7 +175,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
produces = MediaType.APPLICATION_JSON_VALUE)
@Hidden
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
- @PostAuthorize("hasPermission(returnObject, 'READ')")
+ @PostAuthorize("hasPermission(returnObject, '')")
public PipelineElementRecommendationMessage recommend(@RequestBody Pipeline pipeline,
@PathVariable("recId") String baseRecElement) {
try {
@@ -204,7 +205,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@Hidden
- @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE + " AND hasPermission(#pipeline.pipelineId, '')")
public ResponseEntity<?> validatePipeline(@RequestBody Pipeline pipeline) {
try {
return ok(Operations.validatePipeline(pipeline));
@@ -231,7 +232,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Update an existing pipeline", tags = {"Pipeline"})
- @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE + " AND hasPermission(#pipelineId, '')")
public ResponseEntity<SuccessMessage> overwritePipeline(@PathVariable("pipelineId") String pipelineId,
@RequestBody Pipeline pipeline) {
Pipeline storedPipeline = getPipelineStorage().getPipeline(pipelineId);
@@ -259,7 +260,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@Content(mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = Pipeline.class)))})})
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.pipelineId, 'READ')")
+ @PostFilter("hasPermission(filterObject.pipelineId, '')")
public List<Pipeline> getPipelinesContainingElement(@PathVariable("elementId") String elementId) {
return PipelineManager.getPipelinesContainingElements(elementId);
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/DescriptionResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/DescriptionResource.java
index 7d8f562034..4258d06250 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/DescriptionResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/DescriptionResource.java
@@ -25,12 +25,14 @@ import org.apache.streampipes.connect.management.management.DescriptionManagemen
import org.apache.streampipes.manager.api.extensions.IExtensionsServiceEndpointGenerator;
import org.apache.streampipes.manager.execution.endpoint.ExtensionsServiceEndpointGenerator;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.svcdiscovery.api.model.SpServiceUrlProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -53,6 +55,7 @@ public class DescriptionResource extends AbstractAdapterResource<DescriptionMana
}
@GetMapping(path = "/adapters", produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public ResponseEntity<List<AdapterDescription>> getAdapters() {
List<AdapterDescription> result = managementService.getAdapters();
@@ -60,6 +63,7 @@ public class DescriptionResource extends AbstractAdapterResource<DescriptionMana
}
@GetMapping(path = "/{id}/assets", produces = "application/zip")
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public ResponseEntity<?> getAdapterAssets(@PathVariable("id") String id) {
try {
String result = null;
@@ -87,6 +91,7 @@ public class DescriptionResource extends AbstractAdapterResource<DescriptionMana
}
@GetMapping(path = "/{id}/assets/icon", produces = "image/png")
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public ResponseEntity<?> getAdapterIconAsset(@PathVariable("id") String id) {
try {
@@ -115,6 +120,7 @@ public class DescriptionResource extends AbstractAdapterResource<DescriptionMana
}
@GetMapping(path = "/{id}/assets/documentation", produces = MediaType.TEXT_PLAIN_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public ResponseEntity<?> getAdapterDocumentationAsset(@PathVariable("id") String id) {
try {
String result = null;
@@ -142,6 +148,7 @@ public class DescriptionResource extends AbstractAdapterResource<DescriptionMana
}
@DeleteMapping(path = "{adapterId}")
+ @PreAuthorize(AuthConstants.HAS_DELETE_ADAPTER_PRIVILEGE)
public ResponseEntity<?> deleteAdapter(@PathVariable("adapterId") String adapterId) {
try {
this.managementService.deleteAdapterDescription(adapterId);
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/GuessResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/GuessResource.java
index f8756e587c..307a23b128 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/GuessResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/GuessResource.java
@@ -26,12 +26,14 @@ import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.connect.guess.AdapterEventPreview;
import org.apache.streampipes.model.connect.guess.GuessSchema;
import org.apache.streampipes.model.monitoring.SpLogMessage;
+import org.apache.streampipes.rest.security.AuthConstants;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -53,6 +55,7 @@ public class GuessResource extends AbstractAdapterResource<GuessManagement> {
path = "/schema",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public ResponseEntity<?> guessSchema(@RequestBody AdapterDescription adapterDescription) {
try {
@@ -74,6 +77,7 @@ public class GuessResource extends AbstractAdapterResource<GuessManagement> {
path = "/schema/preview",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public ResponseEntity<?> getAdapterEventPreview(@RequestBody AdapterEventPreview previewRequest) {
try {
return ok(managementService.performAdapterEventPreview(previewRequest));
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/RuntimeResolvableResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/RuntimeResolvableResource.java
index 32cfb73044..4e8a601417 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/RuntimeResolvableResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/RuntimeResolvableResource.java
@@ -30,6 +30,7 @@ import org.apache.streampipes.model.monitoring.SpLogMessage;
import org.apache.streampipes.model.runtime.RuntimeOptionsRequest;
import org.apache.streampipes.model.runtime.RuntimeOptionsResponse;
import org.apache.streampipes.resource.management.SpResourceManager;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.storage.management.StorageDispatcher;
import org.apache.streampipes.svcdiscovery.api.model.SpServiceUrlProvider;
@@ -37,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -66,6 +68,7 @@ public class RuntimeResolvableResource extends AbstractAdapterResource<WorkerAdm
path = "{id}/configurations",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public ResponseEntity<?> fetchConfigurations(@PathVariable("id") String appId,
@RequestBody RuntimeOptionsRequest runtimeOptionsRequest) {
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/UnitResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/UnitResource.java
index 27404302a1..ac9bc8e70b 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/UnitResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/UnitResource.java
@@ -21,11 +21,13 @@ package org.apache.streampipes.rest.impl.connect;
import org.apache.streampipes.commons.exceptions.connect.AdapterException;
import org.apache.streampipes.connect.management.management.UnitMasterManagement;
import org.apache.streampipes.model.connect.unit.UnitDescription;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,6 +47,7 @@ public class UnitResource extends AbstractAdapterResource<UnitMasterManagement>
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public ResponseEntity<?> getFittingUnits(@RequestBody UnitDescription unitDescription) {
try {
String resultingJson = managementService.getFittingUnits(unitDescription);
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/AbstractDashboardResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/AbstractDashboardResource.java
index 6b83a949b8..80e61a00a9 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/AbstractDashboardResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/AbstractDashboardResource.java
@@ -39,13 +39,13 @@ public abstract class AbstractDashboardResource extends AbstractAuthGuardedRestR
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("this.hasReadAuthority()")
- @PostFilter("hasPermission(filterObject.couchDbId, 'READ')")
+ @PostFilter("hasPermission(filterObject.couchDbId, '')")
public List<DashboardModel> getAllDashboards() {
return getResourceManager().findAll();
}
@GetMapping(path = "/{dashboardId}", produces = MediaType.APPLICATION_JSON_VALUE)
- @PreAuthorize("this.hasReadAuthority() and hasPermission(#dashboardId, 'READ')")
+ @PreAuthorize("this.hasReadAuthority() and hasPermission(#dashboardId, '')")
public DashboardModel getDashboard(@PathVariable("dashboardId") String dashboardId) {
return getResourceManager().find(dashboardId);
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DashboardWidget.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DashboardWidget.java
index 2750f1412a..b00859e05d 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DashboardWidget.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DashboardWidget.java
@@ -20,10 +20,13 @@ package org.apache.streampipes.rest.impl.dashboard;
import org.apache.streampipes.model.dashboard.DashboardWidgetModel;
import org.apache.streampipes.rest.core.base.impl.AbstractRestResource;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.storage.api.IDashboardWidgetStorage;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PostFilter;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -40,11 +43,14 @@ import java.util.List;
public class DashboardWidget extends AbstractRestResource {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_DASHBOARD_PRIVILEGE)
+ @PostFilter("hasPermission(filterObject.widgetId, '')")
public ResponseEntity<List<DashboardWidgetModel>> getAllDashboardWidgets() {
return ok(getDashboardWidgetStorage().getAllDashboardWidgets());
}
@GetMapping(path = "/{widgetId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_DASHBOARD_PRIVILEGE + " AND hasPermission(#widgetId, '')")
public ResponseEntity<DashboardWidgetModel> getDashboardWidget(@PathVariable("widgetId") String widgetId) {
return ok(getDashboardWidgetStorage().getDashboardWidget(widgetId));
}
@@ -53,12 +59,14 @@ public class DashboardWidget extends AbstractRestResource {
path = "/{widgetId}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_DASHBOARD_PRIVILEGE + " AND hasPermission(#dashboardWidgetModel.widgetId, '')")
public ResponseEntity<Void> modifyDashboardWidget(@RequestBody DashboardWidgetModel dashboardWidgetModel) {
getDashboardWidgetStorage().updateDashboardWidget(dashboardWidgetModel);
return ok();
}
@DeleteMapping(path = "/{widgetId}")
+ @PreAuthorize(AuthConstants.HAS_WRITE_DASHBOARD_PRIVILEGE + " AND hasPermission(#widgetId, '')")
public ResponseEntity<Void> deleteDashboardWidget(@PathVariable("widgetId") String widgetId) {
getDashboardWidgetStorage().deleteDashboardWidget(widgetId);
return ok();
@@ -68,6 +76,7 @@ public class DashboardWidget extends AbstractRestResource {
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
+ @PreAuthorize(AuthConstants.HAS_WRITE_DASHBOARD_PRIVILEGE + " AND hasPermission(#dashboardWidgetModel.widgetId, '')")
public ResponseEntity<DashboardWidgetModel> createDashboardWidget(
@RequestBody DashboardWidgetModel dashboardWidgetModel) {
String widgetId = getDashboardWidgetStorage().storeDashboardWidget(dashboardWidgetModel);
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/VisualizablePipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/VisualizablePipelineResource.java
index 01d63dc410..d16a790cd5 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/VisualizablePipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/VisualizablePipelineResource.java
@@ -44,7 +44,7 @@ public class VisualizablePipelineResource extends AbstractPipelineExtractionReso
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_DASHBOARD_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.pipelineId, 'READ')")
+ @PostFilter("hasPermission(filterObject.pipelineId, '')")
public List<VisualizablePipeline> getVisualizablePipelines() {
return extract(new ArrayList<>(), DashboardAppId);
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeWidgetResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeWidgetResource.java
index 2c108866a3..69a55c38b7 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeWidgetResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeWidgetResource.java
@@ -20,10 +20,13 @@ package org.apache.streampipes.rest.impl.datalake;
import org.apache.streampipes.model.datalake.DataExplorerWidgetModel;
import org.apache.streampipes.rest.core.base.impl.AbstractRestResource;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.storage.api.IDataExplorerWidgetStorage;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PostFilter;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -40,11 +43,14 @@ import java.util.List;
public class DataLakeWidgetResource extends AbstractRestResource {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_DATA_EXPLORER_PRIVILEGE)
+ @PostFilter("hasPermission(filterObject.widgetId, '')")
public ResponseEntity<List<DataExplorerWidgetModel>> getAllDataExplorerWidgets() {
return ok(getDataExplorerWidgetStorage().getAllDataExplorerWidgets());
}
@GetMapping(path = "/{widgetId}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_DATA_EXPLORER_PRIVILEGE + " AND hasPermission(#widgetId, '')")
public ResponseEntity<DataExplorerWidgetModel> getDataExplorerWidget(@PathVariable("widgetId") String widgetId) {
return ok(getDataExplorerWidgetStorage().getDataExplorerWidget(widgetId));
}
@@ -53,13 +59,17 @@ public class DataLakeWidgetResource extends AbstractRestResource {
path = "/{widgetId}",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_DATA_EXPLORER_PRIVILEGE +
+ " AND hasPermission(#dataExplorerWidgetModel.widgetId, '')")
public ResponseEntity<DataExplorerWidgetModel> modifyDataExplorerWidget(
- @RequestBody DataExplorerWidgetModel dataExplorerWidgetModel) {
+ @RequestBody DataExplorerWidgetModel dataExplorerWidgetModel
+ ) {
getDataExplorerWidgetStorage().updateDataExplorerWidget(dataExplorerWidgetModel);
return ok(getDataExplorerWidgetStorage().getDataExplorerWidget(dataExplorerWidgetModel.getId()));
}
@DeleteMapping(path = "/{widgetId}")
+ @PreAuthorize(AuthConstants.HAS_WRITE_DATA_EXPLORER_PRIVILEGE + " AND hasPermission(#widgetId, '')")
public ResponseEntity<Void> deleteDataExplorerWidget(@PathVariable("widgetId") String widgetId) {
getDataExplorerWidgetStorage().deleteDataExplorerWidget(widgetId);
return ok();
@@ -69,8 +79,11 @@ public class DataLakeWidgetResource extends AbstractRestResource {
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
+ @PreAuthorize(AuthConstants.HAS_WRITE_DATA_EXPLORER_PRIVILEGE +
+ " AND hasPermission(#dataExplorerWidgetModel.widgetId, '')")
public ResponseEntity<DataExplorerWidgetModel> createDataExplorerWidget(
- @RequestBody DataExplorerWidgetModel dataExplorerWidgetModel) {
+ @RequestBody DataExplorerWidgetModel dataExplorerWidgetModel
+ ) {
String widgetId = getDataExplorerWidgetStorage().storeDataExplorerWidget(dataExplorerWidgetModel);
return ok(getDataExplorerWidgetStorage().getDataExplorerWidget(widgetId));
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/PersistedDataStreamResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/PersistedDataStreamResource.java
index 72c0e9cf2c..04b69cbd5c 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/PersistedDataStreamResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/PersistedDataStreamResource.java
@@ -45,7 +45,7 @@ public class PersistedDataStreamResource extends AbstractPipelineExtractionResou
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_DATA_EXPLORER_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.pipelineId, 'READ')")
+ @PostFilter("hasPermission(filterObject.pipelineId, '')")
public List<DataLakeMeasure> getPersistedDataStreams() {
return extract(new ArrayList<>(), DataLakeAppId);
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java
index fdf3152752..719221886c 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataProcessorResource.java
@@ -45,14 +45,14 @@ public class DataProcessorResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/available", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+ @PostFilter("hasPermission(filterObject.elementId, '')")
public List<DataProcessorDescription> getAvailable() {
return getDataProcessorResourceManager().findAll();
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.belongsTo, 'READ')")
+ @PostFilter("hasPermission(filterObject.belongsTo, '')")
public List<DataProcessorInvocation> getOwn() {
return getDataProcessorResourceManager().findAllAsInvocation();
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java
index 8dc3964feb..4a08587669 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataSinkResource.java
@@ -45,14 +45,14 @@ public class DataSinkResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/available", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+ @PostFilter("hasPermission(filterObject.elementId, '')")
public List<DataSinkDescription> getAvailable() {
return getDataSinkResourceManager().findAll();
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.belongsTo, 'READ')")
+ @PostFilter("hasPermission(filterObject.belongsTo, '')")
public List<DataSinkInvocation> getOwn() {
return getDataSinkResourceManager().findAllAsInvocation();
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
index 70822846fe..0566303a43 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/pe/DataStreamResource.java
@@ -46,14 +46,14 @@ public class DataStreamResource extends AbstractAuthGuardedRestResource {
@GetMapping(path = "/available", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+ @PostFilter("hasPermission(filterObject.elementId, '')")
public List<SpDataStream> getAvailable() {
return getDataStreamResourceManager().findAll();
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(AuthConstants.HAS_READ_PIPELINE_ELEMENT_PRIVILEGE)
- @PostFilter("hasPermission(filterObject.elementId, 'READ')")
+ @PostFilter("hasPermission(filterObject.elementId, '')")
public List<SpDataStream> get() {
return getDataStreamResourceManager().findAllAsInvocation();
}