Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

agni-sairent
Copy link
Contributor

@agni-sairent agni-sairent commented Apr 16, 2022

Pull Request Check List

Resolves: #5107

  • Added tests for changed code.
  • Updated documentation for changed code.

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.

@agni-sairent agni-sairent changed the title Issue #5107: Support mutiple respositories on same host with different credentials. Issue #5107: Support multiple respositories on same host with different credentials. Apr 16, 2022
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
Copy link
Contributor

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

Copy link
Contributor Author

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!

Comment on lines 212 to 218
cred = keyring.get_credential(netloc, username)
if cred is not None:
return {
"username": cred.username,
"password": cred.password,
}

Copy link
Contributor

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.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

poetry stores repo credentials by host, it should include path
2 participants