Support for providing username and password for curl downloadsSee original GitHub issue
I’d like to retrieve dependencies from a private URL that requires credentials. In my current setup, I’m using
curl --netrc, which enables me to put a hostname, username, and password into
Poking through the source of the curl module, I see https://github.com/buildinspace/peru/blob/42ad4ad5eabbe6e6872d2b6f4c459475e4051304/peru/resources/plugins/curl/curl_plugin.py#L82 is where the request is created. I looked at the urllib.request docs and see this example for setting up for basic auth:
import urllib.request # Create an OpenerDirector with support for Basic HTTP Authentication... auth_handler = urllib.request.HTTPBasicAuthHandler() auth_handler.add_password(realm='PDQ Application', uri='https://mahler:8092/site-updates.py', user='klem', passwd='kadidd!ehopper') opener = urllib.request.build_opener(auth_handler) # ...and install it globally so it can be used with urlopen. urllib.request.install_opener(opener) urllib.request.urlopen('http://www.example.com/login.html')
netrc parsing is, fortunately, a standard library feature of Python, through the aptly-named
The implementation of this all seems pretty straightforward but the configuration within peru is unclear. It would probably make sense for peru to read this file and populate the opener by default but I could see how some users may feel that’s a security risk. So, a compromise may be opt-in in the peru.yml, an
# from the example in README.md curl module pathogen: url: https://codeload.github.com/tpope/vim-pathogen/tar.gz/v2.3 auth: netrc # Untar the archive after fetching. unpack: tar # After the unpack, use this subdirectory as the root of the module. export: vim-pathogen-2.3/autoload/ curl module pathogen: url: https://codeload.github.com/tpope/vim-pathogen/tar.gz/v2.3 auth: username: whatever password: whywouldyouputthathere # Untar the archive after fetching. unpack: tar # After the unpack, use this subdirectory as the root of the module. export: vim-pathogen-2.3/autoload/
- Created 5 years ago
- Comments:17 (16 by maintainers)
Top GitHub Comments
I’ll see what I can drum up!
It seems that I lost in this one.
Let’s see how it goes then. I will try to work on something in the next few days.
About the alias, I am opening another issue mentioning this discussion.