Issue #5107: Support multiple respositories on same host with different credentials.#5463
Closed
agni-sairent wants to merge 5 commits intopython-poetry:masterfrom
Closed
Issue #5107: Support multiple respositories on same host with different credentials.#5463agni-sairent wants to merge 5 commits intopython-poetry:masterfrom
agni-sairent wants to merge 5 commits intopython-poetry:masterfrom
Conversation
Darsstar
suggested changes
Apr 18, 2022
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 |
Contributor
There was a problem hiding this comment.
I would prefer using str.startswith
Contributor
Author
There was a problem hiding this comment.
Yeah, that's much better in this case, thanks!
Comment on lines
212
to
218
| cred = keyring.get_credential(netloc, username) | ||
| if cred is not None: | ||
| return { | ||
| "username": cred.username, | ||
| "password": cred.password, | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
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.
Darsstar
approved these changes
Apr 18, 2022
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.