-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add CLI options for enhancing requests with HTTP headers #8078
Conversation
I am unable to stamp this, but verified this works great. Thanks! |
Any thoughts on this? @uranusjr @pradyunsg @NoahGorny ? |
I really like the idea, but I am only a simple commenter and can not approve this PR in any way :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic looks good to me 🙂 A couple of notes on implementation.
Thank you for your comments, @uranusjr ! I've made the requested changes; hope they are to your satisfaction. |
Any updates on this? Happy to discuss |
Hi, just pinging to inquire about where this PR stands. |
I am personally not entirely comfortable with this, mostly for security reasons.
pip can do HTTP requests to many other hosts than indexes ( So I tend to think this would require a per-host configuration. Or per index if we restrict this to indexes only, but that is probably too restrictive? I'm not sure how to do that elegantly (without going all the way to specifying a fully pluggable http session mechanism). |
... and frankly, a fully pluggable mechanism would enable solutions to many other open issues as well (Kerberos and NTLM support, integration with platform native networking). I don't want to derail a quick win by expanding the scope to something unachievable, but I do think it's time that we had a serious look at pushing the complexity and limited flexibility of pip's current network handling options out to a pluggable mechanism of some sort. |
I'm definitely sensitive to concerns about security, but by the same token (no pun intended) it would also be great to see pip support something more advanced than basic auth in the near term. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
-H, --header <key:val> HTTP header to include in all requests. This option can be used multiple times. Conflicts with --extra-index-url. Example: ``` pip install \ --index-url http://pypi.index/simple/ \ --trusted-host pypi.index \ -H 'X-Spam: ~*~ SPAM ~*~' \ requests ```
This is really useful for me. I am surprised that it doesn't currently exist within pip. Does anyone have any workarounds in the meantime? What is the latest on this? Is this going to be merged or is it stuck? @amancevice Thanks |
Some security concerns were raised and because of that I think the devs want to take this feature in a different direction. My personal feeling is that this is a case of "letting perfect be the enemy of good" but the security concerns are valid. I'm happy to revise this PR if the devs decide they would like to move forward on it, but my guess is this is a dead end. |
I'd say you should ignore the digression about plugins, but look at how to address the point that pip doesn't just make HTTP requests to indexes. So if we don't want to expose sensitive information to (say) the host serving a direct URL, how should we do that? Modelling the interface on curl may be a mistake, as curl only does a single request each run, whereas pip does a lot of requests as part of an install. Per-host extra headers seems more secure/reliable. It's also worth noting that we haven't had many requests for a feature like this, so risking a security hole for something that may be of limited benefit is something we have to take seriously. |
thanks for the reply @pfmoore — I originally opened #8042 to open up the conversation as to what the interface could look like but it wasn't getting much traction (ie, I got antsy waiting for feedback 🙂) and opened this as a sort of minimum-viable implementation. One of the proposals I put forward in #8042 was providing a command-line arg that accepted JSON in the form:
And then |
-1 on needing to enter JSON on the command line. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Closing since this is fairly out of date and bitrotten. Let's continue the discussion in #8042, since it's unclear if adding this functionality to pip would make sense. :) |
Adressess issue #8042. Originally proposed in PR #8030 but more discussion was requested. This PR is a new attempt to add the barebones functionality requested without compromising on security.
This change adds a cURL-like
-H / --header
option to the CLI to allow users to enhance requests with custom HTTP headers.To prevent pip from sending sensitive headers to unintended hosts, this option is ignored when extra index URLs are provided. The CLI will emit a warning to the user and any provided headers will be ignored if pip is configured to use multiple index URLs.
Example: