-
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
Implement documented --force-keyring #12473
base: main
Are you sure you want to change the base?
Conversation
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.
Looks good to me.
Hopefully it wasn't to hard to grok test_prompt_for_keyring_if_needed. I probably should have gone through the effort to refactor out the common stuff and made multiple easier to understand tests. Sorry.
Good luck!
docs/html/topics/authentication.md
Outdated
know beforehand that the server requires it. It can also prevent issues with | ||
Artifactory or other servers with overly strict security policies that blocks | ||
user (temporarily) on the first failed attempt. | ||
|
||
```{warning} |
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.
Please remove this warning. It is identical to the one on line 159, which is entirely my fault.
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.
Done. :-)
It was OK. I was just surprised by how much tests the combinatorial produced! 😆
I actually like the extensive testing it produces and how the xfail marks are applied. I'm used to have many more independent test functions but I don't think that is really more readable in the end as you must scroll through pages of tests to see if you're covering all cases. |
It's not listing all the choices and the default shown is hardcoded to the wrong value.
e9e032b
to
860d73a
Compare
@Darsstar, is there is anything else I should do for this to get merged? |
I'm not part of any pypa team. I just contributed the I suggest to be patient. Maybe after two months or some ping a team member. That has been my tactic, anyway. |
OK. Thanks for tips! |
It needs a pip maintainer to approve and merge it. Looking briefly back at the linked issue, the only core maintainer I see commenting is @uranusjr who (in effect) wanted some assurance that this wasn't simply to work around an issue with how Artifactory is handling permissions. I don't think that was ever really confirmed, beyond some discussion (that I didn't really follow, TBH) around whether a 401 response was correct. In addition, the original implementation explicitly decided not to have a Personally, as I said here, I'm not at all comfortable with the amount of complexity that the keyring option has resulted in, and this is yet another example of that. Therefore, I don't plan on approving or merging this PR myself1, and I'd strongly advise any other pip maintainer considering doing so to ask for a better justification for why we now need this, what has changed since it was removed, and why there isn't a more "streamlined" and less complex way of controlling the whole keyring mechanism2. If @odormond, or anyone else interested in this PR, wants to put some effort into making it more likely that this functionality gets merged, I would suggest any or all of the following:
Better still would be to contribute a simplified implementation - but that's a lot more work (more than I think it's reasonable to ask for just to get this feature added) as well as hitting exactly the same issue that no-one would be in a position to review or approve the change on anything but a "good enough for me" basis. Footnotes |
The That way you might, successfully, be able to argue that this PR has become a bugfix instead of a new feature, @odormond. PS. Well redacted I should have written |
This PR was indeed prompted by how Artifactory handles permissions. I went with the
I'll happily challenge the way pip is currently handling authentication in order to get a simpler implementation. I went through a few RFCs in order to better understand what to expect from HTTP authentication and I think pip should simply not send spontaneously an In my understanding, to stick to the RFCs, pip should send a first request without any With this in place, getting back to Artifactory, it shouldn't have enough information to temporarily suspend a user, as it wouldn't receive an Wrapping it all up, I'll give it a try and start again from scratch, simply dropping the initial Footnotes
|
@odormond Thanks for that analysis. I'm not an expert in HTTP authentication, so I can't comment on the details (and I'd be cautious about approving any PR without someone who does know about the subject) but your proposal does indeed sound cleaner and more in line with the sort of "take a step back and get the design right" approach I was advocating. |
This fixes the issue with Artifactory as I expected. I'll dig further to see how to handle the other quirks the code is currently taking care of, namely:
|
I've created PR #12496 to address the issue without introducing the I'm afraid the code is not significantly simpler due to the inherent complexity of supporting credentials coming from possibly 4 different places (original URL, index URL, keyring, netrc) and being possibly partially distributed (i.e. username in URL and password in keyring). |
I've made a few comments on that PR. For people following this PR, though, I'll note that my position is that I'm uncomfortable adding (maintenance) complexity to pip (which is 100% volunteer maintained) to patch over an issue that only affects a single (commercial) index implementation. I'm also concerned that the keyring support - which was added cautiously and on the basis that it "wouldn't be a big burden" - is becoming complex to maintain. My preference would be to go back to the fundamental design in #6818 where we treat "URL with an auth token" and "URL with a username but no password" as the same. If that's an invalid assumption1 then we should revisit the design there. Maybe "practicality beats purity" dictates that we just implement something that works, and don't get bogged down in principles, but if so then it'll be someone other than me who makes that call, I'm afraid. Footnotes
|
Google Cloud Platform (GCP) Artifact Registry also recommends |
Currently, the |
I just merged #12455 which removes the mistakenly included section in the documentation that describes the pip is conservative and does not query keyring at all when `--no-input` is used
because the keyring might require user interaction such as prompting the user
on the console. You can force keyring usage by passing `--force-keyring` or one
of the following:
```bash
# possibly with --user, --global or --site
$ pip config set global.force-keyring true
# or
$ export PIP_FORCE_KEYRING=1
```
```{warning}
Be careful when doing this since it could cause tools such as pipx and Pipenv
to appear to hang. They show their own progress indicator while hiding output
from the subprocess in which they run Pip. You won't know whether the keyring
backend is waiting the user input or not in such situations.
```
``` |
This PR provide an implementation of
--force-keyring
that is documented in authentication.It was initially introduced in #11698 and accidentally left behind in the documentation when addressing comments and merging the functionality into specifying an explicit keyring provider.
I'm reviving it in order to address #11721.
My implementation simply allows usage of keyring to retrieve the credentials on the initial request. This let us skip the initial request that fails with 401 Unauthorized and which also temporarily suspend the user on Artifactory. Keyring is actually only queried if a username is found in the configured (extra-)index-url and does not result in an attempt to unlock the keyring when simply talking to pypi thanks to the logic already in place.
The last three commits are not related to
--force-keyring
but just boyscout work:--keyring-provider
option--keyring-provider
dowbload
->download
I've not included any news fragment for these three commits. I'll happily do so if this is considered the right thing do or split them into separate PRs if needed.