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

Support multiple accounts for remote urls that differ in path #18651

Merged
merged 17 commits into from
May 23, 2024

Conversation

niik
Copy link
Member

@niik niik commented May 20, 2024

ref #18586
based on #18627

Description

Changes our account lookup logic to use the entire remote url (if we get it by Git, i.e. the useHttpPath config option must be turned on for the host).

Prior to 3.3.15 a long lived regex mistake in the parseRemote function caused the hostname for Azure Devops urls to include the first two segments of the path. When we called getGenericHostname on a remote url like https://dev.azure.com/org/repo/_git/repo the hostname would get parsed as dev.azure.com/org/repo thus creating a unique key for storing a token for a specific repository.

When we resolved that flaw all we had access to was the hostname which broke the credential storage for users having multiple repositories across multiple orgs on Azure Devops.

This change will have Desktop honor the full remote url when Git is configured to provide it. We intend to make a change to https://github.com/desktop/dugite to set useHttpPath for dev.azure.com just like Git for Windows does

In this work we've also had to contend with URLs containing usernames such as https://USERNAME@dev.azure.com/username/repo/_git/repo. For these remote urls we've disabled the username input in our password prompt and respect the username from the url.

Screenshot of a password prompt dialog in GitHub Desktop

Release notes

Notes:

niik and others added 13 commits May 16, 2024 13:50
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
We don't want to accidentally reference it

Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
Co-Authored-By: Sergio Padrino <1083228+sergiou87@users.noreply.github.com>
@niik niik requested a review from tidy-dev May 22, 2024 10:26
@tidy-dev
Copy link
Contributor

I was thinking we had a scenario like https://USERNAME@dev.azure.com/username/repo/_git/repo where the username was "xxxyyy" and in the url it was "xxx.yyy". Is the one in the username always correct and the provided one incorrect?

@niik
Copy link
Member Author

niik commented May 22, 2024

The short answer is yes, the provided username before the @ is correct since that's what Git will use. That doesn't mean the other won't work, that's an implementation detail we know nothing about but we're aligning with Git's behavior here

Base automatically changed from proxy-url-without-account to development May 22, 2024 14:46
@@ -7,4 +7,7 @@ export interface IGitAccount {

/** The endpoint with which the user is authenticating. */
readonly endpoint: string

/** The */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P The sounds kind of ominous all by itself.

tidy-dev
tidy-dev previously approved these changes May 22, 2024
Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💖 Thanks for all the work on this issue.

@niik niik dismissed tidy-dev’s stale review May 22, 2024 16:26

The merge-base changed after approval.

@niik niik dismissed tidy-dev’s stale review May 22, 2024 18:01

The merge-base changed after approval.

tidy-dev
tidy-dev previously approved these changes May 22, 2024
…ialog

Add alert semantics to generic git auth dialog
tidy-dev
tidy-dev previously approved these changes May 22, 2024
@niik niik dismissed tidy-dev’s stale review May 22, 2024 18:08

The merge-base changed after approval.

@niik niik requested a review from tidy-dev May 22, 2024 20:18
tidy-dev
tidy-dev previously approved these changes May 22, 2024
@niik niik dismissed tidy-dev’s stale review May 22, 2024 23:59

The merge-base changed after approval.

@danielkoek
Copy link

danielkoek commented May 23, 2024

Ref #18667, this will be the fix, might be handy to update the docs on https://github.com/desktop/desktop/blob/development/docs/integrations/azure-devops.md to clarify that it is org, not username that is being used as the first path segment. (which in the case of a personal project is the username)

It would be also possible to check the first part of the URL https://@dev.azure.com instead of the first segment of the path. in case this still causes regression bugs

@4413a 4413a mentioned this pull request May 23, 2024
@niik niik enabled auto-merge May 23, 2024 11:49
sergiou87
sergiou87 previously approved these changes May 23, 2024
@niik niik dismissed sergiou87’s stale review May 23, 2024 11:49

The merge-base changed after approval.

@niik niik disabled auto-merge May 23, 2024 11:50
@niik niik merged commit a4ca0d6 into development May 23, 2024
7 checks passed
@niik niik deleted the enable-path-based-accounts branch May 23, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants