-
Notifications
You must be signed in to change notification settings - Fork 308
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
Not obvious how to use multiple project API tokens with keyring #565
Comments
The discussion around this issue seems to be evolving from pypa/packaging.python.org#297 (comment). I think this issue is blocked until that's resolved. |
Judging by the message shown after user have created project-scoped API token
it looks like this issue was kind of solved behind the scenes, but it seems to be broken (pure The following are my thoughts on the issue (tl;dr: use To upload package to index server, using classic case, we must know its URL, username and password. To store password in a secure storage, we can map URL and username to password: both index servers and their usernames are unique, therefore they will produce reliable mapping. When we want to upload package to index server using API token, here too we must know its URL, username and password. Because in case of login through API token username is always constant, namely A better solution could be to add extra key to The thing is, because
to
And of course documentation will have to be updated as well, not to mention doc for BTW, apart from Edit: From the looks of it, someone used one of the solutions from the first post w/o making sure that it was possible to have project-specific URLs, thus breaking current multi-token solution. |
@8day thanks for sharing your thoughts. I haven't read them closely, but a quick scan suggests that you and I have arrived at similar conclusions. A few quick notes (which you may have covered already):
Since opening this issue over 2 years ago, I haven't seen any demand for a fix. So, it's not a high priority, esp. given the unresolved design decisons. |
There is going to be demand now, with PyPI pushing 2FA, then sending emails like this:
|
Maybe that demand will help generate solutions instead of comments with subtext guilting maintainers for not prioritizing something that hasn't been necessary that contribute little to the discussion |
You're reading too much into it Ian, no slight was intended. My comment was intended as a direct reply to Brian's final paragraph:
Out of pragmatism, in the short term I'll just use a single token for all my PyPI projects, since that is documented and clear. Thank you. |
Does the existence of trusted publishing reduce the demand/desire for this feature? |
To some degree, sure it probably does. That said, PyPI isn't the only target people try to upload to (and I've heard of some other corporate indexes trying to mimic this behavior for some bizarre reason). For another, I'm certain there are projects which can not use GitHub/GitHub Actions (or GitLab which I think is one of the other trusted publishers) to publish things. Some folks self-host Jenkins, etc but still release to PyPI and likely need some way to securely manage tokens (although I doubt they want keyring for that). Beyond that, I'd expect some people just don't trust GitHub to publish things and would feel better doing so themselves with a token. I don't blame them as people put a lot of trust in a company that's all too often not done what's best for the community since it works to serve shareholders goals. So, yes, I think the demand is lessened but not by a measurable quantity (only because the original demand was not measurable). |
While publishing from CI is clearly the better choice, for smaller projects it may just not be worth the effort, so we also support publishing from a local machine. We don't support `.pypirc`, the non-standard file that saves password as plaintext to the user home. Instead, we recommend using the keyring for local publishing, using the operating system's much more secure, mostly standardized and better queryable credential store as backend. This comes with the catch that the keyring keys by URL+username, so we need to use the horrible query string attach to tag per-project scoped tokens to a more specific URL (pypa/twine#565).
Your Environment
Your operating system: macOS
Version of python you are running: 3.7.6
How did you install twine? pipx
Version of twine you have installed (include complete output of):
The Issue
Twine only uses the repository URL and username to retrieve the credentials, so the standard use of keyring doesn't seem support multiple project API tokens.
Possible Workaround
Adding the package name as a query parameter seems to work, but feels like a hack:
Or:
Possible Solutions
Off the top of my head, without adding an additional argument to keyring:
Add the repository name to be part of the keyring
USERNAME
argument, e.g.:I think this might be relatively quick to implement, but feels clunky to document and use.
Use the repository name as the keyring
SERVICE
argument e.g.:This feels friendlier to users. However, I'm guessing it requires more substantial changes in twine's configuration handling.
The text was updated successfully, but these errors were encountered: