question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Git Credential Manager and ContentUrl with port

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peeveencommented, Nov 16, 2022

@chuckries I got an email telling me that this was fixed in VS 17.5 Preview 1, so I gave it a try, and it seems to be working. I’ll close this. Thanks for your help.

1reaction
peeveencommented, Oct 27, 2022

This all sounds very promising. Thanks very much for this. I expect I will eventually be running the proxy again a “proper” hostname (without a port), but I thought I’d better bring this to your attention, as it looked like a defect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git - Credential Storage
This method stores the credentials on disk, and they never expire, but they're encrypted with the same system that stores HTTPS certificates and...
Read more >
Git pull server message : warning: url has no scheme IP ...
it says : warning: url has no scheme IP:Port , fatal: credential url cannot be parsed IP:Port . i tried to set new...
Read more >
Git - git-credential Documentation
Use the credential (e.g., access the URL with the username and password ... This includes the port number if one was specified (e.g.,...
Read more >
git-credential-manager/docs/faq.md at main
Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, ... Execute git remote -v from a terminal to show the remote...
Read more >
Git-Credential-Manager-for-Windows/Docs/Faq.md at master
Secure Git credential storage for Windows with support for Visual Studio Team Services, GitHub, and Bitbucket multi-factor authentication.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found