-
Notifications
You must be signed in to change notification settings - Fork 2.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
Use env vars if either --username
or --password
(or both) is missing
#5584
base: main
Are you sure you want to change the base?
Conversation
# Check if we have a token first | ||
token = self._authenticator.get_pypi_token(repository_name) | ||
token = None | ||
if not (username or password): |
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.
I don't think this is desired.
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 original behavior would overwrite any value passed via CLI, if either is missing and a token is found (e.g if a username is passed and a token is found, then it would discard the username). Do we want to consider token auth if there's a username? I am happy to change back to the original behavior, although I find it a bit unintuitive.
username = auth.username | ||
password = auth.password | ||
username = username or auth.username | ||
password = password or auth.password |
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.
Unsure if we really have this scenario.
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.
This looks very niche to me as well. Do you think we should not consider this case?
I'm still not sure on this myself, but I would like to see tests (plus dropping the second case) to consider this for merging. |
53d8d4c
to
5d00496
Compare
Pull Request Check List
Resolves: #5526
This PR changes authentication logic for publishing:
username
andpassword
is missing, consider PyPI token env var.username
orpassword
is missing, consider http basic env var for the missing field.Previously, env vars were only considered if both CLI options where missing. This PR effectively makes it possible to mix the CLI options with the env vars.
This way both
will work. I am doubtful about whether it is worth supporting the second use case.