tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

Yum config and URL-encoded auth #129

Closed awiseman closed 9 years ago

awiseman commented 9 years ago

Currently, vagrant-proxyconf seems to require that proxy auth credentials be provided in URI-valid format (i.e. http://user>:<pass>@<host:). For usernames and passwords that contain URI reserved characters

] [ ? / < ~ # ` ! @ $ % ^ & * ( ) + = } | : " ; ' , > { space

, this requires that these characters be encoded to their corresponding %## value.

This works fine for the proxy environment variables (http_proxy, https_proxy, etc.). However, yum.conf specifies proxy auth credentials separately from the proxy URL.

proxy=http://<host>:<port>
proxy_username=<user>
proxy_password=<password>

If the username/password contains URI encoded characters, yum is unable to authenticate because it is expecting plain-text representations of these values.

I tried to find a work-around, but vagrant-proxyconf currently doesn't seem to allow the specification of auth credentials in any other format than URI encoded.

otahi commented 9 years ago

I found #120 "need to decode password for yum.conf". Can you try this one?

awiseman commented 9 years ago

Unfortunately, I found that one too, as well as https://github.com/tmatilai/vagrant-proxyconf/issues/113. I tried escaping the character, specifying it via the env variable, and specifying it via "config.yum_proxy.http" in my vagrant file. None of them work :( I get this error message:

C:/HashiCorp/Vagrant/embedded/lib/ruby/2.0.0/uri/generic.rb:214:in `initialize': the scheme http does not accept registry part: user:123 (or bad hostname?) (URI::InvalidURIError)

The issue seems to be that the URI string fails to parse due to those characters. I use this test string:

http://user:123#abc@proxy.example.com:80

which would need to be encoded as the following to work as the http_proxy value

http://user:123%23abc@proxy.example.com:80

Here, the URI parser doesn't know that I'm not specifying something like:

http://host:port#hashpath

Would it be difficult to create a proxy, username, and password key for config.yum_proxy.* such that there is a 1-1 relationship between those values and what gets entered into /etc/yum.conf?

e.g.

if Vagrant.has_plugin?("vagrant-proxyconf")
    config.yum_proxy.proxy    = "http://proxy.example.com:80"
    config.yum_proxy.username = "user"
    config.yum_proxy.password = "123#abc"
end
otahi commented 9 years ago

@awiseman, I'm sorry, I had a mistake. #120 is not merged and closed. So we need new implementation for this issue.

The implementation should be upper compatible. So, how about the followings?

if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy  = "http://user:123%23abc@proxy.example.com:80"
    config.proxy_url_encoded = true
end
if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy  = "http://user:123abc@proxy.example.com:80"
    config.proxy_url_encoded = false
end
awiseman commented 9 years ago

Sure, whichever makes the most sense.

Thanks :)

otahi commented 9 years ago

Already released on 1.5.2.