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

Still showing prompt with multiple accounts even though they're equivalent #1368

Closed
chrisant996 opened this issue Aug 7, 2023 · 1 comment · Fixed by #1369
Closed

Still showing prompt with multiple accounts even though they're equivalent #1368

chrisant996 opened this issue Aug 7, 2023 · 1 comment · Fixed by #1369
Labels
auth-issue An issue authenticating to a host

Comments

@chrisant996
Copy link

Version

2.2.2

Operating system

Windows

OS version or distribution

Windows 10 Pro 22H2 19045.3208

Git hosting provider(s)

GitHub

Other hosting provider

No response

(Azure DevOps only) What format is your remote URL?

None

Can you access the remote repository directly in the browser?

Yes, I can access the repository

Expected behavior

Running git push should proceed without any prompt.

Actual behavior

Running git push shows a graphical prompt asking me to choose between "chrisant996" and "chrisant996", with no way to tell how they're different.

Running cmdkey /list:git* reveals that they're equivalent:

c:\repos\project> cmdkey /list:git:*

Currently stored credentials for git:*:

... snip ...

    Target: git:https://github.com
    Type: Generic
    User: chrisant996
    Local machine persistence

    Target: git:https://chrisant996@github.com
    Type: Generic
    User: chrisant996
    Local machine persistence

... snip...

These accounts are equivalent.
There should not be a prompt.

I shouldn't have to delete one of the targets to make the prompt go away.
Especially since pressing Esc in the prompt succeeds!

The reason the authentication succeeds even after cancelling the GCM prompt is because git config credential.manager is set to wincred. When GCM fails, the auth ends up succeeding because wincred uses the cached credentials correctly.

Logs

10:14:35.953346 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
10:14:35.968979 git.c:462 trace: built-in: git push
10:14:35.968979 run-command.c:661 trace: run_command: GIT_DIR=.git git remote-https origin https://github.com/chrisant996/clink.git
10:14:35.984615 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:35.984615 git.c:748 trace: exec: git-remote-https origin https://github.com/chrisant996/clink.git
10:14:35.984615 run-command.c:661 trace: run_command: git-remote-https origin https://github.com/chrisant996/clink.git
10:14:36.000222 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.187723 run-command.c:661 trace: run_command: 'C:/Program\ Files/Git/mingw64/bin/git-credential-manager.exe get'
10:14:36.312738 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.312738 git.c:462 trace: built-in: git config --null --list
10:14:36.359596 ...\Application.cs:106 trace: [RunInternalAsync] Version: 2.2.2.0
10:14:36.359596 ...\Application.cs:107 trace: [RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
10:14:36.359596 ...\Application.cs:108 trace: [RunInternalAsync] Platform: Windows (x86-64)
10:14:36.359596 ...\Application.cs:109 trace: [RunInternalAsync] OSVersion: 10.0 (build 19045)
10:14:36.359596 ...\Application.cs:110 trace: [RunInternalAsync] AppPath: C:\Program Files\Git\mingw64\bin\git-credential-manager.exe
10:14:36.359596 ...\Application.cs:111 trace: [RunInternalAsync] InstallDir: C:\Program Files\Git\mingw64\bin
10:14:36.359596 ...\Application.cs:112 trace: [RunInternalAsync] Arguments: get
10:14:36.390877 ...GitCommandBase.cs:32 trace: [ExecuteAsync] Start 'get' command...
10:14:36.406472 ...GitCommandBase.cs:46 trace: [ExecuteAsync] Detecting host provider for input:
10:14:36.406472 ...GitCommandBase.cs:47 trace: [ExecuteAsync] protocol=https
10:14:36.406472 ...GitCommandBase.cs:47 trace: [ExecuteAsync] host=github.com
10:14:36.406472 ...GitCommandBase.cs:47 trace: [ExecuteAsync] wwwauth=Basic realm="GitHub"
10:14:36.406472 ...viderRegistry.cs:149 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:14:36.406472 ...viderRegistry.cs:162 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:14:36.406472 ...viderRegistry.cs:170 trace: [GetProviderAsync] Checking against 4 host providers registered with priority 'Normal'.
10:14:36.406472 ...GitCommandBase.cs:49 trace: [ExecuteAsync] Host provider 'GitHub' was selected.
10:14:36.422133 ...bHostProvider.cs:142 trace: [GetCredentialAsync] Found 2 accounts in the store for service=https://github.com:
10:14:36.422133 ...bHostProvider.cs:145 trace: [GetCredentialAsync] chrisant996
10:14:36.422133 ...bHostProvider.cs:145 trace: [GetCredentialAsync] chrisant996
10:14:36.422133 ...bHostProvider.cs:218 trace: [FilterAccounts] Account filtering is enabled.
10:14:36.437754 ...bHostProvider.cs:226 trace: [FilterAccounts] Filtering based on WWW-Authenticate header information...
10:14:36.437754 ...bHostProvider.cs:229 trace: [FilterAccounts] Matched 2 accounts with public domain:
10:14:36.437754 ...bHostProvider.cs:234 trace: [FilterAccounts] chrisant996
10:14:36.437754 ...bHostProvider.cs:234 trace: [FilterAccounts] chrisant996
10:14:36.437754 ...bHostProvider.cs:158 trace: [GetCredentialAsync] Multiple accounts available - prompting user to select one...
10:14:36.468972 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.468972 git.c:462 trace: built-in: git version
10:14:36.484597 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.484597 git.c:462 trace: built-in: git config --null --type=path credential.https://github.com.gitHubHelper
10:14:36.500222 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.515847 git.c:462 trace: built-in: git config --null --type=path credential.github.com.gitHubHelper
10:14:36.531472 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:36.531472 git.c:462 trace: built-in: git config --null --type=path credential.gitHubHelper
fatal: User cancelled dialog.
at GitCredentialManager.Authentication.AuthenticationBase.ThrowIfWindowCancelled(WindowViewModel viewModel)
at GitHub.GitHubAuthentication.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at GitHub.GitHubHostProvider.<GetCredentialAsync>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at GitCredentialManager.Commands.GetCommand.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at GitCredentialManager.Commands.GitCommandBase.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Invocation.AnonymousCommandHandler.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__18_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__5_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<b__0>d.MoveNext()
10:14:45.179802 run-command.c:661 trace: run_command: 'git credential-wincred get'
10:14:45.226676 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:45.226676 git.c:748 trace: exec: git-credential-wincred get
10:14:45.226676 run-command.c:661 trace: run_command: git-credential-wincred get
10:14:45.414177 run-command.c:661 trace: run_command: 'C:/Program\ Files/Git/mingw64/bin/git-credential-manager.exe store'
10:14:45.539177 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:45.539177 git.c:462 trace: built-in: git config --null --list
10:14:45.570428 ...\Application.cs:106 trace: [RunInternalAsync] Version: 2.2.2.0
10:14:45.570428 ...\Application.cs:107 trace: [RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
10:14:45.570428 ...\Application.cs:108 trace: [RunInternalAsync] Platform: Windows (x86-64)
10:14:45.570428 ...\Application.cs:109 trace: [RunInternalAsync] OSVersion: 10.0 (build 19045)
10:14:45.570428 ...\Application.cs:110 trace: [RunInternalAsync] AppPath: C:\Program Files\Git\mingw64\bin\git-credential-manager.exe
10:14:45.570428 ...\Application.cs:111 trace: [RunInternalAsync] InstallDir: C:\Program Files\Git\mingw64\bin
10:14:45.570428 ...\Application.cs:112 trace: [RunInternalAsync] Arguments: store
10:14:45.617303 ...GitCommandBase.cs:32 trace: [ExecuteAsync] Start 'store' command...
10:14:45.617303 ...GitCommandBase.cs:46 trace: [ExecuteAsync] Detecting host provider for input:
10:14:45.617303 ...GitCommandBase.cs:47 trace: [ExecuteAsync] protocol=https
10:14:45.617303 ...GitCommandBase.cs:47 trace: [ExecuteAsync] host=github.com
10:14:45.617303 ...GitCommandBase.cs:47 trace: [ExecuteAsync] username=chrisant996
10:14:45.617303 ...GitCommandBase.cs:47 trace: [ExecuteAsync] password=********
10:14:45.632960 ...viderRegistry.cs:149 trace: [GetProviderAsync] Performing auto-detection of host provider.
10:14:45.632960 ...viderRegistry.cs:162 trace: [GetProviderAsync] Auto-detect probe timeout is 2 ms.
10:14:45.632960 ...viderRegistry.cs:170 trace: [GetProviderAsync] Checking against 4 host providers registered with priority 'Normal'.
10:14:45.632960 ...GitCommandBase.cs:49 trace: [ExecuteAsync] Host provider 'GitHub' was selected.
10:14:45.632960 ...bHostProvider.cs:257 trace: [StoreCredentialAsync] Storing credential with service=https://github.com account=chrisant996...
10:14:45.632960 ...bHostProvider.cs:259 trace: [StoreCredentialAsync] Credential was successfully stored.
10:14:45.632960 ...GitCommandBase.cs:53 trace: [ExecuteAsync] End 'store' command...
10:14:45.648588 run-command.c:661 trace: run_command: 'git credential-wincred store'
10:14:45.695428 exec-cmd.c:243 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
10:14:45.695428 git.c:748 trace: exec: git-credential-wincred store
10:14:45.695428 run-command.c:661 trace: run_command: git-credential-wincred store
Everything up-to-date

@chrisant996 chrisant996 added the auth-issue An issue authenticating to a host label Aug 7, 2023
mjcheetham added a commit that referenced this issue Aug 7, 2023
If may be possible for multiple credentials for the same user account to
exist in any credential store. To avoid issues with redundant account
selection prompts we should ensure duplicate accounts are removed from
the results of `ICredentialStore.GetAccounts`.

Call `.Distinct()` or use a `HashSet` where appropriate on all
implementation of `ICredentialStore.GetAccounts`.

If there are multiple credentials for the same account, we'd only ever
be able to retrieve the first enumerated credential regardless because
our matching logic is to return to first credential that matches.

Fixes #1368
@mjcheetham
Copy link
Collaborator

Thanks for the report that this is still an issue. We've identified an unforeseen data-shape that we have now implemented a fix for. This should be in the next release of GCM (slated to be 2.3.1), and should also be include the next Git for Windows 2.42.0

ldennington added a commit that referenced this issue Aug 11, 2023
Changes:

- Ensure only unique accounts are returned from credential store
  - Issue: #1368
  - PR: #1369
- Migrate GCM from `microsoft/homebrew-git` to `Homebrew/homebrew-core`
tap
  - Issue: #1102 
  - PR: #1374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth-issue An issue authenticating to a host
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants