Skip to content

Git Credential Manager and ContentUrl with port #894

@peeveen

Description

@peeveen

Hi,

As is well documented in this issue, internal GitLab repositories don't play nice with SourceLink, but there is a workaround of using a proxy to retrieve the source via the GitLab API, by specifying the proxy URL via the ContentUrl property:

<SourceLinkGitLabHost Include="gitlab.myinternal.com" ContentUrl="https://blah:1234/" />

I've been putting a proxy together, and it all seems to work well, but I've noticed an oddity with how the credentials are retrieved from Git Credential Manager.

If I run my proxy on a URL with a port (e.g. https://blah:1234), and register credentials with GCM:

> git credential-manager-core store
protocol=https
host=blah:1234
username=myusername
password=mypassword
^Z

... when the time comes to fetch some code, Source Link gives an error:

Source Link Error:
git-credential-manager-core.exe: Could not obtain credentials. Process failed with exit code -1.
ERROR: The request failed with code 401 : "Unauthorized".

HOWEVER, if I use the same git credential-manager-core store command but omit the port:

> git credential-manager-core store
protocol=https
host=blah
username=myusername
password=mypassword
^Z

... then Source Link is happy, and all goes well.

So I don't know if this is a Source Link or Visual Studio thing, but it looks like the port gets stripped when asking for credentials from GCM, which I don't think is right.

This has another knock-on effect ... if the credentials are not pre-registered in GCM, a git credential-manager-core get command will usually launch a credentials login dialog if it detects a service at the specified host, and that does not happen from VS when the URL has a port, so a user is forced to add credentials manually.

EDIT: a bit more evidence ... here's me requesting GCM credentials for my proxy running on localhost:5042:

image

As you can see, GCM prompts for credentials, as it has detected the service at the given location.
And now here's me requesting the credentials, but omitting the port:

image

So it looks like GCM does want the full host (name and port), but I'm pretty sure that VisualStudio/SourceLink is only requesting credentials for the host name (without the port).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions