Skip to content

Commit 6bad3d1

Browse files
committed
disable keyring per default
1 parent 21e30b1 commit 6bad3d1

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed

docs/configuration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,12 @@ for more information.
532532

533533
**Type**: `boolean`
534534

535-
**Default**: `true`
535+
**Default**: `false`
536536

537537
**Environment Variable**: `POETRY_KEYRING_ENABLED`
538538

539+
*Changed default to `false` in 2.0.0*
540+
539541
Enable the system keyring for storing credentials.
540542
See [Repositories - Configuring credentials]({{< relref "repositories#configuring-credentials" >}})
541543
for more information.

docs/repositories.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,19 @@ poetry config http-basic.pypi <username> <password>
472472
You can also specify the username and password when using the `publish` command
473473
with the `--username` and `--password` options.
474474

475-
If a system keyring is available and supported, the password is stored to and retrieved from the keyring. In the above example, the credential will be stored using the name `poetry-repository-pypi`. If access to keyring fails or is unsupported, this will fall back to writing the password to the `auth.toml` file along with the username.
476-
477-
Keyring support is enabled using the [keyring library](https://pypi.org/project/keyring/). For more information on supported backends refer to the [library documentation](https://keyring.readthedocs.io/en/latest/?badge=latest).
478-
479-
If you do not want to use the keyring, you can tell Poetry to disable it and store the credentials in plaintext config files:
475+
If a system keyring is available and supported, the password is stored to and retrieved from the keyring.
476+
Otherwise, credentials are stored in plaintext config files.
477+
In order to use keyring, you have to enable keyring support:
480478

481479
```bash
482-
poetry config keyring.enabled false
480+
poetry config keyring.enabled true
483481
```
484482

483+
In the above example, the credential will be stored using the name `poetry-repository-pypi`.
484+
If access to keyring is disabled, fails or is unsupported, this will fall back to writing the password to the `auth.toml` file along with the username.
485+
486+
Keyring support is enabled using the [keyring library](https://pypi.org/project/keyring/). For more information on supported backends refer to the [library documentation](https://keyring.readthedocs.io/en/latest/?badge=latest).
487+
485488
{{% note %}}
486489

487490
Poetry will fall back to Pip style use of keyring so that backends like

src/poetry/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Config:
134134
},
135135
"system-git-client": False,
136136
"keyring": {
137-
"enabled": True,
137+
"enabled": False,
138138
},
139139
}
140140

src/poetry/utils/password_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ def keyring(self) -> PoetryKeyring:
154154

155155
@staticmethod
156156
def warn_plaintext_credentials_stored() -> None:
157-
logger.warning("Using a plaintext file to store credentials")
157+
logger.warning(
158+
"Using a plaintext file to store credentials.\n"
159+
"Enable keyring support (`poetry config keyring.enabled true`)"
160+
" to store credentials securely."
161+
)
158162

159163
def set_pypi_token(self, repo_name: str, token: str) -> None:
160164
if not self.use_keyring:

tests/config/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def test_config_expands_tilde_for_virtualenvs_path(
111111
def test_disabled_keyring_is_unavailable(
112112
config: Config, with_simple_keyring: None, dummy_keyring: DummyBackend
113113
) -> None:
114+
manager = PasswordManager(config)
115+
assert not manager.use_keyring
116+
117+
config.config["keyring"]["enabled"] = True
114118
manager = PasswordManager(config)
115119
assert manager.use_keyring
116120

tests/console/commands/test_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_list_displays_default_value_if_not_set(
6060
installer.only-binary = null
6161
installer.parallel = true
6262
installer.re-resolve = true
63-
keyring.enabled = true
63+
keyring.enabled = false
6464
requests.max-retries = 0
6565
solver.lazy-wheel = true
6666
system-git-client = false
@@ -92,7 +92,7 @@ def test_list_displays_set_get_setting(
9292
installer.only-binary = null
9393
installer.parallel = true
9494
installer.re-resolve = true
95-
keyring.enabled = true
95+
keyring.enabled = false
9696
requests.max-retries = 0
9797
solver.lazy-wheel = true
9898
system-git-client = false
@@ -145,7 +145,7 @@ def test_unset_setting(
145145
installer.only-binary = null
146146
installer.parallel = true
147147
installer.re-resolve = true
148-
keyring.enabled = true
148+
keyring.enabled = false
149149
requests.max-retries = 0
150150
solver.lazy-wheel = true
151151
system-git-client = false
@@ -176,7 +176,7 @@ def test_unset_repo_setting(
176176
installer.only-binary = null
177177
installer.parallel = true
178178
installer.re-resolve = true
179-
keyring.enabled = true
179+
keyring.enabled = false
180180
requests.max-retries = 0
181181
solver.lazy-wheel = true
182182
system-git-client = false
@@ -305,7 +305,7 @@ def test_list_displays_set_get_local_setting(
305305
installer.only-binary = null
306306
installer.parallel = true
307307
installer.re-resolve = true
308-
keyring.enabled = true
308+
keyring.enabled = false
309309
requests.max-retries = 0
310310
solver.lazy-wheel = true
311311
system-git-client = false
@@ -344,7 +344,7 @@ def test_list_must_not_display_sources_from_pyproject_toml(
344344
installer.only-binary = null
345345
installer.parallel = true
346346
installer.re-resolve = true
347-
keyring.enabled = true
347+
keyring.enabled = false
348348
repositories.foo.url = "https://foo.bar/simple/"
349349
requests.max-retries = 0
350350
solver.lazy-wheel = true

tests/utils/test_authenticator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def repo() -> dict[str, dict[str, str]]:
4242
return {"foo": {"url": "https://foo.bar/simple/"}}
4343

4444

45+
@pytest.fixture
46+
def config(config: Config) -> Config:
47+
config.config["keyring"]["enabled"] = True
48+
return config
49+
50+
4551
@pytest.fixture
4652
def mock_config(config: Config, repo: dict[str, dict[str, str]]) -> Config:
4753
config.merge(

tests/utils/test_password_manager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
from tests.conftest import DummyBackend
2323

2424

25+
@pytest.fixture
26+
def config(config: Config) -> Config:
27+
config.config["keyring"]["enabled"] = True
28+
return config
29+
30+
2531
def test_set_http_password(
2632
config: Config, with_simple_keyring: None, dummy_keyring: DummyBackend
2733
) -> None:

0 commit comments

Comments
 (0)