Skip to content

Comments

Fix credentials set via environment variables#2955

Closed
fbergroth wants to merge 5 commits intopython-poetry:masterfrom
fbergroth:fix-credentials
Closed

Fix credentials set via environment variables#2955
fbergroth wants to merge 5 commits intopython-poetry:masterfrom
fbergroth:fix-credentials

Conversation

@fbergroth
Copy link
Contributor

@fbergroth fbergroth commented Sep 24, 2020

config.get('http-basic') may not list repositories if credentials are set via environment variables. This fixes that by listing repositories from config.get('repositories').

However, the user still need to configure the repo url like poetry config repositories.foo .... It doesn't work by simply setting the environment variable POETRY_REPOSITORIES_FOO_URL, as there is currently no way to iterate over the repository names set via environment variables.

I added a commit 1733ed9 to show a potential solution to this, but it might need to be reworked a bit. I can split it out in a separate PR if needed.

Pull Request Check List

Resolves: #2799

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

config.get('http-basic') may not list repositories if credentials are set via
environment variables.
@fbergroth fbergroth force-pushed the fix-credentials branch 3 times, most recently from b833165 to 4cea791 Compare September 25, 2020 05:56
@abn
Copy link
Member

abn commented Sep 28, 2020

@fbergroth #2990 will close this PR. I have kept your attribution for your test changes (408b0fb).

For the POETRY_REPOSITORIES env variables; this is not yet supported. The test or that can be reused if we introduce that support.

@pytest.fixture
def environment_repository(monkeypatch):
    monkeypatch.setenv("POETRY_REPOSITORIES_FOO_URL", "https://foo.bar/simple/")


def test_authenticator_uses_env_provided_credentials_and_repo(
    config, environ, mock_remote, http, environment_repository_credentials, environment_repository
):
    authenticator = Authenticator(config, NullIO())
    authenticator.request("get", "https://foo.bar/files/foo-0.1.0.tar.gz")

    request = http.last_request()

    assert "Basic YmFyOmJheg==" == request.headers["Authorization"]

@abn
Copy link
Member

abn commented Sep 28, 2020

Closing this in favour of #2990. Support of POETRY_REPOSITORIES_ needs to be handled separately in poetry.config.config.Config as a new feature really since this is not supported at the moment.

@abn abn closed this Sep 28, 2020
@github-actions
Copy link

github-actions bot commented Mar 1, 2024

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 Mar 1, 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.

1.1.0rc1: POETRY_HTTP_BASIC_ environment variables are ignored for private repositories

2 participants