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 2026/06/29 11:01:29 UTC
(streampipes) 01/01: fix: align script template access handling
This is an automated email from the ASF dual-hosted git repository.
tenthe pushed a commit to branch connect-script-template-auth-banner
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 7b4fec9972f9cb9fc1009cdd5c4ae9a59daea744
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Mon Jun 29 11:00:46 2026 +0000
fix: align script template access handling
---
.../impl/connect/TransformationScriptLanguageResource.java | 3 +++
.../impl/connect/TransformationScriptTemplateResource.java | 7 +++++++
ui/deployment/i18n/de.json | 2 ++
ui/deployment/i18n/en.json | 2 ++
ui/deployment/i18n/pl.json | 2 ++
...eate-adapter-transformation-template-dialog.component.html | 11 +++++++++++
...create-adapter-transformation-template-dialog.component.ts | 7 ++++++-
...lect-adapter-transformation-template-dialog.component.html | 11 +++++++++++
...select-adapter-transformation-template-dialog.component.ts | 2 ++
9 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptLanguageResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptLanguageResource.java
index 18fe0c7f0d..47230151d3 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptLanguageResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptLanguageResource.java
@@ -23,11 +23,13 @@ import org.apache.streampipes.connect.transformer.api.TransformationEngines;
import org.apache.streampipes.manager.execution.endpoint.ExtensionsServiceEndpointUtils;
import org.apache.streampipes.model.connect.ScriptMetadata;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.svcdiscovery.SpServiceDiscovery;
import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceTypes;
import org.apache.streampipes.svcdiscovery.api.model.SpServiceUrlProvider;
import org.springframework.http.MediaType;
+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;
@@ -40,6 +42,7 @@ import java.util.List;
public class TransformationScriptLanguageResource {
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public List<ScriptMetadata> getAll(@RequestBody AdapterDescription adapterDescription) throws
NoServiceEndpointsAvailableException {
var languagesSupportedByCore = TransformationEngines.INSTANCE.getAvailableEngineMetadata();
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptTemplateResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptTemplateResource.java
index b3b6f93fc6..a78042b406 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptTemplateResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/connect/TransformationScriptTemplateResource.java
@@ -20,10 +20,12 @@ package org.apache.streampipes.rest.impl.connect;
import org.apache.streampipes.model.connect.ConnectTransformationScriptTemplate;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
+import org.apache.streampipes.rest.security.AuthConstants;
import org.apache.streampipes.storage.api.system.ITransformationScriptTemplateStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
import org.springframework.http.MediaType;
+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;
@@ -45,12 +47,14 @@ public class TransformationScriptTemplateResource extends AbstractAuthGuardedRes
@GetMapping(
value = "{id}",
produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public ConnectTransformationScriptTemplate findById(@PathVariable String id) {
return templateStorage.getElementById(id);
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_READ_ADAPTER_PRIVILEGE)
public List<ConnectTransformationScriptTemplate> getAll() {
return templateStorage.findAll();
}
@@ -59,6 +63,7 @@ public class TransformationScriptTemplateResource extends AbstractAuthGuardedRes
value = "{id}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public ConnectTransformationScriptTemplate update(@PathVariable String id,
@RequestBody ConnectTransformationScriptTemplate scriptTemplate) {
if (!id.equals(scriptTemplate.getElementId())) {
@@ -69,11 +74,13 @@ public class TransformationScriptTemplateResource extends AbstractAuthGuardedRes
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public void create(@RequestBody ConnectTransformationScriptTemplate scriptTemplate) {
templateStorage.persist(scriptTemplate);
}
@DeleteMapping(value = "{id}", produces = MediaType.APPLICATION_JSON_VALUE)
+ @PreAuthorize(AuthConstants.HAS_WRITE_ADAPTER_PRIVILEGE)
public void delete(@PathVariable String id) {
var scriptTemplate = templateStorage.getElementById(id);
if (scriptTemplate == null) {
diff --git a/ui/deployment/i18n/de.json b/ui/deployment/i18n/de.json
index 32fff84e7b..84202ba498 100644
--- a/ui/deployment/i18n/de.json
+++ b/ui/deployment/i18n/de.json
@@ -1017,6 +1017,7 @@
"Show tooltip": "Tooltip anzeigen",
"Show values as labels": "Werte als Beschriftung anzeigen",
"Shows the distribution of numerical data": "Zeigt die Verteilung der numerischen Daten",
+ "Shared transformation templates": "Geteilte Transformationsvorlagen",
"Simple filters below are kept for fallback, but the advanced filter is currently used for queries.": "Die einfachen Filter unten bleiben als Rückfalloption erhalten, aber derzeit wird der erweiterte Filter für Abfragen verwendet.",
"Single": "Einzeln",
"Site": "Standort",
@@ -1085,6 +1086,7 @@
"Template": "Vorlage",
"Template description": "Beschreibung der Vorlage",
"Template name": "Name der Vorlage",
+ "Templates are shared and are not permission-managed individually. Users with adapter access can view, edit, and remove templates. Do not store sensitive data in templates.": "Vorlagen werden gemeinsam genutzt und nicht einzeln über Berechtigungen verwaltet. Benutzer mit Adapterzugriff können Vorlagen anzeigen, bearbeiten und entfernen. Speichern Sie keine sensiblen Daten in Vorlagen.",
"Terms": "Nutzungsbedingungen",
"Terms acknowledgment after login": "Bestätigung von Nutzungsbedingungen nach dem Login",
"Test": "Test",
diff --git a/ui/deployment/i18n/en.json b/ui/deployment/i18n/en.json
index 865f7a11d5..aee28aa99d 100644
--- a/ui/deployment/i18n/en.json
+++ b/ui/deployment/i18n/en.json
@@ -1017,6 +1017,7 @@
"Show tooltip": null,
"Show values as labels": null,
"Shows the distribution of numerical data": null,
+ "Shared transformation templates": null,
"Simple filters below are kept for fallback, but the advanced filter is currently used for queries.": null,
"Single": null,
"Site": null,
@@ -1085,6 +1086,7 @@
"Template": null,
"Template description": null,
"Template name": null,
+ "Templates are shared and are not permission-managed individually. Users with adapter access can view, edit, and remove templates. Do not store sensitive data in templates.": null,
"Terms": null,
"Terms acknowledgment after login": null,
"Test": null,
diff --git a/ui/deployment/i18n/pl.json b/ui/deployment/i18n/pl.json
index 5557760100..21d57673be 100644
--- a/ui/deployment/i18n/pl.json
+++ b/ui/deployment/i18n/pl.json
@@ -1017,6 +1017,7 @@
"Show tooltip": "Pokaż podpowiedź",
"Show values as labels": "Pokaż wartości jako etykiety",
"Shows the distribution of numerical data": "Pokazuje rozkład danych numerycznych",
+ "Shared transformation templates": "Współdzielone szablony transformacji",
"Simple filters below are kept for fallback, but the advanced filter is currently used for queries.": "Poniższe proste filtry są zachowane jako opcja zapasowa, ale obecnie do zapytań używany jest filtr zaawansowany.",
"Single": "Pojedynczy",
"Site": "Lokalizacja",
@@ -1085,6 +1086,7 @@
"Template": "Szablon",
"Template description": "Opis szablonu",
"Template name": "Nazwa szablonu",
+ "Templates are shared and are not permission-managed individually. Users with adapter access can view, edit, and remove templates. Do not store sensitive data in templates.": "Szablony są współdzielone i nie są zarządzane indywidualnie przez uprawnienia. Użytkownicy z dostępem do adapterów mogą wyświetlać, edytować i usuwać szablony. Nie zapisuj w szablonach danych wrażliwych.",
"Terms": "Warunki",
"Terms acknowledgment after login": "Potwierdzenie warunków po zalogowaniu",
"Test": "Test",
diff --git a/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.html b/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.html
index bb2e1fb9f3..b63f46590c 100644
--- a/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.html
+++ b/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.html
@@ -18,6 +18,17 @@
<div class="sp-dialog-container">
<div class="sp-dialog-content p-15">
+ <sp-alert-banner
+ type="info"
+ [title]="'Shared transformation templates' | translate"
+ [description]="
+ 'Templates are shared and are not permission-managed individually. Users with adapter access can view, edit, and remove templates. Do not store sensitive data in templates.'
+ | translate
+ "
+ data-cy="script-template-shared-info"
+ >
+ </sp-alert-banner>
+
<sp-form-field [level]="3" [label]="'Template name' | translate">
<mat-form-field>
<input
diff --git a/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.ts b/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.ts
index 166829bf1a..f4e52ea589 100644
--- a/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.ts
+++ b/ui/src/app/connect/dialog/create-adapter-transformation-template-dialog/create-adapter-transformation-template-dialog.component.ts
@@ -17,7 +17,11 @@
*/
import { Component, inject, Input } from '@angular/core';
-import { DialogRef, FormFieldComponent } from '@streampipes/shared-ui';
+import {
+ DialogRef,
+ FormFieldComponent,
+ SpAlertBannerComponent,
+} from '@streampipes/shared-ui';
import { ConnectScriptTemplatesService } from '@streampipes/platform-services';
import { MatFormField } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input';
@@ -35,6 +39,7 @@ import { TranslatePipe } from '@ngx-translate/core';
styleUrl: './create-adapter-transformation-template-dialog.component.scss',
imports: [
FormFieldComponent,
+ SpAlertBannerComponent,
MatFormField,
MatInput,
FormsModule,
diff --git a/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.html b/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.html
index a8a0ffe35e..8cc64d077e 100644
--- a/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.html
+++ b/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.html
@@ -18,6 +18,17 @@
<div class="sp-dialog-container">
<div class="sp-dialog-content p-15">
+ <sp-alert-banner
+ type="info"
+ [title]="'Shared transformation templates' | translate"
+ [description]="
+ 'Templates are shared and are not permission-managed individually. Users with adapter access can view, edit, and remove templates. Do not store sensitive data in templates.'
+ | translate
+ "
+ data-cy="script-template-shared-info"
+ >
+ </sp-alert-banner>
+
<sp-form-field [level]="3" [label]="'Template' | translate">
<mat-form-field>
<mat-select
diff --git a/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.ts b/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.ts
index 255497ad1d..04bf54ccc9 100644
--- a/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.ts
+++ b/ui/src/app/connect/dialog/select-adapter-transformation-template-dialog/select-adapter-transformation-template-dialog.component.ts
@@ -24,6 +24,7 @@ import {
import {
DialogRef,
FormFieldComponent,
+ SpAlertBannerComponent,
SpLabelComponent,
} from '@streampipes/shared-ui';
import { MatFormField } from '@angular/material/form-field';
@@ -51,6 +52,7 @@ import { TranslatePipe } from '@ngx-translate/core';
styleUrl: './select-adapter-transformation-template-dialog.component.scss',
imports: [
FormFieldComponent,
+ SpAlertBannerComponent,
MatFormField,
MatSelect,
FormsModule,