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

Support HTTP Proxies #38

Open
tombentley opened this issue Aug 3, 2012 · 18 comments
Open

Support HTTP Proxies #38

tombentley opened this issue Aug 3, 2012 · 18 comments
Labels
Milestone

Comments

@tombentley
Copy link
Member

The URL/Dav content stores should support accessing the net via a proxy. We should also support proxy authentication.

@FroMage
Copy link
Member

FroMage commented Aug 3, 2012

That needs support from the config file too, right?

@tombentley
Copy link
Member Author

It will do, yeah. I'd imagine something like this:

[proxy]
host=myproxy.mynetwork
port=1234
non-proxy-hosts=foo.mynetwork, bar.mynetwork
# EITHER: plaintext password
password=myPlaintextPassword
# OR: password in a keystore
keystore-alias=proxy-password

@tombentley
Copy link
Member Author

Wow, you have to love java.net. This page has some useful info: http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html Seems you can use the system's proxy settings (on Windows and Gnome anyway), though this only works at the ProxySelector level, and only if you set the right system property. I think we should use the system's proxy settings by default, which would mean:

  • Setting the system property, and
  • Setting the system-wide ProxySelector.setDefault() if a [proxy] was specified.

Then there's the question of which proxy settings win out in the IDE (the ones in the config file, or on the IDE).

@tombentley
Copy link
Member Author

ceylon-common now supports the configuration of a proxy. For the built injava.net protocol clients it should be a matter of calling Authentication.installProxy() to setup a java.net.ProxySelector (and a java.net.Authenticator if the proxy requires auth).

@FroMage
Copy link
Member

FroMage commented Feb 26, 2013

So does this mean this is resolved?

@tombentley
Copy link
Member Author

Alas, not yet. We still need to configure CMR to use the proxy.

@FroMage
Copy link
Member

FroMage commented Mar 6, 2013

Well, moving to M6.

@FroMage
Copy link
Member

FroMage commented Sep 25, 2014

Moving again.

@FroMage FroMage modified the milestones: 1.2, 1.1 Sep 25, 2014
@quintesse quintesse self-assigned this May 5, 2015
quintesse added a commit to ceylon/ceylon.language that referenced this issue May 5, 2015
quintesse added a commit to ceylon/ceylon-compiler that referenced this issue May 5, 2015
quintesse referenced this issue May 6, 2015
….openConnection()` and `URLConnection.openConnection(Proxy.NO_PROXY)` don't behave the same
quintesse referenced this issue in ceylon/ceylon-compiler May 6, 2015
….openConnection()` and `URLConnection.openConnection(Proxy.NO_PROXY)` don't behave the same
quintesse referenced this issue in ceylon/ceylon-common May 6, 2015
…penConnection()` and `URLConnection.openConnection(Proxy.NO_PROXY)` don't behave the same
@quintesse
Copy link
Member

Ok, this wasn't as straight-forward as I hoped it was due to Java's brain dead implementation of this. You can only set authentication globally for the JVM? Reallly?

So a real solution might require the use of Apache's HttpComponents (which we're already including for Maven support, but maybe we'd like that to be as optional as possible) or write our own authentication handling (no idea how hard that would be, "Basic" proxy authentication is easy enough, but what else is there?)

Anyway, what I pushed should make non-authenticating proxies work. No tests though.

@quintesse quintesse removed their assignment May 6, 2015
@tombentley
Copy link
Member Author

"Basic" proxy authentication is easy enough, but what else is there?

I've encountered a proxy which used NTLM authentication, which is a barrel of laughs to deal with in Java.

@quintesse
Copy link
Member

I've encountered a proxy which used NTLM authentication

And does Java's Authentication even deal with that?

@tombentley
Copy link
Member Author

It was a long time ago, thankfully, so I've largely forgotten how I got around it, but I think the gist of the answer is "no, not in any way". NTLM was old hat even then, so I don't seriously propose we worry about it, but I would guess that something like Kerberos would still be current in corporate environments.

@quintesse
Copy link
Member

So a temporary hack/work-around would be to install the proxy handler if somebody passed -Dceylon.installGlobalProxyHandler=true on the command line. It's crappy but it would at least make things work for now and not mess with embedded use-cases. WDYT @FroMage @tombentley ?

@ThiporKong
Copy link

Refactor access to URL.openConnection into some interface with two strategies, one JDK-based and one HttpClient-based. Make the JDK-based one the default to avoid the dependency on HttpClient.
Turn the the HttpClient-based strategy on, if proxy.{user,password} properties are set or have a proxy.connectionStrategyClass=... setting.

@josephwinston
Copy link

I'm using ceylon version 1.2.0 (A Series Of Unlikely Explanations) on Kubuntu 14.04 behind a ntlm proxy. I have a cntlm version running in linux.

Finding the proxy discusssion, I added to ~/.ceylon/config:

# define a proxy for accessing the network
[proxy]
host=localhost
port=3128

But I cannot access http://repo1.maven.org/maven2/. A typical error message is:

Warning: Failed downloading org/apache/spark/spark-core_2.10/1.2.1/spark-core_2.10-1.2.1.pom from http://repo1.maven.org/maven2/. Reason: 
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.spark:spark-core_2.10:pom:1.2.1 from/to central (http://repo1.maven.org/maven2): Error transferring file: Connection refused from http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10/1.2.1/spark-core_2.10-1.2.1.pom 
/disk2/hb55683/work/DistributedArchitecture/CEYOLN/interop-java/source/com/example/interop/module.ceylon:22: error: cannot find module artifact org.apache.spark:spark-core_2.10-1.2.1(.car|.jar)

However, wget works with cntlm:

get http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10/1.2.1/spark-core_2.10-1.2.1.pom
--2015-11-06 13:38:26--  http://repo1.maven.org/maven2/org/apache/spark/spark-core_2.10/1.2.1/spark-core_2.10-1.2.1.pom
Connecting to 127.0.0.1:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 18595 (18K) [text/xml]
Saving to: ‘spark-core_2.10-1.2.1.pom’

100%[====================================================================================================================>] 18,595      --.-K/s   in 0.02s   

2015-11-06 13:38:26 (1.03 MB/s) - ‘spark-core_2.10-1.2.1.pom’ saved [18595/18595]

Suggestions welcome.

@quintesse
Copy link
Member

@josephwinston Maven has its own proxies that I think you'll need to configure, see here for more info: https://maven.apache.org/guides/mini/guide-proxies.html

@josephwinston
Copy link

My ~/.m2/settings.xml are in place and work for maven.

@quintesse
Copy link
Member

Could you try and see what happens when you specifically point Ceylon to that file by adding --aether:/path/to/settings.xml to the command line while compiling?

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

No branches or pull requests

5 participants