-
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
Issue #5107: Support multiple respositories on same host with different credentials. #5463
Conversation
src/poetry/utils/authenticator.py
Outdated
if netloc is None or netloc == parsed_url.netloc: | ||
if url is None or ( | ||
parsed_repository_url.netloc == parsed_package_url.netloc | ||
and parsed_repository_url.path in parsed_package_url.path |
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 would prefer using str.startswith
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.
Yeah, that's much better in this case, thanks!
src/poetry/utils/authenticator.py
Outdated
cred = keyring.get_credential(netloc, username) | ||
if cred is not None: | ||
return { | ||
"username": cred.username, | ||
"password": cred.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.
This is a fallback. Please do not delete the fallback. I like the fallback because I implemented the fallback.
It falls back on the netloc after trying the full url the same way that Pip does.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Pull Request Check List
Resolves: #5107
Motivation: when using a private package registry (f.e. GitLab), you often end up with multiple registries with different credentials hosted on the same domain. Poetry is using only netloc part of the URL to determine what credentials to use.
Fix: Replace netloc with repository URL, then credentials can be looked up by finding matching netlocs and checking if the repository URL path is a substring of the package URL path.