Skip to content

Add keyring integration for git credentials#15456

Draft
jtfmumm wants to merge 1 commit intojtfm/keyring-explorationfrom
jtfm/git-keyring-integration
Draft

Add keyring integration for git credentials#15456
jtfmumm wants to merge 1 commit intojtfm/keyring-explorationfrom
jtfm/git-keyring-integration

Conversation

@jtfmumm
Copy link
Contributor

@jtfmumm jtfmumm commented Aug 22, 2025

This PR adds native keyring integration for persisting and fetching git credentials. On successful authentication for a git repo, credentials are persisted to the system keyring if keyring-provider = "native". Future invocations will be able to find these credentials even in the absence of a git credential helper (though you must currently still provide a username on future invocations, see #10866).

Credentials are stored in the system keyring with a uv-credentials: prefix (see #14559), e.g., the keyring service for a GitHub repo would be named uv-credentials:https://github.com/<org>/<repo>.

TODO:

  • Add a test for uv sync (there is currently only a new test for uv add). I've successfully tested uv sync locally but ideally we should have an automated test.

Depends on #14559.

@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 15:35 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 4a382fc to 80154a2 Compare August 22, 2025 15:36
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from 523f733 to 70128eb Compare August 22, 2025 15:37
/// persisted to the system keyring for future use.
///
/// Returns the previously stored credentials for this URL, if any.
pub async fn insert(
Copy link
Contributor Author

@jtfmumm jtfmumm Aug 22, 2025

Choose a reason for hiding this comment

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

This method was switched to async for calling KeyringProvider::store_if_native, as was store_credentials_from_url below.

/// Fetch the underlying Git repository at the given revision.
#[instrument(skip(self), fields(repository = %self.git.repository(), rev = ?self.git.precise()))]
pub fn fetch(self) -> Result<Fetch> {
pub async fn fetch(self, keyring_provider: Option<&KeyringProvider>) -> Result<Fetch> {
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 method was switched to async in order to call KeyringProvider::fetch_if_native. As a result, a immediately invoked closure below was converted to a spawn_blocking call. It's worth noting that this change holds whether or not the keyring provider is configured to be native.

@jtfmumm jtfmumm force-pushed the jtfm/keyring-exploration branch from 80154a2 to ec49f65 Compare August 22, 2025 15:45
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch 2 times, most recently from b5210b0 to ccfabfe Compare August 22, 2025 15:47
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 15:50 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from ccfabfe to ce94163 Compare August 22, 2025 15:52
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 15:55 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from ce94163 to 83dc944 Compare August 22, 2025 16:38
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 16:40 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from 83dc944 to cb5a707 Compare August 22, 2025 17:08
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 17:11 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch 2 times, most recently from 4be8581 to 9f8fb3c Compare August 22, 2025 17:18
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 17:21 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from 9f8fb3c to 0ef62d2 Compare August 22, 2025 17:25
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 17:27 — with GitHub Actions Inactive
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 17:39 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from 0c869fd to f2eed74 Compare August 22, 2025 17:54
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 17:57 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from f2eed74 to 676373d Compare August 22, 2025 18:14
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 18:17 — with GitHub Actions Inactive
@jtfmumm jtfmumm force-pushed the jtfm/git-keyring-integration branch from 676373d to 7f3adc3 Compare August 22, 2025 18:34
@jtfmumm jtfmumm temporarily deployed to uv-test-registries August 22, 2025 18:37 — with GitHub Actions Inactive
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