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

authenticating proxy not working #131

Closed
jorgheymans opened this issue Oct 30, 2020 · 7 comments
Closed

authenticating proxy not working #131

jorgheymans opened this issue Oct 30, 2020 · 7 comments
Assignees
Labels
Bug Something is not working as expected
Milestone

Comments

@jorgheymans
Copy link

Using gradle 6.6.1, given config

plugins {
   id 'org.siouan.frontend' version '3.0.1'
}

repositories {
   mavenLocal()
   mavenCentral()
}

frontend {
   nodeVersion = '14.8.0'
   assembleScript = 'run build'
   proxyHost = '....'
   proxyPort = 7890
   proxyUsername = '...'
   proxyPassword = '...'
   verboseModeEnabled = true
}

when trying to build a project, behind the corporate authenticating proxy we get this:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':client:installNode'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:2
....
....
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
    at org.siouan.frontendgradleplugin.domain.usecase.DownloadResource.execute(DownloadResource.java:79)
    at org.siouan.frontendgradleplugin.domain.usecase.GetDistribution.execute(GetDistribution.java:87)
    at org.siouan.frontendgradleplugin.domain.usecase.AbstractInstallDistribution.execute(AbstractInstallDistribution.java:81)
    at org.siouan.frontendgradleplugin.infrastructure.gradle.AbstractDistributionInstallTask.execute(AbstractDistributionInstallTask.java:116)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
    ... 89 more

In case it helps, here are the headers the proxy returns unauthenticated:

* Mark bundle as not supporting multiuse
< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: BASIC realm="PROXY_INTERNET"
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: close
< Set-Cookie: BCSI-CS-4e5ea614a1ff0a94=2; Path=/
< Connection: close
< Content-Length: 849

I know the proxy URL, port and credentials are correct as we're using it for many other things and usually after some fiddling it works for most things. Any ideas what could be happening here ?

@v1nc3n4
Copy link
Member

v1nc3n4 commented Oct 30, 2020

Hi @jorgheymans,

Thank you for reporting this issue. I can confirm the problem: the URL to download the Node.js distribution uses HTTPS, making proxy basic credentials invisible for the proxy server.
I may need some days to implement correctly the fix: it seems there's no easy way to forward secured requests with a clear Basic proxy auth, in Java. The proxy must see the credentials in a separate request, and the HTTPS request must be done after that. I would implement the logic by hand, as suggested in this SO discussion.

Apart from obvious workarounds such as disabling proxy authentication temporarily in your organisation for this client workstation, I don't see an acceptable solution until the fix is published.
BR

@v1nc3n4 v1nc3n4 self-assigned this Oct 30, 2020
@v1nc3n4 v1nc3n4 added Bug Something is not working as expected IN PROGRESS Design and implementation are in progress labels Oct 30, 2020
@v1nc3n4 v1nc3n4 added this to the 4.0.1 milestone Oct 30, 2020
@jorgheymans
Copy link
Author

Thanks for the detailed reply ! Instead of doing the heavy lifting yourself, have you considered leveraging https://square.github.io/okhttp/ for this ? It supports this scenario out of the box.

@v1nc3n4
Copy link
Member

v1nc3n4 commented Oct 31, 2020

Yes, thank you! In fact, I'm not only considering doing that 'by hand'. I saw Apache HttpClient also supports this feature. But I'll take a look at the okhttp of course, because I'm also interested in a lighweight solution.
Have a nice day!

v1nc3n4 added a commit that referenced this issue Nov 1, 2020
v1nc3n4 added a commit that referenced this issue Nov 1, 2020
@v1nc3n4 v1nc3n4 removed the IN PROGRESS Design and implementation are in progress label Nov 1, 2020
v1nc3n4 added a commit that referenced this issue Nov 1, 2020
@v1nc3n4 v1nc3n4 closed this as completed in 42079ca Nov 1, 2020
@jorgheymans
Copy link
Author

Thank you, it works now !

Maybe a suggestion: in $HOME/.gradle/gradle.properties I had already defined the necessary proxy settings maybe these could be sourced as a fallback ?

@v1nc3n4
Copy link
Member

v1nc3n4 commented Nov 4, 2020

Hi, glad to read it's working now.

I understand you would like the plugin to find its configuration automatically from predefined properties. I need more details about the fallback strategy you are introducing:

  • What was the initial problem you were facing?
  • How did you achieve to workaround/deal with this problem?
  • What is the content of the gradle.properties located in your home directory?

Thank you for your help!
BR

@jorgheymans
Copy link
Author

@v1nc3n4
Copy link
Member

v1nc3n4 commented Nov 5, 2020

Hello, thank you. That's perfect, I create a dedicated issue for this improvement.
Good day!

jorgheymans added a commit to jorgheymans/akhq that referenced this issue Nov 11, 2020
update to latest version of frontend plugin which supports building from behind an authenticating proxy (siouan/frontend-gradle-plugin#131)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants