You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the Windows side we called back into GitHub.exe - so we'd need to extract that logic out if we wanted to reuse that.
Git for Windows (and our MinGit) ships with Git Credential Manager - it requires .NET 4.5.something to be installed on the user's machine, but we could leverage that. We had plans to ensure we're playing nice with other Git-based applications and using the credential store on Windows, and I'm pretty sure that's the case here...
As @shiftkey said we set up the exe itself to be the credential provider on Windows. While that has worked fairly well there was a few drawbacks, chief among them being performance. GitHub.exe was real slow to get to the point where it could ask the underlying sqlite db for the credentials which made push and pull needlessly time consuming.
@shiftkey What's your thoughts on dealing with the split world problem if we start relying on Git Credential Manager? What happens if it holds credentials for another account than the one signed into GHD?
And what if it can't find the credentials, won't it pop some interactive prompt? I feel that it's important that we control the credentials fully for our embedded git at least.
What's your thoughts on dealing with the split world problem if we start relying on Git Credential Manager?
I have some concerns, especially if we have our hearts set on making it trivial to migrate from GHD to TNG:9000. If we want to support the ability to run both apps side-by-side we're going to have to address this in GHD.
What happens if it holds credentials for another account than the one signed into GHD?
An excellent question. I guess this could be handled by detecting this and asking the user if they want to migrate it, but that's just a thought (and depends on the previous question)...
And what if it can't find the credentials, won't it pop some interactive prompt?
Possibly. Definitely something we'd need to investigate, especially as it promotes 2FA support.
especially if we have our hearts set on making it trivial to migrate from GHD to TNG:9000
Beyond auth issues, what else is there to migrate from one application to another?
If we want to support the ability to run both apps side-by-side we're going to have to address this in GHD.
Are there strong feels about this? Ideally we would encourage people to migrate to TNG:9000 as soon as is reasonable so that we aren't stuck maintaining multiple disparate versions of Desktop.
Beyond auth issues, what else is there to migrate from one application to another?
I think tracked repositories is the only other thing. Git settings and SSH keys are stored under ~/.
Are there strong feels about this?
I think this is something we can push for from Day 1, but if we don't have feature XYZ that exists in Desktop Classic I can foresee some resistance. But I'm 👍 for doing whatever we can to avoid maintaining three apps ...
I think this is something we can push for from Day 1, but if we don't have feature XYZ that exists in Desktop Classic I can foresee some resistance
Makes perfect sense, and I'm not advocating for shuttering support for Desktop classic as soon as TNG:9000 launches; but would like to strongly encourage people to migrate over to the New Thing ™️ as quickly as is reasonable so we're not stuck in exactly that situation.
I wonder how strongly people would react to having to re-track repositories in TNG:9000 if they knew it's a new thing that's mostly like the old thing on launch day?
I created #186 so we can talk about the data migration question separately.
What's your thoughts on dealing with the split world problem if we start relying on Git Credential Manager?
Would we be able to check if we match the reds in Git Credential Manager, and then update it with our credentials if they don't match?
My impression, and @pmn can correct me if I'm misguided, is that TNG:9000 should do a better job of interoperating with the larger git ecosystem. In my mind, ensuring the credential manager is properly configured could be part of that.
This is still a pretty big unknown, so let's try to 🔨 it down.
I see a couple options:
Credential helper
Use git's built-in credential helper. On macOS, this stores the credentials in the Keychain, and on Windows this stores the credentials in the Windows Credential Store (if using a recent version of Git for Windows).
We could:
Get the credentials for github.com (or Enterprise or whatever) from git credential fill.
Test that they work.
If they do, cool.
If they don't, fill it with our credentials.
👍 Gets the user on The Right Path for command line usage, and plays well with any other utilities that'd leverage git.
👍 Maybe less work?
👎 What happens if it holds credentials for another account than the one signed into GHD?
Git AskPass
Use GIT_ASKPASS as we do in Desktop Classic currently. We tell git to call a program for credentials, and that program then provides our credentials.
👍 Works independently of how the user has anything configured.
I'd rather us play nice with conventions wherever possible:
use the OS credential store rather than roll our own solution
store credentials in ways that other tools can interoperate with us nicely
I'm still favouring the credential helper because of the fewer downsides (and we get to leverage the existing components), but this is an excellent point:
What happens if it holds credentials for another account than the one signed into GHD?
Unfortunately the credential API for OSes doesn't support more granularity in querying beyond the domain name, but I'm also curious how often this is likely to occur - especially given we're focused on new GitHub users.
In this scenario, I think we could easily warn the user that we've found a different set of credentials stored locally and give them two options:
suggest they restart the signin flow with the account found locally, and let them cancel this setup
continue with the setup and overwrite the existing credentials with their new one
Use GIT_ASKPASS as we do in Desktop Classic currently.
To be clear, this is what Desktop Classic on Mac does currently. On Windows we set ourselves up to be the credential helper in the shell environment we ship (where we control the system-level gitconfig) meaning that in addition to delivering stored GH/GHE credentials we'll also happily accept new non-GH credentials from the command line and persist those.
use the OS credential store rather than roll our own solution
This is what we're doing today with keytar, no? And by "own solution" you mean something like what we used to do on Windows (user-level DPAPI encryption into own file). If so then I'm onboard, I'm always in favor of less code, especially when it's xplattish.
I'm still favouring the credential helper because of the fewer downsides
What do you mean by that, are you saying we should invoke the MS credential helper to get our creds? That we should be the credential helper?
Unfortunately the credential API for OSes doesn't support more granularity in querying beyond the domain name
I'm not sure I follow here, since keytar uses generic credentials we get to use an arbitrary string as the key for our passwords, no? Right now it looks like we use GitHub - ${host}
We could... Get the credentials for github.com (or Enterprise or whatever) from git credential fill
Calling git credential fill when the configured credential helper doesn't have the credentials we ask for will interactively prompt the user tho, right? The built-in credential helpers will attempt to collect the credentials from the user on the command line (blocking our execution) and if they've got the MS credential helper configured it'll launch a UI to sign you in (including 2fa).
I think we're conflating a some things here and we should divvy up the scenarios in which this issue is.. an issue...
What environments do we have to deal with?
There's two or more git environments at play here on two platforms (at the moment).
We have the internal environment used by us for shelling out and (potentially) an external shell environment.
On Windows we have our internal git environment which is isolated, used only by us and only intersects with any other installed git environment through the global git config (in the user's home directory). Key point here is that we control the system level gitconfig and can set that up to do pretty much whatever we want, including setting ourselves (or any other application) as the credential helper.
On mac the internal environment has no separate git configuration and instead relies entirely on the system. That's why they use the GIT_ASKPASS environment variable.
Then we have the external environment. On Mac there's a maximum of one (right @joshaber, after xcode has been installed?). On Windows there's none to start with but Git For Windows is the de-facto shell environment (not counting cygwin or the new win10 bash). A lot of users will install it using GitHub Desktop/Win and in that case we install it to a special per-user folder which changes for each update. The non-gh edition installs to C:\Program Files\Git or C:\Program Files (x86)\Git by default but that's customizable. There's also a portable version (which is what we use in GH:D/Win) for people who don't have admin access on their machines (No GHD currently requires this).
Depending on the outcome of #340 that's another environment for Windows as well.
Internal environment
For the internal environment I'd suggest a hybrid approach borrowing from both existing platforms. Prior to invoking a network operation (clone, fetch, push, pull etc) we check keytar to make sure the credentials are there, invoke git with GIT_ASKPASS pointing to our own executable which, when invoked, uses keytar to deliver the credentials, no inter-process communication with the single-instance process. In the unlikely event of a race condition where the credentials are gone when we're invoked by git we'll exit and then deal with that in the single instance process the same way we'd deal with revoked credentials, we'll spot it when git errors out and trigger the sign-in flow again.
External environment
This is where it get tricky. I agree with this sentiment (and the reply)
My impression, and @pmn can correct me if I'm misguided, is that TNG:9000 should do a better job of interoperating with the larger git ecosystem.
Where possible and pragmatic, yes.
On mac it's easy to provide the configured credential helper with creds (I read somewhere that it might even be hardcoded to always be osxkeychain). On Windows it's trickier but we could do it. When possible I think we should synchronize our own tokens the system credential helper. Whether we do it only on login or periodically is up for debate.
Finally, if we ship our own environment on Windows like we do today I think we should configure that environment to call GitHub.exe as the credential helper like we do today.
I'm still favouring the credential helper because of the fewer downsides
What do you mean by that, are you saying we should invoke the MS credential helper to get our creds? That we should be the credential helper?
Currently the Git for Windows environment enables Git Credential Manager for Windows by default for it's credential management. Ideally, I'd love for us to "just use that". We should verify the 2FA stuff they claim they've included works as expected - as well as test against various Enterprise environments.
Unfortunately the credential API for OSes doesn't support more granularity in querying beyond the domain name
I'm not sure I follow here, since keytar uses generic credentials we get to use an arbitrary string as the key for our passwords, no? Right now it looks like we use GitHub - ${host}
This was more related to the point about detecting existing credentials, and then thinking about how these appear in the keychain/credential manager. Currently GfW uses a different format to us when storing credentials:
Calling git credential fill when the configured credential helper doesn't have the credentials we ask for will interactively prompt the user tho, right?
This is correct 😢 - hence me thinking about how things are stored in the keychain/credential manager.
we check keytar to make sure the credentials are there,
Would we check for both git:https://github.com and GitHub - https://api.github.com/USERNAME? If we did, then authenticating in VS would also authenticate Desktop.
invoke git with GIT_ASKPASS pointing to our own executable
Is this a new standalone executable for this purpose or GitHub.exe?
We seemed to be talking past each other a bit so @niik and I zoomed yesterday and @shiftkey and I zoomed last night.
Here's where we ended up:
We'll use GIT_ASKPASS to provide credentials for our operations. Whether this is the app itself or a separate binary is an implementation detail.
We'll provide users the option of syncing their credentials from Desktop TNG to the git credential store. In this way, we'll hopefully interop nicely with the greater ecosystem. On macOS, this'll be straightforward. On Windows, this will probably involve some heuristics to work with Git for Windows.
Cool. It might be useful to draw out a list of some of the scenarios and how this approach handles them. For example, a scenario I'm concerned about would be the user has been using the Git Credential Manager on Windows with one account. They login to Desktop with another and then invoke "Open in Git Shell". What account will that shell be using?
On the other hand, the number of users with multiple accounts is probably vanishingly small so maybe we don't worry about it. But at least we've thought through it.
Another scenario: If you've logged into GitHub for Visual Studio or used the Git Credential Manager to authenticate to github.com, are you automatically logged into Desktop TNG?
Cool. It might be useful to draw out a list of some of the scenarios and how this approach handles them.
Yeah good call 👍
If they're authenticating a GitHub repository (.com or Enterprise), we provide the credentials we have. If they're rejected, tell the user.
If they're authenticating a 3rd party repository ...
If we're on Windows try to find the Git Credential Manager and ask it for credentials.
If we're on macOS, let the built in credential cacher handle it.
If all that fails, we shrug and tell the user. Should we do anything more here? Prompt them?
For example, a scenario I'm concerned about would be the user has been using the Git Credential Manager on Windows with one account. They login to Desktop with another and then invoke "Open in Git Shell". What account will that shell be using?
If you've logged into GitHub for Visual Studio or used the Git Credential Manager to authenticate to github.com, are you automatically logged into Desktop TNG?
Nope. We never use anyone else's credentials. Especially in the case of rando credentials from the Git Credential Manager, we can't rely on them having all the permissions that Desktop needs.
Especially in the case of rando credentials from the Git Credential Manager, we can't rely on them having all the permissions that Desktop needs.
FYI: git-credential-manager will request gist and repo scope when it creates a personal access token on behalf of the user (using the Authorization API)
Activity
shiftkey commentedon Jul 27, 2016
On the Windows side we called back into
GitHub.exe- so we'd need to extract that logic out if we wanted to reuse that.Git for Windows (and our MinGit) ships with Git Credential Manager - it requires .NET 4.5.something to be installed on the user's machine, but we could leverage that. We had plans to ensure we're playing nice with other Git-based applications and using the credential store on Windows, and I'm pretty sure that's the case here...
niik commentedon Jul 27, 2016
As @shiftkey said we set up the exe itself to be the credential provider on Windows. While that has worked fairly well there was a few drawbacks, chief among them being performance. GitHub.exe was real slow to get to the point where it could ask the underlying sqlite db for the credentials which made push and pull needlessly time consuming.
@shiftkey What's your thoughts on dealing with the split world problem if we start relying on Git Credential Manager? What happens if it holds credentials for another account than the one signed into GHD?
And what if it can't find the credentials, won't it pop some interactive prompt? I feel that it's important that we control the credentials fully for our embedded git at least.
shiftkey commentedon Jul 27, 2016
I have some concerns, especially if we have our hearts set on making it trivial to migrate from GHD to TNG:9000. If we want to support the ability to run both apps side-by-side we're going to have to address this in GHD.
An excellent question. I guess this could be handled by detecting this and asking the user if they want to migrate it, but that's just a thought (and depends on the previous question)...
Possibly. Definitely something we'd need to investigate, especially as it promotes 2FA support.
pmn commentedon Jul 27, 2016
Beyond auth issues, what else is there to migrate from one application to another?
Are there strong feels about this? Ideally we would encourage people to migrate to TNG:9000 as soon as is reasonable so that we aren't stuck maintaining multiple disparate versions of Desktop.
shiftkey commentedon Jul 27, 2016
I think tracked repositories is the only other thing. Git settings and SSH keys are stored under
~/.I think this is something we can push for from Day 1, but if we don't have feature XYZ that exists in Desktop Classic I can foresee some resistance. But I'm 👍 for doing whatever we can to avoid maintaining three apps
...
pmn commentedon Jul 27, 2016
Makes perfect sense, and I'm not advocating for shuttering support for Desktop classic as soon as TNG:9000 launches; but would like to strongly encourage people to migrate over to the New Thing ™️ as quickly as is reasonable so we're not stuck in exactly that situation.
I wonder how strongly people would react to having to re-track repositories in TNG:9000 if they knew it's a new thing that's mostly like the old thing on launch day?
joshaber commentedon Jul 28, 2016
I created #186 so we can talk about the data migration question separately.
Would we be able to check if we match the reds in Git Credential Manager, and then update it with our credentials if they don't match?
My impression, and @pmn can correct me if I'm misguided, is that TNG:9000 should do a better job of interoperating with the larger git ecosystem. In my mind, ensuring the credential manager is properly configured could be part of that.
pmn commentedon Jul 29, 2016
Where possible and pragmatic, yes.
joshaber commentedon Aug 11, 2016
FWIW the Atom team's going the
GIT_ASKPASSroute: atom/github#190joshaber commentedon Aug 26, 2016
This is still a pretty big unknown, so let's try to 🔨 it down.
I see a couple options:
Credential helper
Use git's built-in credential helper. On macOS, this stores the credentials in the Keychain, and on Windows this stores the credentials in the Windows Credential Store (if using a recent version of Git for Windows).
We could:
github.com(or Enterprise or whatever) fromgit credential fill.Git AskPass
Use
GIT_ASKPASSas we do in Desktop Classic currently. We tell git to call a program for credentials, and that program then provides our credentials.joshaber commentedon Aug 26, 2016
Thoughts? Are there other options we should consider?
joshaber commentedon Sep 7, 2016
👊
Anyone have thoughts on this?
shiftkey commentedon Sep 8, 2016
I'd rather us play nice with conventions wherever possible:
I'm still favouring the credential helper because of the fewer downsides (and we get to leverage the existing components), but this is an excellent point:
Unfortunately the credential API for OSes doesn't support more granularity in querying beyond the domain name, but I'm also curious how often this is likely to occur - especially given we're focused on new GitHub users.
In this scenario, I think we could easily warn the user that we've found a different set of credentials stored locally and give them two options:
joshaber commentedon Sep 9, 2016
I really like that 👍
Unless anyone else has feels, it sounds like using the credential store is worth a shot.
niik commentedon Sep 9, 2016
To be clear, this is what Desktop Classic on Mac does currently. On Windows we set ourselves up to be the credential helper in the shell environment we ship (where we control the system-level gitconfig) meaning that in addition to delivering stored GH/GHE credentials we'll also happily accept new non-GH credentials from the command line and persist those.
This is what we're doing today with keytar, no? And by "own solution" you mean something like what we used to do on Windows (user-level DPAPI encryption into own file). If so then I'm onboard, I'm always in favor of less code, especially when it's xplattish.
What do you mean by that, are you saying we should invoke the MS credential helper to get our creds? That we should be the credential helper?
I'm not sure I follow here, since keytar uses generic credentials we get to use an arbitrary string as the key for our passwords, no? Right now it looks like we use
GitHub - ${host}Calling
git credential fillwhen the configured credential helper doesn't have the credentials we ask for will interactively prompt the user tho, right? The built-in credential helpers will attempt to collect the credentials from the user on the command line (blocking our execution) and if they've got the MS credential helper configured it'll launch a UI to sign you in (including 2fa).I think we're conflating a some things here and we should divvy up the scenarios in which this issue is.. an issue...
What environments do we have to deal with?
There's two or more git environments at play here on two platforms (at the moment).
We have the internal environment used by us for shelling out and (potentially) an external shell environment.
On Windows we have our internal git environment which is isolated, used only by us and only intersects with any other installed git environment through the global git config (in the user's home directory). Key point here is that we control the system level gitconfig and can set that up to do pretty much whatever we want, including setting ourselves (or any other application) as the credential helper.
On mac the internal environment has no separate git configuration and instead relies entirely on the system. That's why they use the
GIT_ASKPASSenvironment variable.Then we have the external environment. On Mac there's a maximum of one (right @joshaber, after xcode has been installed?). On Windows there's none to start with but Git For Windows is the de-facto shell environment (not counting cygwin or the new win10 bash). A lot of users will install it using GitHub Desktop/Win and in that case we install it to a special per-user folder which changes for each update. The non-gh edition installs to
C:\Program Files\GitorC:\Program Files (x86)\Gitby default but that's customizable. There's also a portable version (which is what we use in GH:D/Win) for people who don't have admin access on their machines (No GHD currently requires this).Depending on the outcome of #340 that's another environment for Windows as well.
Internal environment
For the internal environment I'd suggest a hybrid approach borrowing from both existing platforms. Prior to invoking a network operation (clone, fetch, push, pull etc) we check keytar to make sure the credentials are there, invoke git with
GIT_ASKPASSpointing to our own executable which, when invoked, uses keytar to deliver the credentials, no inter-process communication with the single-instance process. In the unlikely event of a race condition where the credentials are gone when we're invoked by git we'll exit and then deal with that in the single instance process the same way we'd deal with revoked credentials, we'll spot it when git errors out and trigger the sign-in flow again.External environment
This is where it get tricky. I agree with this sentiment (and the reply)
On mac it's easy to provide the configured credential helper with creds (I read somewhere that it might even be hardcoded to always be osxkeychain). On Windows it's trickier but we could do it. When possible I think we should synchronize our own tokens the system credential helper. Whether we do it only on login or periodically is up for debate.
Finally, if we ship our own environment on Windows like we do today I think we should configure that environment to call
GitHub.exeas the credential helper like we do today.shiftkey commentedon Sep 12, 2016
Currently the Git for Windows environment enables Git Credential Manager for Windows by default for it's credential management. Ideally, I'd love for us to "just use that". We should verify the 2FA stuff they claim they've included works as expected - as well as test against various Enterprise environments.
This was more related to the point about detecting existing credentials, and then thinking about how these appear in the keychain/credential manager. Currently GfW uses a different format to us when storing credentials:
This is correct 😢 - hence me thinking about how things are stored in the keychain/credential manager.
haacked commentedon Sep 13, 2016
Would we check for both
git:https://github.comandGitHub - https://api.github.com/USERNAME? If we did, then authenticating in VS would also authenticate Desktop.Is this a new standalone executable for this purpose or GitHub.exe?
joshaber commentedon Sep 13, 2016
We seemed to be talking past each other a bit so @niik and I zoomed yesterday and @shiftkey and I zoomed last night.
Here's where we ended up:
GIT_ASKPASSto provide credentials for our operations. Whether this is the app itself or a separate binary is an implementation detail.@shiftkey @niik does that sound accurate?
haacked commentedon Sep 13, 2016
Cool. It might be useful to draw out a list of some of the scenarios and how this approach handles them. For example, a scenario I'm concerned about would be the user has been using the Git Credential Manager on Windows with one account. They login to Desktop with another and then invoke "Open in Git Shell". What account will that shell be using?
On the other hand, the number of users with multiple accounts is probably vanishingly small so maybe we don't worry about it. But at least we've thought through it.
Another scenario: If you've logged into GitHub for Visual Studio or used the Git Credential Manager to authenticate to github.com, are you automatically logged into Desktop TNG?
joshaber commentedon Sep 13, 2016
Yeah good call 👍
I think that depends on the outcome of #340.
Nope. We never use anyone else's credentials. Especially in the case of rando credentials from the Git Credential Manager, we can't rely on them having all the permissions that Desktop needs.
shiftkey commentedon Sep 13, 2016
FYI:
git-credential-managerwill requestgistandreposcope when it creates a personal access token on behalf of the user (using the Authorization API)