From e4716f1925004412aa9f9c82bedf1495698381ca Mon Sep 17 00:00:00 2001 From: Meric Feyzullahoglu Date: Fri, 31 May 2024 13:36:47 +0000 Subject: [PATCH] Update ScorpioBroker to the v4 Signed-off-by: Meric Feyzullahoglu --- AllInOneRunner/pom.xml | 10 ++--- .../resources/application-kafka.properties | 22 +++++------ .../src/main/resources/application.properties | 39 +++++++++++-------- .../db/migration/V20190604.1__entity.sql | 4 +- .../resources/dockerfiles/dockerfile-java | 2 - BrokerParent/pom.xml | 12 ++++++ EntityManager/pom.xml | 2 +- .../controller/EntityBatchController.java | 5 +++ .../controller/EntityController.java | 10 +++++ .../db/migration/V20190604.1__entity.sql | 4 +- QueryManager/pom.xml | 2 +- .../EntityOperationsQueryController.java | 2 + .../controller/QueryController.java | 7 ++++ .../db/migration/V20190604.1__entity.sql | 4 +- RegistryManager/pom.xml | 2 +- .../controller/RegistryController.java | 6 +++ .../db/migration/V20190604.1__entity.sql | 4 +- RegistrySubscriptionManager/pom.xml | 2 +- .../RegistrySubscriptionController.java | 6 +++ .../db/migration/V20190604.1__entity.sql | 4 +- SubscriptionManager/pom.xml | 2 +- .../controller/SubscriptionController.java | 6 +++ .../db/migration/V20190604.1__entity.sql | 4 +- pom.xml | 6 +-- 24 files changed, 118 insertions(+), 49 deletions(-) diff --git a/AllInOneRunner/pom.xml b/AllInOneRunner/pom.xml index 361b54480..d1cabc29a 100644 --- a/AllInOneRunner/pom.xml +++ b/AllInOneRunner/pom.xml @@ -9,17 +9,17 @@ all-in-one-runner AllInOneRunner - + eu.neclab.ngsildbroker entity-manager ${parent.version} - + eu.neclab.ngsildbroker query-manager @@ -75,7 +75,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/AllInOneRunner/src/main/resources/application-kafka.properties b/AllInOneRunner/src/main/resources/application-kafka.properties index 6a45ecf48..dcced053c 100644 --- a/AllInOneRunner/src/main/resources/application-kafka.properties +++ b/AllInOneRunner/src/main/resources/application-kafka.properties @@ -1,5 +1,5 @@ -mysettings.kafka.bootstrap.host=${bushost:localhost} -mysettings.kafka.bootstrap.port=${busport:9092} +mysettings.kafka.bootstrap.host=${KAFKA_BOOTSTRAP:localhost} +mysettings.kafka.bootstrap.port=${KAFKA_PORT:9092} bootstrap.servers=${mysettings.kafka.bootstrap.host}:${mysettings.kafka.bootstrap.port} client-id-prefix=$[quarkus.uuid} group.id=$[quarkus.application.name}$[quarkus.uuid} @@ -33,8 +33,8 @@ mp.messaging.incoming.entitybatchretrieve.auto.offset.reset=latest mp.messaging.incoming.entitybatchretrieve.broadcast=true #mp.messaging.incoming.entitybatchretrieve.value.deserializer=eu.neclab.ngsildbroker.commons.serialization.messaging.BatchRequestDeserializer #readability block###########. -mp.messaging.outgoing.history.connector=smallrye-kafka -mp.messaging.outgoing.history.topic=${scorpio.topics.temporal} +# mp.messaging.outgoing.history.connector=smallrye-kafka +# mp.messaging.outgoing.history.topic=${scorpio.topics.temporal} #readability block########### mp.messaging.outgoing.isubs.topic=${scorpio.topics.internalregsub} mp.messaging.outgoing.isubs.connector=smallrye-kafka @@ -89,10 +89,10 @@ mp.messaging.incoming.regsubsyncretrieve.topic=${scorpio.topics.regsubsync} mp.messaging.incoming.regsubsyncretrieve.auto.offset.reset=latest mp.messaging.incoming.regsubsyncretrieve.broadcast=true #mp.messaging.incoming.regsubsyncretrieve.value.deserializer=eu.neclab.ngsildbroker.commons.serialization.messaging.SyncMessageDeserializer -mp.messaging.outgoing.histsync.connector=smallrye-kafka -mp.messaging.outgoing.histsync.topic=${scorpio.topics.histsync} -#mp.messaging.outgoing.regsubsync.value.serializer=eu.neclab.ngsildbroker.commons.serialization.messaging.SyncMessageSerializer -mp.messaging.incoming.histsyncretrieve.connector=smallrye-kafka -mp.messaging.incoming.histsyncretrieve.topic=${scorpio.topics.histsync} -mp.messaging.incoming.histsyncretrieve.auto.offset.reset=latest -mp.messaging.incoming.histsyncretrieve.broadcast=true \ No newline at end of file +# mp.messaging.outgoing.histsync.connector=smallrye-kafka +# mp.messaging.outgoing.histsync.topic=${scorpio.topics.histsync} +# #mp.messaging.outgoing.regsubsync.value.serializer=eu.neclab.ngsildbroker.commons.serialization.messaging.SyncMessageSerializer +# mp.messaging.incoming.histsyncretrieve.connector=smallrye-kafka +# mp.messaging.incoming.histsyncretrieve.topic=${scorpio.topics.histsync} +# mp.messaging.incoming.histsyncretrieve.auto.offset.reset=latest +# mp.messaging.incoming.histsyncretrieve.broadcast=true \ No newline at end of file diff --git a/AllInOneRunner/src/main/resources/application.properties b/AllInOneRunner/src/main/resources/application.properties index 43932b219..3694cc32f 100644 --- a/AllInOneRunner/src/main/resources/application.properties +++ b/AllInOneRunner/src/main/resources/application.properties @@ -12,14 +12,14 @@ quarkus.vertx.prefer-native-transport=true #quarkus.http.tcp-quick-ack=true #quarkus.http.tcp-cork=true #quarkus.http.tcp-fast-open=true -mysettings.postgres.host=${dbhost:localhost} +mysettings.postgres.host=${POSTGRES_SERVICE:localhost} mysettings.postgres.port=${dbport:5432} mysettings.postgres.username=${dbuser:ngb} -mysettings.postgres.password=${dbpass:ngb} -mysettings.postgres.database-name=${dbname:ngb} +mysettings.postgres.password=${POSTGRES_PASSWORD:ngb} +mysettings.postgres.database-name=${POSTGRES_DBNAME:ngb} mysettings.gateway.host=${gateway.host:localhost} mysettings.gateway.port=${gateway.port:9090} -jdbcurl=jdbc:postgresql://${mysettings.postgres.host}:${mysettings.postgres.port}/${mysettings.postgres.database-name}?ApplicationName=${quarkus.application.name} +jdbcurl=jdbc:postgresql://${mysettings.postgres.host}:${mysettings.postgres.port}/${mysettings.postgres.database-name}?ApplicationName=${quarkus.application.name}&sslmode=require scorpio.messaging.duplicate=true scorpio.gatewayurl=http://localhost:9090 atcontext.url=http://localhost:9090/ngsi-ld/v1/jsonldContexts/ @@ -48,17 +48,17 @@ scorpio.registry.batch-operations.upsert.max=1000 scorpio.registry.batch-operations.update.max=1000 scorpio.registry.batch-operations.delete.max=1000 scorpio.registry.batch-operations.query.max=1000 -scorpio.topics.entity=ENTITY -scorpio.topics.entitybatch=ENTITYBATCH -scorpio.topics.registry=REGISTRY -scorpio.topics.temporal=TEMPORAL -scorpio.topics.internalnotification=I_NOTIFY -scorpio.topics.internalregsub=I_REGSUB -scorpio.topics.subalive=SUB_ALIVE -scorpio.topics.subsync=SUB_SYNC -scorpio.topics.regsubalive=REG_SUB_ALIVE -scorpio.topics.regsubsync=REG_SUB_SYNC -scorpio.topics.histsync=HIST_SUB_SYNC +scorpio.topics.entitybatch=${ENTITYBATCH_TOPIC:ENTITYBATCH} +scorpio.topics.entity=${ENTITY_TOPIC:ENTITY} +scorpio.topics.registry=${REGISTRY_TOPIC:REGISTRY} +scorpio.topics.temporal=${TEMPORAL_TOPIC:TEMPORAL} +scorpio.topics.internalnotification=${INTERNAL_NOTIFY_TOPIC:I_NOTIFY} +scorpio.topics.internalregsub=${INTERNAL_REGISTRYSUB_TOPIC:I_REGSUB} +scorpio.topics.subalive=${SUB_ALIVE_TOPIC:SUB_ALIVE} +scorpio.topics.subsync=${SUB_SYNC_TOPIC:SUB_SYNC} +scorpio.topics.regsubalive=${REGISTRYSUB_ALIVE_TOPIC:REG_SUB_ALIVE} +scorpio.topics.regsubsync=${REGISTRYSUB_SYNC_TOPIC:REG_SUB_SYNC} +# scorpio.topics.histsync=HIST_SUB_SYNC not used without history manager scorpio.entitymap.cleanup.ttl=30 sec scorpio.entitymap.cleanup.schedule=10s scorpio.startupdelay=5s @@ -70,11 +70,12 @@ quarkus.datasource.db-kind=postgresql quarkus.datasource.username=${mysettings.postgres.username} quarkus.datasource.password=${mysettings.postgres.password} quarkus.datasource.jdbc.url=${jdbcurl} -quarkus.datasource.reactive.url=postgresql://${mysettings.postgres.host}:${mysettings.postgres.port}/${mysettings.postgres.database-name} +quarkus.datasource.reactive.url=postgresql://${mysettings.postgres.host}:${mysettings.postgres.port}/${mysettings.postgres.database-name}?sslmode=require quarkus.datasource.reactive.shared=true quarkus.datasource.reactive.cache-prepared-statements=true quarkus.datasource.reactive.max-size=50 quarkus.datasource.reactive.idle-timeout=15s +quarkus.datasource.reactive.trust-all=true #quarkus.datasource.reactive.event-loop-size=100 quarkus.flyway.migrate-at-start=true quarkus.flyway.baseline-on-migrate=true @@ -87,4 +88,8 @@ quarkus.rest-client.atcontext-service.url=http://localhost:9090 scorpio.registry.subscription.checkinterval=30s scorpio.subscription.checkinterval=2s scorpio.fedupdaterate=600s -quarkus.http.limits.max-initial-line-length=50000 \ No newline at end of file +quarkus.http.limits.max-initial-line-length=50000 +#Keycloak +quarkus.oidc.auth-server-url=${KEYCLOAK_SERVER_URL}realms/${REALM} +quarkus.oidc.client-id=${CLIENT_ID} +quarkus.oidc.tls.verification=none \ No newline at end of file diff --git a/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql b/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..04e722ade 100644 --- a/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; diff --git a/AllInOneRunner/src/main/resources/dockerfiles/dockerfile-java b/AllInOneRunner/src/main/resources/dockerfiles/dockerfile-java index c29465889..b1e50e572 100644 --- a/AllInOneRunner/src/main/resources/dockerfiles/dockerfile-java +++ b/AllInOneRunner/src/main/resources/dockerfiles/dockerfile-java @@ -1,6 +1,4 @@ FROM openjdk:22-ea-21-jdk-slim WORKDIR /usr/src/scorpio COPY target/quarkus-app ./ -ENV DBHOST=postgres -ENV BUSHOST=kafka CMD java $MY_JAVA_SETTINGS -jar quarkus-run.jar diff --git a/BrokerParent/pom.xml b/BrokerParent/pom.xml index 15e88ab84..b1b92545b 100644 --- a/BrokerParent/pom.xml +++ b/BrokerParent/pom.xml @@ -207,6 +207,18 @@ io.quarkus quarkus-smallrye-reactive-messaging-kafka + + io.quarkus + quarkus-oidc + + + io.quarkus + quarkus-keycloak-authorization + + + jakarta.annotation + jakarta.annotation-api + diff --git a/EntityManager/pom.xml b/EntityManager/pom.xml index b41ad5f4d..862a5e15a 100644 --- a/EntityManager/pom.xml +++ b/EntityManager/pom.xml @@ -150,7 +150,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityBatchController.java b/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityBatchController.java index e15cf6dd0..4b69c8dff 100644 --- a/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityBatchController.java +++ b/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityBatchController.java @@ -14,6 +14,7 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; +import jakarta.annotation.security.RolesAllowed; import static eu.neclab.ngsildbroker.commons.tools.EntityTools.noConcise; import eu.neclab.ngsildbroker.commons.datatypes.results.NGSILDOperationResult; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -60,6 +61,7 @@ public class EntityBatchController { @POST @Path("/create") + @RolesAllowed({"Factory-Admin", "Factory-Writer"}) public Uni> createMultiple(HttpServerRequest request, List> compactedEntities, @QueryParam("localOnly") boolean localOnly) { List>> unis = Lists.newArrayList(); @@ -119,6 +121,7 @@ public Uni> createMultiple(HttpServerRequest request, @POST @Path("/upsert") + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> upsertMultiple(HttpServerRequest request, List> compactedEntities, @QueryParam(value = "options") String options, @QueryParam("localOnly") boolean localOnly) { @@ -186,6 +189,7 @@ public Uni> upsertMultiple(HttpServerRequest request, */ @POST @Path("/update") + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> appendMultiple(HttpServerRequest request, List> compactedEntities, @QueryParam(value = "options") String options, @QueryParam("localOnly") boolean localOnly) { @@ -237,6 +241,7 @@ public Uni> appendMultiple(HttpServerRequest request, @POST @Path("/delete") + @RolesAllowed("Factory-Admin") public Uni> deleteMultiple(HttpServerRequest request, String entityIdsStr, @QueryParam("localOnly") boolean localOnly) { List entityIds; diff --git a/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityController.java b/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityController.java index 42b713c40..f7aa5e39f 100644 --- a/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityController.java +++ b/EntityManager/src/main/java/eu/neclab/ngsildbroker/entityhandler/controller/EntityController.java @@ -30,6 +30,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.QueryParam; +import jakarta.annotation.security.RolesAllowed; /** * * @version 1.0 @@ -58,6 +59,7 @@ public class EntityController {// implements EntityHandlerInterface { */ @Path("/entities") @POST + @RolesAllowed({"Factory-Admin", "Factory-Writer"}) public Uni> createEntity(HttpServerRequest req, String bodyStr) { Map body; try { @@ -88,6 +90,7 @@ public Uni> createEntity(HttpServerRequest req, String body @PATCH @Path("/entities/{entityId}/attrs") + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> updateEntity(HttpServerRequest req, @PathParam("entityId") String entityId, String bodyStr) { Map body; @@ -117,6 +120,7 @@ public Uni> updateEntity(HttpServerRequest req, @PathParam( @POST @Path("/entities/{entityId}/attrs") + @RolesAllowed({"Factory-Admin", "Factory-Writer"}) public Uni> appendEntity(HttpServerRequest req, @PathParam("entityId") String entityId, String bodyStr, @QueryParam("options") String options) { Map body; @@ -147,6 +151,7 @@ public Uni> appendEntity(HttpServerRequest req, @PathParam( */ @PATCH @Path("/entities/{entityId}/attrs/{attrId}") + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> partialUpdateAttribute(HttpServerRequest req, @PathParam("entityId") String entityId, @PathParam("attrId") String attrib, String bodyStr) { Map body; @@ -188,6 +193,7 @@ public Uni> partialUpdateAttribute(HttpServerRequest req, @DELETE @Path("/entities/{entityId}/attrs/{attrId}") + @RolesAllowed("Factory-Admin") public Uni> deleteAttribute(HttpServerRequest request, @PathParam("entityId") String entityId, @PathParam("attrId") String attrId, @QueryParam("datasetId") String datasetId, @QueryParam("deleteAll") boolean deleteAll) { @@ -218,6 +224,7 @@ public Uni> deleteAttribute(HttpServerRequest request, @Pat */ @DELETE @Path("/entities/{entityId}") + @RolesAllowed("Factory-Admin") public Uni> deleteEntity(HttpServerRequest request, @PathParam("entityId") String entityId) { try { HttpUtils.validateUri(entityId); @@ -234,6 +241,7 @@ public Uni> deleteEntity(HttpServerRequest request, @PathPa @PATCH @Path("/entities/{entityId}") + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> mergePatch(HttpServerRequest request, @PathParam("entityId") String entityId, String bodyStr) { Map body; @@ -259,6 +267,7 @@ public Uni> mergePatch(HttpServerRequest request, @PathPara @Path("/entities/{entityId}") @PUT + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> replaceEntity(@PathParam("entityId") String entityId, HttpServerRequest request, String bodyStr) { logger.debug("replacing entity"); @@ -289,6 +298,7 @@ public Uni> replaceEntity(@PathParam("entityId") String ent @Path("/entities/{entityId}/attrs/{attrId}") @PUT + @RolesAllowed({"Factory-Admin", "Factory-Editor", "Factory-Writer"}) public Uni> replaceAttribute(@PathParam("attrId") String attrId, @PathParam("entityId") String entityId, HttpServerRequest request, String bodyStr) { logger.debug("replacing Attrs"); diff --git a/EntityManager/src/main/resources/db/migration/V20190604.1__entity.sql b/EntityManager/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..04e722ade 100644 --- a/EntityManager/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/EntityManager/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; diff --git a/QueryManager/pom.xml b/QueryManager/pom.xml index 99a3a05d9..684cbadb3 100644 --- a/QueryManager/pom.xml +++ b/QueryManager/pom.xml @@ -144,7 +144,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/EntityOperationsQueryController.java b/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/EntityOperationsQueryController.java index 042e91dfe..54b698990 100644 --- a/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/EntityOperationsQueryController.java +++ b/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/EntityOperationsQueryController.java @@ -11,6 +11,7 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; +import jakarta.annotation.security.RolesAllowed; import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -60,6 +61,7 @@ public class EntityOperationsQueryController { @Path("/query") @POST + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> postQuery(HttpServerRequest request, String bodyStr, @QueryParam(value = "limit") Integer limit, @QueryParam(value = "offset") int offset, @QueryParam(value = "options") String options, @QueryParam(value = "count") boolean count, diff --git a/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryController.java b/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryController.java index 4a7acc355..7a71ccfba 100644 --- a/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryController.java +++ b/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryController.java @@ -45,6 +45,7 @@ import eu.neclab.ngsildbroker.queryhandler.services.QueryService; import io.smallrye.mutiny.Uni; import io.vertx.core.http.HttpServerRequest; +import jakarta.annotation.security.RolesAllowed; @Singleton @Path("/ngsi-ld/v1") @@ -78,6 +79,7 @@ public class QueryController { */ @Path("/entities/{entityId}") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> getEntity(HttpServerRequest request, @QueryParam(value = "attrs") String attrs, @QueryParam(value = "options") String options, @QueryParam(value = "lang") String lang, @QueryParam(value = "geometryProperty") String geometryProperty, @@ -158,6 +160,7 @@ public Uni> getEntity(HttpServerRequest request, @QueryPara */ @Path("/entities") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> query(HttpServerRequest request, @QueryParam("id") String id, @QueryParam("type") String typeQuery, @QueryParam("idPattern") String idPattern, @QueryParam("attrs") String attrs, @QueryParam("q") String qInput, @QueryParam("csf") String csf, @@ -357,6 +360,7 @@ public Uni> query(HttpServerRequest request, @QueryParam("i @Path("/types") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> getAllTypes(HttpServerRequest request, @QueryParam(value = "details") boolean details, @QueryParam(value = "localOnly") boolean localOnly) { @@ -385,6 +389,7 @@ public Uni> getAllTypes(HttpServerRequest request, @Path("/types/{entityType}") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> getType(HttpServerRequest request, @PathParam("entityType") String type, @QueryParam(value = "localOnly") boolean localOnly) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll(HttpHeaders.ACCEPT)); @@ -409,6 +414,7 @@ public Uni> getType(HttpServerRequest request, @PathParam(" @Path("/attributes") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> getAllAttributes(HttpServerRequest request, @QueryParam(value = "details") boolean details, @QueryParam(value = "localOnly") boolean localOnly) { @@ -436,6 +442,7 @@ public Uni> getAllAttributes(HttpServerRequest request, @Path("/attributes/{attribute}") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Factory-Editor"}) public Uni> getAttribute(HttpServerRequest request, @PathParam("attribute") String attribute, @QueryParam(value = "details") boolean details, @QueryParam(value = "localOnly") boolean localOnly) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll(HttpHeaders.ACCEPT)); diff --git a/QueryManager/src/main/resources/db/migration/V20190604.1__entity.sql b/QueryManager/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..04e722ade 100644 --- a/QueryManager/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/QueryManager/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; diff --git a/RegistryManager/pom.xml b/RegistryManager/pom.xml index 6d2f70729..7d6e74703 100644 --- a/RegistryManager/pom.xml +++ b/RegistryManager/pom.xml @@ -44,7 +44,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/RegistryManager/src/main/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistryController.java b/RegistryManager/src/main/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistryController.java index c840c5cc9..7bf927fa5 100644 --- a/RegistryManager/src/main/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistryController.java +++ b/RegistryManager/src/main/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistryController.java @@ -10,6 +10,7 @@ import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.QueryParam; +import jakarta.annotation.security.RolesAllowed; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.resteasy.reactive.RestResponse; @@ -57,6 +58,7 @@ public class RegistryController { JsonLDService ldService; @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader"}) public Uni> queryCSource(HttpServerRequest request, @QueryParam("id") String ids, @QueryParam("type") String type, @QueryParam("idPattern") String idPattern, @QueryParam("attrs") String attrs, @QueryParam("q") String q, @QueryParam("csf") String csf, @@ -127,6 +129,7 @@ public Uni> queryCSource(HttpServerRequest request, @QueryP } @POST + @RolesAllowed("Factory-Admin") public Uni> registerCSource(HttpServerRequest request, String payload) { return HttpUtils.expandBody(request, payload, AppConstants.CSOURCE_REG_CREATE_PAYLOAD, ldService).onItem() .transformToUni(tuple -> { @@ -140,6 +143,7 @@ public Uni> registerCSource(HttpServerRequest request, Stri @Path("/{registrationId}") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader"}) public Uni> getCSourceById(HttpServerRequest request, @PathParam("registrationId") String registrationId) { logger.debug("get CSource() ::" + registrationId); @@ -165,6 +169,7 @@ public Uni> getCSourceById(HttpServerRequest request, @Path("/{registrationId}") @PATCH + @RolesAllowed("Factory-Admin") public Uni> updateCSource(HttpServerRequest request, @PathParam("registrationId") String registrationId, String payload) { return HttpUtils.expandBody(request, payload, AppConstants.CSOURCE_REG_UPDATE_PAYLOAD, ldService).onItem() @@ -179,6 +184,7 @@ public Uni> updateCSource(HttpServerRequest request, @Path("/{registrationId}") @DELETE + @RolesAllowed("Factory-Admin") public Uni> deleteCSource(HttpServerRequest request, @PathParam("registrationId") String registrationId) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll("Accept")); diff --git a/RegistryManager/src/main/resources/db/migration/V20190604.1__entity.sql b/RegistryManager/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..d327595ac 100644 --- a/RegistryManager/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/RegistryManager/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; \ No newline at end of file diff --git a/RegistrySubscriptionManager/pom.xml b/RegistrySubscriptionManager/pom.xml index 9d36e7542..553dccd57 100644 --- a/RegistrySubscriptionManager/pom.xml +++ b/RegistrySubscriptionManager/pom.xml @@ -156,7 +156,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/RegistrySubscriptionManager/src/main/java/eu/neclab/ngsildbroker/registry/subscriptionmanager/controller/RegistrySubscriptionController.java b/RegistrySubscriptionManager/src/main/java/eu/neclab/ngsildbroker/registry/subscriptionmanager/controller/RegistrySubscriptionController.java index 70789cc4b..b009ffb3b 100644 --- a/RegistrySubscriptionManager/src/main/java/eu/neclab/ngsildbroker/registry/subscriptionmanager/controller/RegistrySubscriptionController.java +++ b/RegistrySubscriptionManager/src/main/java/eu/neclab/ngsildbroker/registry/subscriptionmanager/controller/RegistrySubscriptionController.java @@ -22,6 +22,7 @@ import eu.neclab.ngsildbroker.registry.subscriptionmanager.service.RegistrySubscriptionService; import io.smallrye.mutiny.Uni; import io.vertx.core.http.HttpServerRequest; +import jakarta.annotation.security.RolesAllowed; @Singleton @Path("/ngsi-ld/v1/csourceSubscriptions") @@ -44,6 +45,7 @@ public class RegistrySubscriptionController { JsonLDService ldService; @POST + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> subscribe(HttpServerRequest request, String payload) { return HttpUtils.expandBody(request, payload, AppConstants.SUBSCRIPTION_CREATE_PAYLOAD, ldService).onItem() .transformToUni(tuple -> { @@ -54,6 +56,7 @@ public Uni> subscribe(HttpServerRequest request, String pay } @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader"}) public Uni> getAllSubscriptions(HttpServerRequest request, @QueryParam("limit") Integer limit, @QueryParam("offset") int offset, @QueryParam("options") String options) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll("Accept")); @@ -88,6 +91,7 @@ public Uni> getAllSubscriptions(HttpServerRequest request, @Path("/{id}") @GET + @RolesAllowed({"Factory-Admin", "Factory-Reader", "Subscriber"}) public Uni> getSubscriptionById(HttpServerRequest request, @PathParam(value = "id") String subscriptionId, @QueryParam(value = "options") String options) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll("Accept")); @@ -112,6 +116,7 @@ public Uni> getSubscriptionById(HttpServerRequest request, @Path("/{id}") @DELETE + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> deleteSubscription(HttpServerRequest request, @PathParam(value = "id") String id) { try { HttpUtils.validateUri(id); @@ -126,6 +131,7 @@ public Uni> deleteSubscription(HttpServerRequest request, @ @Path("/{id}") @PATCH + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> updateSubscription(HttpServerRequest request, @PathParam(value = "id") String id, String payload) { try { diff --git a/RegistrySubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql b/RegistrySubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..d327595ac 100644 --- a/RegistrySubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/RegistrySubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; \ No newline at end of file diff --git a/SubscriptionManager/pom.xml b/SubscriptionManager/pom.xml index 6f5356cac..ef1088c03 100644 --- a/SubscriptionManager/pom.xml +++ b/SubscriptionManager/pom.xml @@ -155,7 +155,7 @@ src/main/resources/dockerfiles/dockerfile-${os} - scorpiobroker/${project.artifactId} + ibn40/scorpio-${project.artifactId} ${docker-tag} ${project.build.finalName}-runner${nativeext} diff --git a/SubscriptionManager/src/main/java/eu/neclab/ngsildbroker/subscriptionmanager/controller/SubscriptionController.java b/SubscriptionManager/src/main/java/eu/neclab/ngsildbroker/subscriptionmanager/controller/SubscriptionController.java index c658d1401..cf3b73f3f 100644 --- a/SubscriptionManager/src/main/java/eu/neclab/ngsildbroker/subscriptionmanager/controller/SubscriptionController.java +++ b/SubscriptionManager/src/main/java/eu/neclab/ngsildbroker/subscriptionmanager/controller/SubscriptionController.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import jakarta.annotation.security.RolesAllowed; @Path("/ngsi-ld/v1/subscriptions") public class SubscriptionController { @@ -49,6 +50,7 @@ public class SubscriptionController { JsonLDService ldService; @POST + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> subscribe(HttpServerRequest request, Map map) { try{ if(!map.containsKey(NGSIConstants.JSONLD_CONTEXT)){ @@ -84,6 +86,7 @@ public Uni> subscribe(HttpServerRequest request, Map> getAllSubscriptions(HttpServerRequest request, @QueryParam("limit") Integer limit, @QueryParam("offset") int offset, @QueryParam("options") String options) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll("Accept")); @@ -116,6 +119,7 @@ public Uni> getAllSubscriptions(HttpServerRequest request, @Path("/{id}") @GET + @RolesAllowed({"Factory-Admin, Subscriber, Factory-Reader"}) public Uni> getSubscriptionById(HttpServerRequest request, @PathParam(value = "id") String subscriptionId, @QueryParam(value = "options") String options) { int acceptHeader = HttpUtils.parseAcceptHeader(request.headers().getAll("Accept")); @@ -139,6 +143,7 @@ public Uni> getSubscriptionById(HttpServerRequest request, @Path("/{id}") @DELETE + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> deleteSubscription(HttpServerRequest request, @PathParam(value = "id") String id) { try { HttpUtils.validateUri(id); @@ -153,6 +158,7 @@ public Uni> deleteSubscription(HttpServerRequest request, @ @Path("/{id}") @PATCH + @RolesAllowed({"Factory-Admin", "Subscriber"}) public Uni> updateSubscription(HttpServerRequest request, @PathParam(value = "id") String id, Map map) { try { diff --git a/SubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql b/SubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql index a8259f8bf..d327595ac 100644 --- a/SubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql +++ b/SubscriptionManager/src/main/resources/db/migration/V20190604.1__entity.sql @@ -54,4 +54,6 @@ CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace); -- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys -- check https://www.postgresql.org/docs/current/static/datatype-json.html -CREATE INDEX i_entity_data ON entity USING GIN (data); +CREATE INDEX i_entity_data ON entity USING GIN (data); + +ALTER TABLE public.entity REPLICA IDENTITY FULL; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 88497a89f..2ce14f6ed 100644 --- a/pom.xml +++ b/pom.xml @@ -15,14 +15,14 @@ BrokerParent Commons - at-context-server + EntityManager QueryManager SubscriptionManager RegistryManager RegistrySubscriptionManager - HistoryEntityManager - HistoryQueryManager + AllInOneRunner