Skip to content

Issue with authentication with proxy #391

Closed
tysonite opened this Issue Jan 25, 2012 · 8 comments

8 participants

@tysonite

I try to authenticate on proxy using the following method:
export http_proxy='http://DOMAIN\login:password@192.168.205.2:8080'

and it doesn't work with the following message:
[root@host]# gem update
Updating installed gems
ERROR: While executing gem ... (URI::InvalidURIError)
bad URI(is not URI?): http://DOMAIN\login:password@192.168.205.2:8080

However, if I exclude "DOMAIN\" string from http_proxy variable it tries to authenticate, but fails (because proxy requires domain name to be included for the user):

[root@host]# export http_proxy='http://login:password@192.168.205.2:8080'

[root@host]# gem update
Updating installed gems
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Proxy Authentication Required 407 (http://rubygems.org/latest_specs.4.8.gz)

I guess that proxy settings parser should be extended to understand domain name.

rubygems version is
[root@host]# gem -v
1.8.15

@danielpuglisi

+1

I don't have to use the domain variable everywhere... maybe it works for you with this syntax:

http://domain%5Cusername:password@proxy_ip:port

But for me it doesn't, don't know what to do... I've set the http_proxy variables for different things. curl, wget, ssh, git and so on - everything tunnels through the http_proxy. Only gem wan't work the way it should. Neither with the --http-proxy or -p params...

@tysonite tysonite referenced this issue in rubygems/rubygems Oct 19, 2012
Closed

Issue with authentication with proxy #360

@MartinMa

👍
Because of this, I'm already stuck on part 3.2 Creating the Blog Application of the getting started guide of Ruby on Rails.

@MartinMa

The problem is related to the uri component of Ruby itself, which tries to match the userinfo part of the URI (i.e. DOMAIN\login) with the following regex:

# userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," | "\" )

whereas the patterns unreserved and escaped do not contain the backslash character. According to the spec (RFC 2396: URI Generic Syntax) this is correct. It reads:

Other characters are excluded because gateways and other transport
agents are known to sometimes modify such characters, or they are
used as delimiters.

unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"

For a quick fix go to \lib\ruby\1.9.1\uri, open common.rb, find userinfo and replace the definition with this line ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,\\\\]|#{escaped})*"

@IrwinDong

Brilliant!

@patrobinson

This should really be fixed, rather than hand modifying ruby libraries

@qrush
RubyGems member
qrush commented Nov 28, 2014

Not a rubygems.org issue, closing.

@qrush qrush closed this Nov 28, 2014
@etxzay
etxzay commented Mar 17, 2015

@MartinMa Thank you!

@ken-sands

or url encode that backslash using %5C as below

http://DOMAIN%5Clogin:password@192.168.205.2:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.