diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/AbstractAuthenticationPropagationHeadersFactory.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/AbstractAuthenticationPropagationHeadersFactory.java index 2f9c1a04..069c7cff 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/AbstractAuthenticationPropagationHeadersFactory.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/AbstractAuthenticationPropagationHeadersFactory.java @@ -7,6 +7,8 @@ import jakarta.ws.rs.core.MultivaluedMap; import org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.quarkiverse.openapi.generator.OpenApiGeneratorConfig; @@ -23,6 +25,8 @@ public abstract class AbstractAuthenticationPropagationHeadersFactory implements protected OpenApiGeneratorConfig generatorConfig; protected HeadersProvider headersProvider; + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAuthenticationPropagationHeadersFactory.class); + protected AbstractAuthenticationPropagationHeadersFactory(BaseCompositeAuthenticationProvider compositeProvider, OpenApiGeneratorConfig generatorConfig, HeadersProvider headersProvider) { @@ -36,6 +40,11 @@ public MultivaluedMap update(MultivaluedMap inco MultivaluedMap clientOutgoingHeaders) { MultivaluedMap propagatedHeaders = new MultivaluedHashMap<>(); MultivaluedMap providedHeaders = headersProvider.getStringHeaders(generatorConfig); + + LOGGER.debug("Incoming headers keys{}", incomingHeaders.keySet()); + LOGGER.debug("Outgoing headers keys{}", clientOutgoingHeaders.keySet()); + LOGGER.debug("Provided headers keys{}", providedHeaders.keySet()); + compositeProvider.getAuthenticationProviders().stream() .filter(AbstractAuthProvider.class::isInstance) .map(AbstractAuthProvider.class::cast) @@ -46,9 +55,14 @@ public MultivaluedMap update(MultivaluedMap inco // get priority to the headers coming from the headers provider. List headerValue = providedHeaders.get(headerName); if (headerValue == null) { - // lastly look into the incoming headers. + // next, look into the incoming headers. headerValue = incomingHeaders.get(headerName); } + if (headerValue == null) { + // lastly look into the outgoing headers. + headerValue = clientOutgoingHeaders.get(headerName); + } + if (headerValue != null) { propagatedHeaders.put(propagationHeaderName(authProvider.getOpenApiSpecId(), authProvider.getName(), diff --git a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java index 511b9112..035f4939 100644 --- a/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java +++ b/client/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/BearerAuthenticationProvider.java @@ -6,6 +6,9 @@ import jakarta.ws.rs.client.ClientRequestContext; import jakarta.ws.rs.core.HttpHeaders; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Provides bearer token authentication or any other valid scheme. * @@ -14,6 +17,7 @@ public class BearerAuthenticationProvider extends AbstractAuthProvider { private final String scheme; + private static final Logger LOGGER = LoggerFactory.getLogger(BearerAuthenticationProvider.class); public BearerAuthenticationProvider(final String openApiSpecId, final String name, final String scheme, List operations, CredentialsProvider credentialsProvider) { @@ -23,6 +27,7 @@ public BearerAuthenticationProvider(final String openApiSpecId, final String nam @Override public void filter(ClientRequestContext requestContext) throws IOException { + LOGGER.debug("Headers keys set in incoming requestContext: {}", requestContext.getHeaders().keySet()); String bearerToken = getBearerToken(requestContext); if (isTokenPropagation()) { @@ -32,6 +37,7 @@ public void filter(ClientRequestContext requestContext) throws IOException { if (!bearerToken.isBlank()) { requestContext.getHeaders().add(HttpHeaders.AUTHORIZATION, AuthUtils.authTokenOrBearer(this.scheme, bearerToken)); } + LOGGER.debug("Header keys set in filtered requestContext: {}", requestContext.getHeaders().keySet()); } private String getBearerToken(ClientRequestContext requestContext) {