Skip to content

Problem authenticating with multiple accounts in multiple git domains #18824

Closed

Description

@niik

captured from #18586 (comment)

@cloydlau I just tried version 3.4.2-beta2, and the issue still persists. My situation is that I use multiple git domains simultaneously, and under the same domain, I might have multiple accounts. I have been using GitHub Desktop for many years and have never encountered any similar issues before. It seems that the previous logic was that the credentials were at the repository level, but now it appears to have expanded to the domain level. Therefore, if I have multiple accounts under the same domain, problems arise. For example, if I have logged into account A in repository A under domain A, and then I perform a git pull in repository B under domain A with account B, an "Authentication failed" error occurs. I understand that having credentials at the domain level can reduce the number of verifications and improve user experience, but I hope you also consider situations where there are multiple accounts under the same domain.

Activity

  1. niik commented on Jun 12, 2024

    @niik
    MemberAuthor

    @cloydlau In your scenario, are the domains running GitHub Enterprise, GitLab or any other service that's supported by Git Credential Manager (i.e Azure DevOps, Azure DevOps Server (formerly Team Foundation Server), Bitbucket, GitHub, and GitLab)?

    I ask because if it's any of those services then Git Credential Manager should take care of provisioning credentials for you.

    Regardless, you're correct that the previous behavior was (unintentionally) storing credentials per-repo. The default behavior of Git is to store credentials per domain and that's what we're aligning with now. If your domain requires you to have multiple credentials you can configure Git to do so by setting 'useHttpPath'. So if your domain A is say https://git.example.com you would run

    git config --global credential.https://git.example.com.useHttpPath true

    That would make Git pass the entire url to us (and we then to Git Credential Manager). Let me know if that resolves your issue.

  2. cloydlau commented on Jun 12, 2024

    @cloydlau

    At present it looks good (I have enabled Git Credential Manager). Great work! From my understanding, this reverts back to the previous repository-level credential management. If it could support account-level credential management, that would be even better (although it might just be a niche requirement, just saying).

  3. niik commented on Jun 12, 2024

    @niik
    MemberAuthor

    If it could support account-level credential management

    I think this depends on the hosting provider. For Azure Devops for example GCM will create one token per "organisation" (which I think would be the same as account in your case). If you're hosting your repositories on a provider not supported by GCM then it will store credentials based on the entire remote url. There are some providers (like AWS CodeCommit) which has their own credential helpers to handle more complex authentication scenarios but for now Git natively only supports authentication by domain (useHttpPath=false) or on full url (useHttpPath=true) and we don't want to diverge from Git's behavior (again).

    It sounds like this has addressed your issue even though there are possible areas of improvement so I'm going to close this out. Thanks for testing the beta and reporting back. Please open a new issue if you encounter any problems.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions