You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ho...@apache.org on 2026/10/23 12:11:53 UTC

(streampipes) branch dev updated: feat(#5113): add dashboard audit events (#5118)

This is an automated email from the ASF dual-hosted git repository.

JHoelli pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6fb45f6e81 feat(#5113): add dashboard audit events (#5118)
6fb45f6e81 is described below

commit 6fb45f6e81bd202030df3adc84d454f2050c0b91
Author: Jacqueline Höllig <78...@users.noreply.github.com>
AuthorDate: Fri Oct 23 14:11:48 2026 +0200

    feat(#5113): add dashboard audit events (#5118)
---
 .../audit/events/StandardAuditEvents.java          | 10 +++++
 .../events/dashboard/DashboardAuditReporter.java   | 49 ++++++++++++++++++++++
 .../events/dashboard/DashboardCreatedDetails.java  | 25 +++++++++++
 .../events/dashboard/DashboardDeletedDetails.java  | 25 +++++++++++
 .../events/dashboard/DashboardEditedDetails.java   | 25 +++++++++++
 .../impl/dashboard/DataLakeDashboardResource.java  |  6 +++
 6 files changed, 140 insertions(+)

diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
index bab3285da0..6683f8f65d 100644
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
@@ -24,6 +24,9 @@ import org.apache.streampipes.audit.events.adapter.AdapterCreatedDetails;
 import org.apache.streampipes.audit.events.adapter.AdapterEditedDetails;
 import org.apache.streampipes.audit.events.adapter.AdapterLifecycleDetails;
 import org.apache.streampipes.audit.events.authentication.AuthenticationDetails;
+import org.apache.streampipes.audit.events.dashboard.DashboardCreatedDetails;
+import org.apache.streampipes.audit.events.dashboard.DashboardDeletedDetails;
+import org.apache.streampipes.audit.events.dashboard.DashboardEditedDetails;
 import org.apache.streampipes.audit.events.chart.ChartCreatedDetails;
 import org.apache.streampipes.audit.events.chart.ChartDeletedDetails;
 import org.apache.streampipes.audit.events.chart.ChartEditedDetails;
@@ -32,6 +35,12 @@ import java.util.List;
 
 public final class StandardAuditEvents implements AuditEventProvider {
 
+  public static final AuditEventDefinition<DashboardCreatedDetails> DASHBOARD_CREATE =
+      new AuditEventDefinition<>("sp.dashboard.create", DashboardCreatedDetails.class, "dashboard");
+  public static final AuditEventDefinition<DashboardEditedDetails> DASHBOARD_EDIT =
+      new AuditEventDefinition<>("sp.dashboard.edit", DashboardEditedDetails.class, "dashboard");
+  public static final AuditEventDefinition<DashboardDeletedDetails> DASHBOARD_DELETE =
+      new AuditEventDefinition<>("sp.dashboard.delete", DashboardDeletedDetails.class, "dashboard");
   public static final AuditEventDefinition<ChartCreatedDetails> CHART_CREATE =
       new AuditEventDefinition<>("sp.chart.create", ChartCreatedDetails.class, "chart");
   public static final AuditEventDefinition<ChartEditedDetails> CHART_EDIT =
@@ -55,6 +64,7 @@ public final class StandardAuditEvents implements AuditEventProvider {
 
 
   private static final List<AuditEventDefinition<?>> EVENT_TYPES = List.of(
+      DASHBOARD_CREATE, DASHBOARD_EDIT, DASHBOARD_DELETE,
       CHART_CREATE, CHART_EDIT, CHART_DELETE,
       ADAPTER_CREATE, ADAPTER_START, ADAPTER_STOP, ADAPTER_EDIT, AUTH_LOGIN, AUTH_LOGOUT);
 
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardAuditReporter.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardAuditReporter.java
new file mode 100644
index 0000000000..ea4dc91cca
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardAuditReporter.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.dashboard;
+
+import org.apache.streampipes.audit.api.AuditOutcome;
+import org.apache.streampipes.audit.api.AuditService;
+import org.apache.streampipes.audit.events.StandardAuditEvents;
+
+import java.util.Objects;
+
+/** Publishes dashboard lifecycle events with safe, resource-free details. */
+public final class DashboardAuditReporter {
+  private final AuditService auditService;
+
+  public DashboardAuditReporter(AuditService auditService) {
+    this.auditService = Objects.requireNonNull(auditService);
+  }
+
+  public void created(String actor, String dashboardId) {
+    auditService.record(StandardAuditEvents.DASHBOARD_CREATE, AuditOutcome.SUCCEEDED, actor, dashboardId,
+        new DashboardCreatedDetails());
+  }
+
+  public void edited(String actor, String dashboardId) {
+    auditService.record(StandardAuditEvents.DASHBOARD_EDIT, AuditOutcome.SUCCEEDED, actor, dashboardId,
+        new DashboardEditedDetails());
+  }
+
+  public void deleted(String actor, String dashboardId) {
+    auditService.record(StandardAuditEvents.DASHBOARD_DELETE, AuditOutcome.SUCCEEDED, actor, dashboardId,
+        new DashboardDeletedDetails());
+  }
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardCreatedDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardCreatedDetails.java
new file mode 100644
index 0000000000..021d6a0d17
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardCreatedDetails.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.dashboard;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+
+/** The dashboard ID is stored in the audit event envelope; no dashboard data is retained. */
+public record DashboardCreatedDetails() implements AuditDetails {
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardDeletedDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardDeletedDetails.java
new file mode 100644
index 0000000000..8d990fc70e
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardDeletedDetails.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.dashboard;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+
+/** The dashboard ID is retained in the audit event envelope after deletion. */
+public record DashboardDeletedDetails() implements AuditDetails {
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardEditedDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardEditedDetails.java
new file mode 100644
index 0000000000..3450fd0c2c
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/dashboard/DashboardEditedDetails.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.dashboard;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+
+/** The dashboard ID is stored in the audit event envelope; no dashboard data is retained. */
+public record DashboardEditedDetails() implements AuditDetails {
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DataLakeDashboardResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DataLakeDashboardResource.java
index 2ec77e492c..1cc39a2b4b 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DataLakeDashboardResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/dashboard/DataLakeDashboardResource.java
@@ -19,6 +19,7 @@
 package org.apache.streampipes.rest.impl.dashboard;
 
 
+import org.apache.streampipes.audit.events.dashboard.DashboardAuditReporter;
 import org.apache.streampipes.model.client.user.DefaultPrivilege;
 import org.apache.streampipes.model.dashboard.DashboardModel;
 import org.apache.streampipes.model.dashboard.DashboardSummaryDto;
@@ -51,10 +52,12 @@ import java.util.Objects;
 @RequestMapping("/api/v3/datalake/dashboard")
 public class DataLakeDashboardResource extends AbstractAuthGuardedRestResource {
 
+  private final DashboardAuditReporter dashboardAudit;
   private final IPermissionStorage permissionStorage;
   private final DashboardResourceManager dashboardResourceManager;
 
   public DataLakeDashboardResource(SpResourceManager resourceManager) {
+    this.dashboardAudit = new DashboardAuditReporter(resourceManager.getAuditService());
     this.permissionStorage = resourceManager.managePermissions().getDb();
     this.dashboardResourceManager = resourceManager.manageDashboards();
   }
@@ -103,6 +106,7 @@ public class DataLakeDashboardResource extends AbstractAuthGuardedRestResource {
   @PreAuthorize("this.hasWriteAuthority() and hasPermission(#dashboardModel.couchDbId, 'WRITE')")
   public ResponseEntity<DashboardModel> modifyDashboard(@RequestBody DashboardModel dashboardModel) {
     dashboardResourceManager.update(dashboardModel);
+    dashboardAudit.edited(getAuthenticatedUserSid(), dashboardModel.getElementId());
     return ok(dashboardResourceManager.find(dashboardModel.getElementId()));
   }
 
@@ -110,6 +114,7 @@ public class DataLakeDashboardResource extends AbstractAuthGuardedRestResource {
   @PreAuthorize("this.hasWriteAuthority() and hasPermission(#dashboardId, 'WRITE')")
   public ResponseEntity<Void> deleteDashboard(@PathVariable("dashboardId") String dashboardId) {
     dashboardResourceManager.delete(dashboardId);
+    dashboardAudit.deleted(getAuthenticatedUserSid(), dashboardId);
     return ok();
   }
 
@@ -117,6 +122,7 @@ public class DataLakeDashboardResource extends AbstractAuthGuardedRestResource {
   @PreAuthorize("this.hasWriteAuthority()")
   public ResponseEntity<DashboardModel> createDashboard(@RequestBody DashboardModel dashboardModel) {
     var response = dashboardResourceManager.create(dashboardModel, getAuthenticatedUserSid());
+    dashboardAudit.created(getAuthenticatedUserSid(), response.getElementId());
     return ok(response);
   }