Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160466750


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+
+String strategyName = (String) strategyParam;
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATED -> getPropagatedTokenFromHeaders(item);
+case CONFIGURED -> getConfiguredToken(item, parameters);
+default -> {
+logger.debug("Strategy {} is NONE or unknown, skipping", 
strategyName);
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedTokenFromHeaders(KogitoWorkItem 
item) {
+
+KogitoProcessInstance processInstance = item.getProcessInstance();
+if (processInstance == null) {
+logger.debug("No process instance available, cannot propagate 
token");
+return Optional.empty();
+}
+
+try {
+// Cast to ProcessInstanceImpl to access getKnowledgeRuntime()
+if (!(processInstance instanceof 
org.jbpm.process.instance.ProcessInstance)) {
+logger.debug("Process instance is not a jBPM ProcessInstance, 
cannot access runtime");
+return Opti

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160409248


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");

Review Comment:
   As per the UI design, `none` will be selected by default in the 
Authentication strategy dropdown.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160409248


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");

Review Comment:
   As per the UI design, `none` will be selected by default.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160347757


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+
+String strategyName = (String) strategyParam;
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATED -> getPropagatedTokenFromHeaders(item);
+case CONFIGURED -> getConfiguredToken(item, parameters);
+default -> {
+logger.debug("Strategy {} is NONE or unknown, skipping", 
strategyName);
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedTokenFromHeaders(KogitoWorkItem 
item) {
+
+KogitoProcessInstance processInstance = item.getProcessInstance();
+if (processInstance == null) {
+logger.debug("No process instance available, cannot propagate 
token");
+return Optional.empty();
+}
+
+try {
+// Cast to ProcessInstanceImpl to access getKnowledgeRuntime()
+if (!(processInstance instanceof 
org.jbpm.process.instance.ProcessInstance)) {
+logger.debug("Process instance is not a jBPM ProcessInstance, 
cannot access runtime");
+return Opti

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160358214


##
kogito-workitems/kogito-rest-workitem/src/test/java/org/kogito/workitem/rest/decorators/TokenPropagationDecoratorTest.java:
##
@@ -0,0 +1,269 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.drools.core.common.InternalKnowledgeRuntime;
+import org.jbpm.process.instance.InternalProcessRuntime;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.kie.kogito.Application;
+import org.kie.kogito.Config;
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+public class TokenPropagationDecoratorTest {
+
+private static final String CONFIGURED_TOKEN = "configured-token-12345";
+private static final String PROPAGATED_TOKEN = "propagated-token-67890";
+private static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";

Review Comment:
   Review comments addressed.



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160342911


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+
+String strategyName = (String) strategyParam;
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATED -> getPropagatedTokenFromHeaders(item);
+case CONFIGURED -> getConfiguredToken(item, parameters);
+default -> {
+logger.debug("Strategy {} is NONE or unknown, skipping", 
strategyName);
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedTokenFromHeaders(KogitoWorkItem 
item) {
+
+KogitoProcessInstance processInstance = item.getProcessInstance();
+if (processInstance == null) {

Review Comment:
   Review comments addressed.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscr

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160336442


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";

Review Comment:
   Changes are done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160334147


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+
+String strategyName = (String) strategyParam;
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATED -> getPropagatedTokenFromHeaders(item);
+case CONFIGURED -> getConfiguredToken(item, parameters);
+default -> {
+logger.debug("Strategy {} is NONE or unknown, skipping", 
strategyName);
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedTokenFromHeaders(KogitoWorkItem 
item) {
+
+KogitoProcessInstance processInstance = item.getProcessInstance();
+if (processInstance == null) {
+logger.debug("No process instance available, cannot propagate 
token");
+return Optional.empty();
+}
+
+try {
+// Cast to ProcessInstanceImpl to access getKnowledgeRuntime()
+if (!(processInstance instanceof 
org.jbpm.process.instance.ProcessInstance)) {
+logger.debug("Process instance is not a jBPM ProcessInstance, 
cannot access runtime");
+return Opti

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-29 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3160331971


##
jbpm/process-workitems/src/main/java/org/kie/kogito/process/workitems/impl/KogitoWorkItemImpl.java:
##
@@ -251,7 +251,18 @@ public String toString() {
 Map.Entry entry = iterator.next();
 b.append(entry.getKey());
 b.append("=");
-b.append(entry.getValue());
+Object value = entry.getValue();
+// Mask sensitive token data for both legacy propagateToken and 
new AccessTokenAcquisitionStrategy
+if (("propagateToken".equals(entry.getKey()) || 
"AccessTokenAcquisitionStrategy".equals(entry.getKey())) && value != null) {

Review Comment:
   Review comment addressed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-28 Thread via GitHub


pefernan commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3152952207


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,195 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.ProcessConfig;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATED("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (!(strategyParam instanceof String)) {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+
+String strategyName = (String) strategyParam;
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATED -> getPropagatedTokenFromHeaders(item);
+case CONFIGURED -> getConfiguredToken(item, parameters);
+default -> {
+logger.debug("Strategy {} is NONE or unknown, skipping", 
strategyName);
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedTokenFromHeaders(KogitoWorkItem 
item) {
+
+KogitoProcessInstance processInstance = item.getProcessInstance();
+if (processInstance == null) {
+logger.debug("No process instance available, cannot propagate 
token");
+return Optional.empty();
+}
+
+try {
+// Cast to ProcessInstanceImpl to access getKnowledgeRuntime()
+if (!(processInstance instanceof 
org.jbpm.process.instance.ProcessInstance)) {
+logger.debug("Process instance is not a jBPM ProcessInstance, 
cannot access runtime");
+return Optional.e

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-28 Thread via GitHub


jomarko commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3152323778


##
jbpm/process-workitems/src/main/java/org/kie/kogito/process/workitems/impl/KogitoWorkItemImpl.java:
##
@@ -251,7 +251,18 @@ public String toString() {
 Map.Entry entry = iterator.next();
 b.append(entry.getKey());
 b.append("=");
-b.append(entry.getValue());
+Object value = entry.getValue();
+// Mask sensitive token data for both legacy propagateToken and 
new AccessTokenAcquisitionStrategy
+if (("propagateToken".equals(entry.getKey()) || 
"AccessTokenAcquisitionStrategy".equals(entry.getKey())) && value != null) {

Review Comment:
   maybe we should use existing constant?
   
   `ACCESS_TOKEN_ACQUISITION_STRATEGY`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-23 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3130210130


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (strategyParam instanceof java.util.List) {

Review Comment:
   Changes are done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-23 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3130209170


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (strategyParam instanceof java.util.List) {
+
+@SuppressWarnings("unchecked")
+java.util.List strategies = (java.util.List) 
strategyParam;
+for (String strategyName : strategies) {
+Optional token = 
tryStrategyWithoutFallback(strategyName, item, parameters);
+if (token.isPresent()) {
+logger.debug("Strategy {} succeeded from list, token 
acquired", strategyName);
+return token;
+}
+logger.debug("Strategy {} failed from list, trying next", 
strategyName);
+}
+return Optional.empty();
+} else if (strategyParam instanceof String) {
+
+return tryStrategyWithFallback((String) strategyParam, item, 
parameters);
+} else {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+}
+
+private Optional tryStrategyWithFallback(String strategyName, 
KogitoWorkItem item, Map parameters) {
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATE -> getPropagatedTokenFromHeaders(item)
+.or(() -> getConfiguredToken(item, parameters));
+case CONFIGURED -> getConfiguredToken(item, parameters);
+

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-23 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3130207966


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagated");

Review Comment:
   Changes are done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-20 Thread via GitHub


pefernan commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r329369


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (strategyParam instanceof java.util.List) {
+
+@SuppressWarnings("unchecked")
+java.util.List strategies = (java.util.List) 
strategyParam;
+for (String strategyName : strategies) {
+Optional token = 
tryStrategyWithoutFallback(strategyName, item, parameters);
+if (token.isPresent()) {
+logger.debug("Strategy {} succeeded from list, token 
acquired", strategyName);
+return token;
+}
+logger.debug("Strategy {} failed from list, trying next", 
strategyName);
+}
+return Optional.empty();
+} else if (strategyParam instanceof String) {
+
+return tryStrategyWithFallback((String) strategyParam, item, 
parameters);
+} else {
+logger.debug("No token acquisition strategy specified, skipping 
authentication");
+return Optional.empty();
+}
+}
+
+private Optional tryStrategyWithFallback(String strategyName, 
KogitoWorkItem item, Map parameters) {
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(strategyName);
+
+return switch (strategy) {
+case PROPAGATE -> getPropagatedTokenFromHeaders(item)
+.or(() -> getConfiguredToken(item, parameters));
+case CONFIGURED -> getConfiguredToken(item, parameters);
+  

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-20 Thread via GitHub


pefernan commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r322599


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.process.workitems.impl.ConfigResolverHolder;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagated");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+private static final String AUTHORIZATION_HEADER = "Authorization";
+private static final String BEARER_PREFIX = "Bearer ";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+Optional bearerToken = getBearerToken(item, parameters);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(KogitoWorkItem item, Map 
parameters) {
+Object strategyParam = 
parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY);
+
+if (strategyParam instanceof java.util.List) {

Review Comment:
   @Christine-Jose for now it will be just a single value, no need to check for 
multiple options.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-08 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3051338747


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   Changes are added.



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/RequestDecorator.java:
##
@@ -21,9 +21,10 @@
 import java.util.Map;
 
 import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
 
 import io.vertx.mutiny.ext.web.client.HttpRequest;
 
 public interface RequestDecorator {
-public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request);
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler);

Review Comment:
   Review comment addressed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-08 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3051336731


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);

Review Comment:
   Review comment addressed.



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);

Review Comment:
   Review comment addressed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-08 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3051335257


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,113 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
+import org.kie.kogito.process.ProcessConfig;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagate");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler) {
+Optional bearerToken = getBearerToken(parameters, handler);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(Map parameters, 
KogitoWorkItemHandler handler) {
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(
+(String) parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY));
+
+return switch (strategy) {
+case PROPAGATE -> getPropagatedToken(handler)
+.or(() -> getConfiguredToken(parameters));
+case CONFIGURED -> getConfiguredToken(parameters);
+default -> {
+logger.debug("No token acquisition strategy specified or 
strategy is NONE, skipping authentication");
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedToken(KogitoWorkItemHandler handler) 
{
+AuthTokenProvider provider = handler.getApplication()
+.config()
+.get(ProcessConfig.class)
+.authTokenProvider();

Review Comment:
   Review comment addressed.



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -163,7 +165,7 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 path += "?" + query;
 }
 } catch (MalformedURLException ex) {
-logger.debug("Parameter endpoint {} is not valid uri {}", 
endPoint, ex.getMessage());
+logger.info("Parameter endpoint {} is not valid uri {}", endPoint, 
ex.getMessage());

Review Comment:
   Review comment addressed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specif

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-04-08 Thread via GitHub


Christine-Jose commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r3051333644


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,113 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
+import org.kie.kogito.process.ProcessConfig;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagate");

Review Comment:
   Changes are done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2997482801


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In other words, essentially this class should not have been modified, the 
AuthDecorator can be done without changing anything here. 



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In other words, essentially this class should not have been modified, the 
AuthDecorator can be implemented without changing anything here. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2997475547


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/RequestDecorator.java:
##
@@ -21,9 +21,10 @@
 import java.util.Map;
 
 import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
 
 import io.vertx.mutiny.ext.web.client.HttpRequest;
 
 public interface RequestDecorator {
-public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request);
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler);

Review Comment:
   I do not think there is need to change the interface and all implementation 
classes, see comments below



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2995930668


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/auth/ApiKeyAuthDecorator.java:
##
@@ -51,7 +52,7 @@ public ApiKeyAuthDecorator(String paramName, Location 
location) {
 }
 
 @Override
-public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler) {

Review Comment:
   Why do we need the KogitoWorkItemHandler in the decorator?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996001045


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);

Review Comment:
   same here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996003847


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);

Review Comment:
   And this existed because the previos logs were not always printed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996059182


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In my opinion, The handler should not be a explicit argument for the 
decorator. You are passing it because you want to access to the application 
object (to retrieve the authprovider) in one of the implementations. 
   Even when keeping the current approach (which Im not sure is useful because 
I cannot see how header propagation for a particular process instance is going 
to work) the `KogitoWorkItem` has access to the `KogitoProcessInstance` and 
from there you will have access to `InternalProcessRuntime`, which has also 
access to the Kogito Application, so this extra parameter and all the changes 
in all decorators, are not needed and should be reverted 
   See access to InternalProcessRuntime from ProcessInstance  here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessInstance.java#L53
 and ProcessInstance from KogitoWorkItem here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/api/kogito-api/src/main/java/org/kie/kogito/internal/process/workitem/KogitoWorkItem.java#L92
 
   Therefore, the decorator interface should have not been changed, because 
application was already accesible throuw KogitoWorkITem (basically anything you 
will ever need will be there)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996169766


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,113 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
+import org.kie.kogito.process.ProcessConfig;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagate");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler) {
+Optional bearerToken = getBearerToken(parameters, handler);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(Map parameters, 
KogitoWorkItemHandler handler) {
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(
+(String) parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY));
+
+return switch (strategy) {
+case PROPAGATE -> getPropagatedToken(handler)
+.or(() -> getConfiguredToken(parameters));
+case CONFIGURED -> getConfiguredToken(parameters);
+default -> {
+logger.debug("No token acquisition strategy specified or 
strategy is NONE, skipping authentication");
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedToken(KogitoWorkItemHandler handler) 
{
+AuthTokenProvider provider = handler.getApplication()
+.config()
+.get(ProcessConfig.class)
+.authTokenProvider();

Review Comment:
   If you want to stick with the current approach (token propagation handled 
globally and not per header instance) at least avoid changing the decorator 
interface (see 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996059182)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: co

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996059182


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In my opinion, The handler should not be a explicit argument for the 
decorator. You are passing it because you want to access to the application 
object (to retrieve the authprovider) in one of the implementations. 
   Even when keeping the current approach (which Im not sure is useful because 
I cannot see how header propagation for a particular process instance is going 
to work) the KogitoWorkItem has access to the KogitoProcessInstance and from 
there you will have access to InternalProcessRuntime, which has also access to 
the Kogito Application, so this extra parameter and all the changes in all 
decorators, are not needed and should be reverted 
   See access to InternalProcessRuntime from ProcessInstance  here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessInstance.java#L53
 and ProcessInstance from KogitoWorkItem here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/api/kogito-api/src/main/java/org/kie/kogito/internal/process/workitem/KogitoWorkItem.java#L92
 
   Therefore, the decorator interface should have not been changed, because 
application was already accesible throuw KogitoWorkITem (basically anything you 
will ever need will be there)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996059182


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In my opinion, The handler should not be a explicit argument for the 
decorator. You are passing it because you want to access to the application 
object (to retrieve the authprovider) in one of the implementations. 
   Even when keeping the current approach (which Im not sure is useful because 
I cannot see how header propagation for a particular process instance is going 
to work) the KogitoWorkItem has access to the KogitoProcessInstance and from 
there you will have access to KogitoProcessRuntime, which has also access to 
the application, so this extra parameter and all the changes in all decorators, 
are not needed and should be reverted 
   



##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In my opinion, The handler should not be a explicit argument for the 
decorator. You are passing it because you want to access to the application 
object (to retrieve the authprovider) in one of the implementations. 
   Even when keeping the current approach (which Im not sure is useful because 
I cannot see how header propagation for a particular process instance is going 
to work) the KogitoWorkItem has access to the KogitoProcessInstance and from 
there you will have access to KogitoProcessRuntime, which has also access to 
the Kogito Application, so this extra parameter and all the changes in all 
decorators, are not needed and should be reverted 
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2995998488


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -163,7 +165,7 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 path += "?" + query;
 }
 } catch (MalformedURLException ex) {
-logger.debug("Parameter endpoint {} is not valid uri {}", 
endPoint, ex.getMessage());
+logger.info("Parameter endpoint {} is not valid uri {}", endPoint, 
ex.getMessage());

Review Comment:
   This was debug for a good reason, we do not want to pollute the log for 
every rest call



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2996059182


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/RestWorkItemHandler.java:
##
@@ -176,19 +178,18 @@ public Optional 
activateWorkItemHandler(KogitoWorkItemManage
 }
 if (isEmpty(path)) {
 path = endPoint;
-logger.debug("Path is empty, using whole endpoint {}", endPoint);
+logger.info("Path is empty, using whole endpoint {}", endPoint);
 }
 if (isEmpty(protocol)) {
 protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : 
HTTP_PROTOCOL;
 }
-logger.debug("Invoking request with protocol {} host {} port {} and 
endpoint {}", protocol, host, port, path);
 
 WebClient client = isHttps(protocol) ? httpsClient : httpClient;
 HttpRequest request = client.request(method, port, host, path);
 WorkItemRecordParameters.recordInputParameters(workItem, parameters);
-requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request));
-authDecorators.forEach(d -> d.decorate(workItem, parameters, request));
-paramsDecorator.decorate(workItem, parameters, request);
+requestDecorators.forEach(d -> d.decorate(workItem, parameters, 
request, handler));

Review Comment:
   In my opinion, The handler should not be a explicit argument for the 
decorator. You are passing it because you want to access to the application 
object (to retrieve the authprovider) in one of the implementations. 
   Even when keeping the current approach (which Im not sure is useful because 
I cannot see how header propagation for a particular process instance is going 
to work) the KogitoWorkItem has access to the KogitoProcessInstance and from 
there you will have access to InternalProcessRuntime, which has also access to 
the Kogito Application, so this extra parameter and all the changes in all 
decorators, are not needed and should be reverted 
   See access to InternalProcessRuntime from ProcessInstance  here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessInstance.java#L53
 and ProcessInstance from KogitoWorkItem here 
https://github.com/apache/incubator-kie-kogito-runtimes/blob/main/api/kogito-api/src/main/java/org/kie/kogito/internal/process/workitem/KogitoWorkItem.java#L92
 
   Therefore, the decorator interface should have not been changed. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2995958526


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,113 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
+import org.kie.kogito.process.ProcessConfig;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagate");
+
+private String name;
+
+AccessTokenAcquisitionStrategy(String name) {
+this.name = name;
+}
+
+public String getName() {
+return name;
+}
+
+public static AccessTokenAcquisitionStrategy fromName(String strategyName) 
{
+return Arrays.stream(AccessTokenAcquisitionStrategy.values())
+.filter(strategy -> strategy.getName().equals(strategyName))
+.findFirst()
+.orElse(NONE);
+}
+}
+
+public class TokenPropagationDecorator implements AuthDecorator {
+
+private static final Logger logger = 
LoggerFactory.getLogger(TokenPropagationDecorator.class);
+
+public static final String ACCESS_TOKEN_ACQUISITION_STRATEGY = 
"AccessTokenAcquisitionStrategy";
+
+private static final String PROPAGATE_TOKEN_PARAM = "propagateToken";
+
+@Override
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler) {
+Optional bearerToken = getBearerToken(parameters, handler);
+
+bearerToken.ifPresentOrElse(
+token -> {
+logger.debug("Rest workItem `{}`: Bearer token available, 
request will be sent with authentication", item.getNodeInstance().getId());
+request.bearerTokenAuthentication(token);
+},
+() -> logger.debug("Rest workItem `{}`: No Bearer Token 
available, request will be sent without authentication", 
item.getNodeInstance().getId()));
+}
+
+Optional getBearerToken(Map parameters, 
KogitoWorkItemHandler handler) {
+AccessTokenAcquisitionStrategy strategy = 
AccessTokenAcquisitionStrategy.fromName(
+(String) parameters.get(ACCESS_TOKEN_ACQUISITION_STRATEGY));
+
+return switch (strategy) {
+case PROPAGATE -> getPropagatedToken(handler)
+.or(() -> getConfiguredToken(parameters));
+case CONFIGURED -> getConfiguredToken(parameters);
+default -> {
+logger.debug("No token acquisition strategy specified or 
strategy is NONE, skipping authentication");
+yield Optional.empty();
+}
+};
+}
+
+private Optional getPropagatedToken(KogitoWorkItemHandler handler) 
{
+AuthTokenProvider provider = handler.getApplication()
+.config()
+.get(ProcessConfig.class)
+.authTokenProvider();

Review Comment:
   I think that the token propagation should basically take the token from the 
process instance headers and propagate in all rest call done by this process 
instance, you do no need an application level object to to that, hence do you 
need to pass the KogitoWorkItemHandler to the decorators, hence you do not need 
to change a ton of classes. 
   We should have discussed the desing before starting this PR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---

Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-26 Thread via GitHub


fjtirado commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2995930668


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/auth/ApiKeyAuthDecorator.java:
##
@@ -51,7 +52,7 @@ public ApiKeyAuthDecorator(String paramName, Location 
location) {
 }
 
 @Override
-public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request) {
+public void decorate(KogitoWorkItem item, Map parameters, 
HttpRequest request, KogitoWorkItemHandler handler) {

Review Comment:
   Why do we need the KogitoWorkItemHandler in the decorator?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] REST-WorkItemHandler implementation in kogito-rest-workitems [incubator-kie-kogito-runtimes]

2026-03-25 Thread via GitHub


martinweiler commented on code in PR #4213:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4213#discussion_r2990195275


##
kogito-workitems/kogito-rest-workitem/src/main/java/org/kogito/workitem/rest/decorators/TokenPropagationDecorator.java:
##
@@ -0,0 +1,113 @@
+/*
+ * 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.kogito.workitem.rest.decorators;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+
+import org.kie.kogito.auth.AuthTokenProvider;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItem;
+import org.kie.kogito.internal.process.workitem.KogitoWorkItemHandler;
+import org.kie.kogito.process.ProcessConfig;
+import org.kogito.workitem.rest.auth.AuthDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vertx.mutiny.ext.web.client.HttpRequest;
+
+enum AccessTokenAcquisitionStrategy {
+NONE("none"),
+CONFIGURED("configured"),
+PROPAGATE("propagate");

Review Comment:
   This should be `propagated` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]