wmedvede commented on code in PR #3928:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3928#discussion_r2218737344


##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow/src/main/java/org/kie/kogito/serverless/workflow/openapi/OpenApiCustomCredentialProvider.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.kie.kogito.serverless.workflow.openapi;
+
+import java.util.Collections;
+import java.util.Optional;
+
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.quarkiverse.openapi.generator.providers.ConfigCredentialsProvider;
+import io.quarkiverse.openapi.generator.providers.CredentialsContext;
+import io.quarkus.arc.Arc;
+import io.quarkus.oidc.client.OidcClient;
+import io.quarkus.oidc.client.OidcClientConfig;
+import io.quarkus.oidc.client.OidcClientException;
+import io.quarkus.oidc.client.OidcClients;
+import io.quarkus.oidc.client.Tokens;
+import io.quarkus.runtime.configuration.ConfigurationException;
+
+import jakarta.annotation.Priority;
+import jakarta.enterprise.context.RequestScoped;
+import jakarta.enterprise.inject.Alternative;
+import jakarta.enterprise.inject.Specializes;
+import jakarta.ws.rs.core.HttpHeaders;
+
+import static 
io.quarkiverse.openapi.generator.providers.AbstractAuthProvider.getHeaderName;
+
+@RequestScoped
+@Alternative
+@Specializes
+@Priority(200)
+public class OpenApiCustomCredentialProvider extends ConfigCredentialsProvider 
{
+    private static final String CANONICAL_EXCHANGE_TOKEN_PROPERTY_NAME = 
"sonataflow.security.%s.exchange-token";

Review Comment:
   In the open api generator, we follow this pattern to configure different 
security schema properties.
   
   e.g.
   
   
quarkus.openapi-generator.my_external_service_yaml.**auth**.my_securituy_scheme.token-propagation
   
   For this new property, Id recommend using this:
   
   sonataflow.security.**auth**.my_securituy_scheme.exchange-token
   
   I think looks more consistent and also establishes that we are not setting a 
global sonataflow  security prop, but a one related with authentication.
   
   
   
   



##########
quarkus/extensions/kogito-quarkus-serverless-workflow-extension/kogito-quarkus-serverless-workflow-integration-test/src/main/resources/application.properties:
##########
@@ -223,6 +223,51 @@ quarkus.oidc-client.service5_oauth2.grant.type=client
 quarkus.oidc-client.service5_oauth2.credentials.client-secret.method=basic
 quarkus.oidc-client.service5_oauth2.credentials.client-secret.value=secret
 
+# -------
+# Token propagation support test properties, relates to the TokenExchangeIT 
and the token-exchange.sw.json
+# -------
+# 1) Configure the desired packages for the code generation, this information 
is basically source
+quarkus.openapi-generator.codegen.spec.token_exchange_external_service_yaml.base-package=org.acme.externalexchangeservice
+
+# 2) Configure the access url for the service.
+quarkus.rest-client.token_exchange_external_service_yaml.url=${exchange-external-service-mock.url}
+sonataflow.security.with_exchange_oauth2.exchange-token=true
+sonataflow.security.with_exchange_and_propagation_oauth2.exchange-token=true

Review Comment:
   Sorry for the silly question, maybe I misunderstood:
   
   In **case 1**)  
   
   sonataflow.security.with_exchange_oauth2.exchange-token=true
   
   1) we exchange the token, so the WF gets a new token, to access the service.
   2) we pass the exchanged token
   
   
   In **case 2**) 
   
   
quarkus.openapi-generator.token_exchange_external_service_yaml.auth.with_exchange_and_propagation_oauth2.token-propagation=true
   
   we do this:
   
   1) no exchange is produced
   2) and, given that token propagation == true, we just propagate it.
   
   Is that correct?
   
   
   
    
   



-- 
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]

Reply via email to