microsoft / Git-Credential-Manager-for-Windows

Secure Git credential storage for Windows with support for Visual Studio Team Services, GitHub, and Bitbucket multi-factor authentication.
Other
2.86k stars 590 forks source link

Git credential manager automatically erases windows credentials #856

Open meenalmenghani opened 5 years ago

meenalmenghani commented 5 years ago

Hi

Issue: I am using proxy to connect to GitHub(proxy is added in .gitconfig), on git fetch(or any command) first time GCM prompts for credentials and stores it in windows credential for both GitHub and proxy. It works fine for some time but after about an hour again on git fetch (or any command) GCM automatically erases the proxy credentials from Windows credential and prompt again for credentials.

First time GCM stores credentials logs GIT 2.22.0 and GCM 1.19.0:


15:28:30.007227 git.c:439               trace: built-in: git fetch origin
15:28:30.012224 run-command.c:663       trace: run_command: GIT_DIR=.git git remote-https origin https://github.com/XXXXX/XXXXXX.git
15:28:30.108230 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:30.110229 git.c:704               trace: exec: git-remote-https origin https://github.com/XXXXX/XXXXXX.git
15:28:30.110229 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/XXXXX/XXXXXX.git
15:28:30.258241 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:30.268247 run-command.c:663       trace: run_command: 'git credential-manager get'
15:28:30.510257 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:30.512257 git.c:704               trace: exec: git-credential-manager get
15:28:30.512257 run-command.c:663       trace: run_command: git-credential-manager get
15:28:31.106301 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'get'
15:28:31.182304 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:31.188305 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:31.192305 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port'.
15:28:31.193305 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:31.255309 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'http://username@proxyhost:port'.
15:28:31.270310 ...\Common.cs:224       trace: [CreateAuthentication] authority for 'http://username@proxyhost:port' is basic with NTLM=Auto.
15:28:31.270310 ...\Common.cs:765       trace: [QueryCredentials] querying 'Auto' for credentials.
15:28:31.277310 ...\Common.cs:780       trace: [QueryCredentials] credentials found.
15:28:32.057663 run-command.c:663       trace: run_command: 'git credential-manager get'
15:28:32.419683 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:32.420683 git.c:704               trace: exec: git-credential-manager get
15:28:32.420683 run-command.c:663       trace: run_command: git-credential-manager get
15:28:32.999720 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'get'
15:28:33.091726 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:33.096728 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:33.100732 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port'.
15:28:33.100732 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:33.169735 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://github.com/'.
15:28:33.186736 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://github.com/'.
15:28:33.186736 ...\Common.cs:176       trace: [CreateAuthentication] authority for 'https://github.com/' is GitHub.
15:28:33.186736 ...\Common.cs:765       trace: [QueryCredentials] querying 'GitHub' for credentials.
15:28:33.193732 ...uthentication.cs:175 trace: [GetCredentials] credentials for 'https://github.com/' found.
15:28:33.593312 ...\Authority.cs:200    trace: [ValidateCredentials] credential validation for 'https://github.com/' succeeded.
15:28:33.593312 ...\Common.cs:873       trace: [QueryCredentials] credentials for 'https://github.com/' found.
15:28:33.594312 ...\Common.cs:709       trace: [LogEvent] GitHub credentials for 'https://github.com/' successfully retrieved.
15:28:34.416396 run-command.c:663       trace: run_command: 'git credential-manager store'
15:28:34.629414 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:34.631420 git.c:704               trace: exec: git-credential-manager store
15:28:34.631420 run-command.c:663       trace: run_command: git-credential-manager store
15:28:35.207446 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'store'
15:28:35.302452 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:35.308453 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:35.312453 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port
15:28:35.312453 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:35.350455 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://PersonalAccessToken@github.com/'.
15:28:35.372456 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://PersonalAccessToken@github.com/'.
15:28:35.372456 ...\Common.cs:176       trace: [CreateAuthentication] authority for 'https://PersonalAccessToken@github.com/' is GitHub.
15:28:35.372456 ...\Program.cs:526      trace: [Store] storing GitHub credentials for 'https://PersonalAccessToken@github.com/'.
15:28:35.437460 run-command.c:663       trace: run_command: 'git credential-manager store'
15:28:35.656474 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:35.658474 git.c:704               trace: exec: git-credential-manager store
15:28:35.658474 run-command.c:663       trace: run_command: git-credential-manager store
15:28:36.247513 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'store'
15:28:36.327518 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:36.332522 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:36.336517 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port
15:28:36.336517 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:36.373521 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://PersonalAccessToken@github.com/'.
15:28:36.394522 ...uthentication.cs:151 trace: [GetAuthentication] created GitHub authentication for 'https://PersonalAccessToken@github.com/'.
15:28:36.394522 ...\Common.cs:176       trace: [CreateAuthentication] authority for 'https://PersonalAccessToken@github.com/' is GitHub.
15:28:36.394522 ...\Program.cs:526      trace: [Store] storing GitHub credentials for 'https://PersonalAccessToken@github.com/'.
15:28:36.426526 run-command.c:663       trace: run_command: 'git credential-manager store'
15:28:36.635538 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:36.637538 git.c:704               trace: exec: git-credential-manager store
15:28:36.637538 run-command.c:663       trace: run_command: git-credential-manager store
15:28:37.201575 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'store'
15:28:37.277580 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:37.282580 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:37.286581 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port'.
15:28:37.287580 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:37.323587 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'http://username@proxyhost:port'.
15:28:37.343584 ...\Common.cs:224       trace: [CreateAuthentication] authority for 'http://username@proxyhost:port' is basic with NTLM=Auto.
15:28:37.343584 ...\Program.cs:513      trace: [Store] storing basic credentials for 'http://username@proxyhost:port'.
15:28:37.375585 run-command.c:663       trace: run_command: 'git credential-manager store'
15:28:37.583605 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:37.585604 git.c:704               trace: exec: git-credential-manager store
15:28:37.585604 run-command.c:663       trace: run_command: git-credential-manager store
15:28:38.158642 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'store'
15:28:38.242648 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
15:28:38.247647 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
15:28:38.251648 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = 'http://username@proxyhost:port
15:28:38.252647 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to 'http://username@proxyhost:port'.
15:28:38.290657 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'http://username@proxyhost:port'.
15:28:38.310651 ...\Common.cs:224       trace: [CreateAuthentication] authority for 'http://username@proxyhost:port' is basic with NTLM=Auto.
15:28:38.310651 ...\Program.cs:513      trace: [Store] storing basic credentials for 'http://username@proxyhost:port'.
15:28:38.343665 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet
15:28:38.420660 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:38.422659 git.c:439               trace: built-in: git rev-list --objects --stdin --not --all --quiet
15:28:38.431659 run-command.c:663       trace: run_command: git rev-list --objects --stdin --not --all --quiet
15:28:38.508667 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:38.510671 git.c:439               trace: built-in: git rev-list --objects --stdin --not --all --quiet
15:28:38.531666 run-command.c:1616      run_processes_parallel: preparing to run up to 1 tasks
15:28:38.531666 run-command.c:1648      run_processes_parallel: done
15:28:38.531666 run-command.c:663       trace: run_command: git gc --auto
15:28:38.609674 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
15:28:38.611671 git.c:439               trace: built-in: git gc --auto
15:28:38.965692 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
15:28:38.967693 git.c:439               trace: built-in: git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD

After some time GCM automatically erases credentials logs GIT 2.22.0 and GCM 1.19.0:

17:22:52.950851 git.c:439               trace: built-in: git fetch origin
17:22:52.953851 run-command.c:663       trace: run_command: GIT_DIR=.git git remote-https origin https://github.com/XXXXX/XXXXXX.git
17:22:53.047858 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
17:22:53.049861 git.c:704               trace: exec: git-remote-https origin https://github.com/XXXXX/XXXXXX.git
17:22:53.049861 run-command.c:663       trace: run_command: git-remote-https origin https://github.com/XXXXX/XXXXXX.git
17:22:53.177867 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
17:22:53.187873 run-command.c:663       trace: run_command: 'git credential-manager get'
17:22:53.447884 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
17:22:53.449883 git.c:704               trace: exec: git-credential-manager get
17:22:53.449883 run-command.c:663       trace: run_command: git-credential-manager get
17:22:54.044922 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'get'
17:22:54.118927 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
17:22:54.124928 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
17:22:54.128927 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = http://username@proxyhost:port.
17:22:54.128927 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to http://username@proxyhost:port
17:22:54.188932 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for http://username@proxyhost:port
17:22:54.203932 ...\Common.cs:224       trace: [CreateAuthentication] authority http://username@proxyhost:port is basic with NTLM=Auto.
17:22:54.203932 ...\Common.cs:765       trace: [QueryCredentials] querying 'Auto' for credentials.
17:22:54.210932 ...\Common.cs:780       trace: [QueryCredentials] credentials found.
17:22:54.308940 run-command.c:663       trace: run_command: 'git credential-manager erase'
17:22:54.520953 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
17:22:54.522953 git.c:704               trace: exec: git-credential-manager erase
17:22:54.522953 run-command.c:663       trace: run_command: git-credential-manager erase
17:22:55.151992 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'erase'
17:22:55.223999 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
17:22:55.230001 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
17:22:55.234000 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = http://username@proxyhost:port.
17:22:55.234000 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to http://username@proxyhost:port
17:22:55.274002 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for http://username@proxyhost:port
17:22:55.295004 ...\Common.cs:224       trace: [CreateAuthentication] authority for http://username@proxyhost:port is basic with NTLM=Auto.
17:22:55.295004 ...\Common.cs:252       trace: [DeleteCredentials] deleting basic credentials for http://username@proxyhost:port
17:22:55.300006 ...aseSecureStore.cs:68 trace: [Delete] credentials for 'git: http://username@proxyhost:port' deleted from store.
17:22:55.326005 run-command.c:663       trace: run_command: 'git credential-manager erase'
17:22:55.539023 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
17:22:55.541022 git.c:704               trace: exec: git-credential-manager erase
17:22:55.541022 run-command.c:663       trace: run_command: git-credential-manager erase
17:22:56.146063 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.19.0) 'erase'
17:22:56.221069 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
17:22:56.226068 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 36 entries.
17:22:56.230071 ...\Common.cs:579       trace: [LoadOperationArguments] http.proxy = http://username@proxyhost:port.
17:22:56.231069 ...tionArguments.cs:605 trace: [SetProxy] successfully set proxy to http://username@proxyhost:port
17:22:56.276079 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for http://username@proxyhost:port
17:22:56.296078 ...\Common.cs:224       trace: [CreateAuthentication] authority for http://username@proxyhost:port is basic with NTLM=Auto.
17:22:56.296078 ...\Common.cs:252       trace: [DeleteCredentials] deleting basic credentials for http://username@proxyhost:port
17:22:56.302082 ...aseSecureStore.cs:59 trace: [Delete] credentials not found for 'git:http://username@proxyhost:port'
17:22:56.770107 exec-cmd.c:238          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
17:22:56.771107 git.c:439               trace: built-in: git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD

Same issue with GCM 1.18.3

But is working correctly with GCM 1.17.2

Could you please help in resolving the issue.

Thanks.

meenalmenghani commented 5 years ago

Any Update?

jeschu1 commented 5 years ago

@meenalmenghani

The erase command is being called from git because an authentication failed. It would be very helpful to see the request that led to the failure to help diagnose the issue.

Can you please try with GIT_TRACE_CURL=1? Let us know what error leads to the failure.

As always please redact any personal information from logs before posting.