Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"[ISSUE] Proxy Authentication fails with openapi-generator-maven-plugin during API spec download" #2124

Open
jmakam opened this issue Oct 8, 2024 · 0 comments

Comments

@jmakam
Copy link

jmakam commented Oct 8, 2024

Description

I am encountering an issue with the openapi-generator-maven-plugin (version 6.2.1) while attempting to generate API stubs from a remote OpenAPI specification file hosted on SwaggerHub. The build process consistently fails due to what appears to be incorrect handling of proxy credentials.

Our build environment is behind a corporate proxy that requires basic authentication. The proxy is configured correctly, and the SwaggerHub URL is whitelisted and accessible from within the build pipeline. However, the openapi-generator-maven-plugin, which relies on the Swagger parser for handling the OpenAPI spec, seems unable to pass the provided proxy credentials when attempting to access external URLs. This results in the failure to download the OpenAPI specification.

From my observations, it seems the Swagger parser is not handling the proxy credentials as expected. Could this be an issue with the way the Swagger parser manages proxy authentication?

Is there a known workaround, or is there any additional configuration that might ensure proper handling of proxy credentials in this scenario?

Environment

openapi-generator-maven-plugin: 6.2.1
Maven: 3.x
JDK: OpenJDK 17
Build Environment: Docker (Alpine-based container in AWS CodePipeline)

What I've Tried

Configuring proxy credentials in settings.xml:

<proxies>
  <proxy>
    <id>http-proxy</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>proxy.resources.vwapps.cloud</host>
    <port>8080</port>
    <username>username</username>
    <password>password</password>
    <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
  </proxy>
</proxies>

Enabling basic authentication with the following flags:

-Djdk.http.auth.tunneling.disabledSchemes= \
-Djdk.http.auth.proxying.disabledSchemes=

Setting the proxy values within the Maven command:

mvn clean package -DskipTests -Dmaven.javadoc.skip=true \
  -Dhttp.proxyHost=${PROXY_HOST} \
  -Dhttp.proxyPort=${PROXY_HTTP_PORT} \
  -Dhttp.proxyUser=${PROXY_USERNAME} \
  -Dhttp.proxyPassword=${PROXY_PASSWORD} \
  -Dhttps.proxyHost=${PROXY_HOST} \
  -Dhttps.proxyPort=${PROXY_HTTPS_PORT} \
  -Dhttps.proxyUser=${PROXY_USERNAME} \
  -Dhttps.proxyPassword=${PROXY_PASSWORD} \
  -Dhttp.nonProxyHosts="localhost,127.0.0.1" \
  -Dhttps.nonProxyHosts="localhost,127.0.0.1" \
  -Djdk.http.auth.tunneling.disabledSchemes= \
  -Djdk.http.auth.proxying.disabledSchemes=

None of these approaches resolved the issue. I also tried setting the flags within MAVEN_OPTS, JAVA_OPT, and JAVA_TOOL_OPTIONS, with no success.

Error Output

The relevant part of the error message:

[ERROR] unable to read
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
    at sun.net.www.protocol.http.HttpURLConnection.doTunneling0 (HttpURLConnection.java:2296)
    at sun.net.www.protocol.http.HttpURLConnection.doTunneling (HttpURLConnection.java:2166)
    at io.swagger.v3.parser.util.RemoteUrl.urlToString (RemoteUrl.java:151)

For full error log see attached error logs.
error-log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant