-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Allow pip to send arbitrary headers to various hosts #8042
Comments
I have a bare-minimum implementation open at #8078 that accepts If the option is used with extra index URLs, the implementation issues a warning that the option is being ignored: pip install boto3 --extra-index-url http://localhost:8000/ -H 'Authorization: SPAM'
WARNING: Refusing to set -H / --header option(s) because multiple index URLs are configured. I think this implementation adds a useful feature without opening users up to any unintended risks and it could always be expanded upon in the future. |
I'm still not sure about how this interacts with multiple indexes. We have feature requests for adding support for different configuration for different URLs and I'm not very keen on locking ourselves out of that: #8232. |
this section of code explains how I'm currently dealing with multiple indices: https://github.com/amancevice/pip/blob/header/src/pip/_internal/cli/req_command.py#L91-L97 In a nutshell, at the point when the So this feature would really only be useful for users wanting to run |
Hi, We are also trying to set up a private PyPI index that uses JWTs to manage auth so this feature would be great to have! Looking forward to following along with the progress on this – thanks! |
This feature (along with providing alternative authenticating methods in general) has been proposed as a Python Software Foundation fundable project. The proposal also outlines why pip maintiners are not actively working on the feature. I would recommend interested parties to take a look, and consider donating resources, including developer time, to developing a solution. Please refer to the linked document on how you can contact the Packaging Working Group to move the project forward. |
What's the status of this issue? It'd be nice to have |
Sad that this was tossed into "lets get founding" when there have been a number of perfectly usable PRs and PoC for this. Being able to pass a simple HTTP header along for a request feels like it doesn't warrant the amount of debate it got over the past 3 years. |
All tasks listed in the fundable project page are available for anyone. The reason it eventually ended up on the list is no volunteer contributor was able to complete the implementation. Feel free to work on it. |
but.. there's multiple PRs in here that fulfil the requirement of the issue - they just didn't meet the extended requirements of the people discussing the topic. The original "let me add headers" - this one for example implemented the requested features just fine and then was closed for the sake of more debate. So I would argue against "no contributor was able to complete the implementation [of this issue as the OP asked for]" |
I'm sorry but can you confirm that you've (a) read the funding page and (b) read the discussions that took place on the PRs? |
I hit this today as a blocker while trying to add an |
Right, and the first concern raised about the proposed design was the thing that still hasn't been resolved. I appreciate that sending an
|
Actually per-host auth is not enough; per-source is required in order to cater for the likely use of bearer tokens to access git repositories, which are likely to be configured per-repository (this is our current use case). |
What's the problem this feature will solve?
Currently, there is no simple solution for pip to authenticate with a custom PyPI index using token-based authentication in HTTP headers.
The proposed feature should allow users to supply custom headers as options on various
pip
commands.Based on discussion in PR #8030, there are a couple of concerns that warrant consideration:
Describe the solution you'd like
If I am a user maintaining a Python application that is built from a mix of public and private pips, I might want to install the dependencies in one command:
or I may opt for a two-step install, installing the public pips first then installing the private ones on top (ignoring dependencies—assuming any public ones were installed in the previous step):
There is no obvious way to implement the desired header option(s), so I will propose a few in the next section...
Alternative Solutions
The JSON solution:
Send headers nested in a JSON document where top-level keys are the target hostnames.
pip install --extra-index-url https://pypi.mine.com/simple/ \ --host-headers '{"pypi.mine.com": {"Authorization": "Bearer ..."}}' \ ...
Pros:
Cons:
-H
option)The cURL-like solution:
Use a cURL-like DSL to set headers + hosts in one line.
The key difference is headers are optionally prefixed by their intended host, eg:
instead of
-H 'Header: Value'
, it's-H 'hostname: Header: value
(or something similar)If the hostname prefix is omitted, the header would be sent to all hosts (possibly with a warning)
pip install --extra-index-url https://pypi.mine.com/simple/ \ -H 'pypi.mine.com: Authorization: Bearer ...' \ ...
Pros:
Cons:
A blended solution:
Allow users to specify headers using cURL-like syntax (
-H 'Header: Value'
) AND allow users to supply a more verbose JSON document with per-host headers.In this solution, the
-H
option is interpreted just like cURL and would be attached to all outgoing requests (possibly with a warning).Pros:
Cons:
Some other solution! No wrong answers!
Additional context
Original discussion at #4475 and original PR at #8030
The text was updated successfully, but these errors were encountered: