Skip to content

How should we handle git authentication? #184

Closed

Description

@joshaber

Should we setup the credential cache for them? Set ourselves as a credential cache? Something else entirely?

In Mac, we had a helper program called GitAskpass which we'd set and would talk to the main app.

Activity

  1. shiftkey commented on Jul 27, 2016

    @shiftkey
    Member

    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...

  2. niik commented on Jul 27, 2016

    @niik
    Member

    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.

  3. shiftkey commented on Jul 27, 2016

    @shiftkey
    Member

    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.

  4. pmn commented on Jul 27, 2016

    @pmn

    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.

  5. shiftkey commented on Jul 27, 2016

    @shiftkey
    Member

    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 :trollface:...

  6. pmn commented on Jul 27, 2016

    @pmn

    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?

  7. joshaber commented on Jul 28, 2016

    @joshaber
    ContributorAuthor

    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.

  8. pmn commented on Jul 29, 2016

    @pmn

    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.

  9. joshaber commented on Aug 11, 2016

    @joshaber
    ContributorAuthor

    FWIW the Atom team's going the GIT_ASKPASS route: atom/github#190

  10. joshaber commented on Aug 26, 2016

    @joshaber
    ContributorAuthor

    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:

    1. Get the credentials for github.com (or Enterprise or whatever) from git credential fill.
    2. Test that they work.
    3. If they do, cool.
    4. 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.
    • 👍 We've done it before.
    • 👎 It's a pain in the ass to implement.
    • 👎 Doesn't help users get on The Right Path.
  11. joshaber commented on Aug 26, 2016

    @joshaber
    ContributorAuthor

    Thoughts? Are there other options we should consider?

  12. joshaber commented on Sep 7, 2016

    @joshaber
    ContributorAuthor

    👊

    Anyone have thoughts on this?

  13. shiftkey commented on Sep 8, 2016

    @shiftkey
    Member

    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
  14. added this to the Internal Alpha milestone on Sep 9, 2016
  15. joshaber commented on Sep 9, 2016

    @joshaber
    ContributorAuthor

    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:

    I really like that 👍

    Unless anyone else has feels, it sounds like using the credential store is worth a shot.

  16. niik commented on Sep 9, 2016

    @niik
    Member

    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.

  17. shiftkey commented on Sep 12, 2016

    @shiftkey
    Member

    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.

  18. haacked commented on Sep 13, 2016

    @haacked
    Contributor

    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?

  19. joshaber commented on Sep 13, 2016

    @joshaber
    ContributorAuthor

    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:

    1. 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.
    2. 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.

    @shiftkey @niik does that sound accurate?

  20. haacked commented on Sep 13, 2016

    @haacked
    Contributor

    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?

  21. joshaber commented on Sep 13, 2016

    @joshaber
    ContributorAuthor

    Cool. It might be useful to draw out a list of some of the scenarios and how this approach handles them.

    Yeah good call 👍

    1. If they're authenticating a GitHub repository (.com or Enterprise), we provide the credentials we have. If they're rejected, tell the user.
    2. If they're authenticating a 3rd party repository ...
      1. If we're on Windows try to find the Git Credential Manager and ask it for credentials.
      2. If we're on macOS, let the built in credential cacher handle it.
      3. 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?

    I think that depends on the outcome of #340.

    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.

  22. shiftkey commented on Sep 13, 2016

    @shiftkey
    Member

    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)

  23. self-assigned this
    on Sep 14, 2016
  24. removed their assignment
    on Sep 29, 2016
  25. locked as resolved and limited conversation to collaborators on Jul 24, 2018
  26. unlocked this conversation on Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions