Skip to content

Enable system keyring integration via --keyring-provider native#14559

Closed
jtfmumm wants to merge 6 commits intomainfrom
jtfm/keyring-exploration
Closed

Enable system keyring integration via --keyring-provider native#14559
jtfmumm wants to merge 6 commits intomainfrom
jtfm/keyring-exploration

Conversation

@jtfmumm
Copy link
Contributor

@jtfmumm jtfmumm commented Jul 11, 2025

This PR uses the uv-keyring crate vendored in #14725 to automatically integrate with the system keyring when the keyring provider is set to "native".

When this backend is enabled, uv auth middleware will attempt to retrieve missing credentials from the system keyring. It will also store index credentials in the system keyring upon successful authentication, enabling users to provide their credentials for an index once and successfully authenticate on future invocations (though you must currently still provide a username on future invocations, see #10866).

Credentials are stored in the system keyring for a "service"/username pair. For the service, this currently prefixes the index URL with uv-credentials:. This prefix could help prevent collisions but would also be useful for determining which keyring credentials have been set by uv. Note that this is using the index URL rather than the index name for the service.

Left to do:

  • Possibly put automatic storage of credentials behind a --preview flag, unless we think it's enough that you must explicitly configure a native keyring provider (we've discussed making it the default, but that's not the behavior here)

Depends on #14725.

/// Store credentials for the given [`Url`] to the keyring if the
/// keyring provider backend is `Native`.
#[instrument(skip_all, fields(url = % url.to_string(), username))]
pub fn store_if_native(&self, url: &DisplaySafeUrl, credentials: &Credentials) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could extend this to the Python keyring as well, but for this PR I've limited the scope to the new native backend.

.as_ref()
.is_ok_and(|response| response.error_for_status_ref().is_ok())
{
if let (Some(index_url), Some(keyring)) = (index_url, &self.keyring) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently only storing credentials on successful authentication if this is an index URL.

@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 371fe09 to 56755c7 Compare July 11, 2025 09:20
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch 2 times, most recently from b42e924 to 99c2b35 Compare July 24, 2025 14:37
@jtfmumm jtfmumm temporarily deployed to uv-test-registries July 24, 2025 14:40 — with GitHub Actions Inactive
@jtfmumm jtfmumm temporarily deployed to uv-test-publish July 24, 2025 14:40 — with GitHub Actions Inactive
@jtfmumm jtfmumm changed the base branch from main to jtfm/vendor-keyring August 6, 2025 11:06
@jtfmumm jtfmumm force-pushed the jtfm/vendor-keyring branch 3 times, most recently from 5443e7e to 9851631 Compare August 6, 2025 13:19
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 99c2b35 to f8756ea Compare August 6, 2025 13:20
@jtfmumm jtfmumm force-pushed the jtfm/vendor-keyring branch from 9851631 to e06b584 Compare August 6, 2025 13:21
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from f8756ea to 166e9e1 Compare August 6, 2025 13:22
@jtfmumm jtfmumm force-pushed the jtfm/vendor-keyring branch 2 times, most recently from 71927bc to e4a1cf1 Compare August 6, 2025 14:15
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 166e9e1 to 496c7a2 Compare August 7, 2025 14:27
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 7, 2025 14:31 — with GitHub Actions Inactive
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 7, 2025 16:59 — with GitHub Actions Inactive
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 7, 2025 17:11 — with GitHub Actions Inactive
@jtfmumm jtfmumm marked this pull request as ready for review August 7, 2025 17:13
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from d1ab06b to a2df725 Compare August 8, 2025 09:17
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 8, 2025 09:19 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/vendor-keyring branch 7 times, most recently from 0288a35 to f29dd35 Compare August 14, 2025 10:27
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from a2df725 to a898fe4 Compare August 14, 2025 10:31
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 14, 2025 10:33 — with GitHub Actions Inactive
Base automatically changed from jtfm/vendor-keyring to main August 15, 2025 13:57
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 4a382fc to 80154a2 Compare August 22, 2025 15:36
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 15:38 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 80154a2 to ec49f65 Compare August 22, 2025 15:45
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 15:54 — with GitHub Actions Inactive
zanieb added a commit that referenced this pull request Aug 28, 2025
Picks up the work from

- #14559 
- #14896

There are some high-level changes from those pull requests

1. We do not stash seen credentials in the keyring automatically
2. We use `auth login` and `auth logout` (for future consistency)
3. We add a `token` command for showing the credential that will be used

As well as many smaller changes to API, messaging, testing, etc.

---------

Co-authored-by: John Mumm <jtfmumm@gmail.com>
zanieb added a commit that referenced this pull request Aug 29, 2025
Picks up the work from

- #14559
- #14896

There are some high-level changes from those pull requests

1. We do not stash seen credentials in the keyring automatically
2. We use `auth login` and `auth logout` (for future consistency)
3. We add a `token` command for showing the credential that will be used

As well as many smaller changes to API, messaging, testing, etc.

---------

Co-authored-by: John Mumm <jtfmumm@gmail.com>
zanieb added a commit that referenced this pull request Aug 30, 2025
Picks up the work from

- #14559
- #14896

There are some high-level changes from those pull requests

1. We do not stash seen credentials in the keyring automatically
2. We use `auth login` and `auth logout` (for future consistency)
3. We add a `token` command for showing the credential that will be used

As well as many smaller changes to API, messaging, testing, etc.

---------

Co-authored-by: John Mumm <jtfmumm@gmail.com>
zanieb added a commit that referenced this pull request Aug 31, 2025
Picks up the work from

- #14559
- #14896

There are some high-level changes from those pull requests

1. We do not stash seen credentials in the keyring automatically
2. We use `auth login` and `auth logout` (for future consistency)
3. We add a `token` command for showing the credential that will be used

As well as many smaller changes to API, messaging, testing, etc.

---------

Co-authored-by: John Mumm <jtfmumm@gmail.com>
@jtfmumm
Copy link
Contributor Author

jtfmumm commented Sep 2, 2025

Closed in favor of #15539

@jtfmumm jtfmumm closed this Sep 2, 2025
zanieb added a commit that referenced this pull request Sep 2, 2025
Picks up the work from

- #14559
- #14896

There are some high-level changes from those pull requests

1. We do not stash seen credentials in the keyring automatically
2. We use `auth login` and `auth logout` (for future consistency)
3. We add a `token` command for showing the credential that will be used

As well as many smaller changes to API, messaging, testing, etc.

---------

Co-authored-by: John Mumm <jtfmumm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant