-
Notifications
You must be signed in to change notification settings - Fork 124
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 private GitLab repositories #281
Comments
I can confirm that this is the case: GitLab does not support raw source file access using Basic Authentication. Additionally, Git Credential Manager for Windows does not support GitLab's OAuth mechanism. Today there is not a good plan moving forward. Personally I hope that GCM will support GitLab's OAuth and we can use some personal access token mechanism, as is done for GitHub via GCM. The branded login/OAuth support for GitHub and BitBucket was contribued to GCM by people from those companies. I hope that GitLab will work with GCM to provide support. As for Basic Auth being a bad idea: basic auth is very common in git scenarios and is mitigated by HTTPS. GitHub and BitBucket both support basic auth for APIs (as long as 2FA is disabled). When in 2FA scenarios, GCM makes use of Personal Access Tokens for GitHub. |
Hi there, thanks for the confirmation, I think its useful to have it written down definitively. I take your point about https, although our policy is that everyone must have two factor auth enabled. Authentication always seems to be a pain, even with the (Microsoft I think) standard OAuth. It feels like it is something that we have got wrong as an industry. |
Have subscribed to updates on this thread as this is something we need as well. |
I've written a small proxy application that I start locally and modified the source link target to localhost. Within the little proxy app I do the authentication (access token based), download the file and forward it to the debugger. That approach works with enterprise on premise gitlab installations, but the disadvantage is that you can only debug if that little proxy tool is running. Is anyone interested in that kind of workaround? |
Yes it is... but not for on premise Gitlab. When you wrote "works with enterprise on premise gitlab", did you mean ONLY or ALSO? |
I think it works for the public gitlab as well. I don't see any reason why it shouldn't work. The special case I had, was a enterprise specific authentication proxy that prevented me from downloading the files from the on premise gitlab instance via a simple http request. |
We would be interested and may test the public gitlab access. |
Hello there. I've got the same problem, so...
|
To my knowledge, Visual Studio still uses basic authentication to retrieve source files. If the credentials inside Visual Studio aren't enough, it falls back to GCM credentials as #281 (comment) points out (if the option is enabled in Debugging/Options). Since Gitlab doesn't support basic authentication anyway, even if the GCM credentials are valid, having valid GCM credentials isn't going to help. This is going to work with other providers like Github, Bitbucket and ADO because:
Gitlab suppports other means of authentication with a PAT, such as:
All means of authentication using a PAT with Gitlab are documented here. For basic authentication, Gitlab is tracking this since Aug 18, 2017 (gitlab-org/gitlab#19189 Allow access to raw files using HTTP Basic Auth) And for GCM itself:
If you self-host Gitlab, you can use https://github.com/rgl/gitlab-source-link-proxy, which is a proxy that passes requests on. I suppose it could work for the usual Gitlab too, but it requires editing both the SourceLink URL and the GCM authorities, which is everything but user-friendly. I see two solutions moving forward:
Unfortunately, both Gitlab issues are stale, and I don't see the VSPT adding Gitlab-specific code, so I suspect this issue will stay open for another couple of years. Edit: And as of today I don't even know if dotnet/sourcelink has any relation with how Visual Studio retrieves the source, besides setting the URL. Maybe the maintainers can answer this, but it might be more appropriate to poke the VSDC directly. |
@bcrosnier are you real? I'll definitely ask for the same OS as yours next christmas... |
@OlegLevitsky |
@lyling it's an actual value of the PersonalAccessToken, nevertheless it doesn't work if you are using gitlab.com |
Tracking this issue also |
mark, this is critical issue for devops |
Working in Windows, I've managed to solve this with a Proxy Server. Perhaps it can help someone else. |
Hmm thanks @sthames42 I will give this a go tomorrow and report back :-) |
GCM team managed to add GitLab support. Even though I haven't had chance to test it yet, it should be possible to use source linking with GitLab.com from now on. More info: |
@darjanbogdan thanks for the info! I will look into this again. |
I had a chance to look at the new GitLab support in GCM. I was able to get an OAuth2 token from it, but there are still several issues integrating with Visual Studio Source Link. For the purposes of this conversation, I am speaking about GitLab.com, and not a self-hosted instance. I do not have access to a self-hosted GitLab for testing, I am only able to test against public. First, two statements of fact:
These two things combine to make the tokens provided by GCM for GitLab currently incompatible with VS Source Link. As far as I can tell, the web-based URL's do not accept header-based auth. Trying to use the token from GCM as either "Basic" or "Bearer" tokens gives a redirect to a sign in page which results in a 503. I also took a look at using GitLab API based URL requests with the token provided by GCM. Unfortunately, this returns 401 Unauthorized for everything I tried. I believe the issue is the scope of the OAuth token obtained by GCM:
Conclusions:
If anybody from GitLab or the Git Credential Manager project can speak to these points, I would really appreciate some insights. |
Since the missing But somehow, SourceLink is still not able to download source files and shows following error:
My assumtion is, that Gitlab still rejects the access token it gets from SourceLink/Git Credential Manager and redirects to the login page (we are using SSO with Active Directory). Is there any way to verify this behavoir? Additionally, I came across this issue but I don't understand if this could still be a showstopper. Any thoughts on this? |
I can access https://gitlab.com/my_private_repo/raw/b80730a8f00280424cb3fb1d8d18e0d6fedb7d78/******.cs in my chrome.
Applications has been added. |
I tried using a proxy approach as suggested by a few users above, but even though it successfully pulled the code from GitLab, the debugging experience in Visual Studio was impossible. On every step-over/step-into attempt, VS seems to be attempting to validate the checksum of the source code, and failing due to a difference in encoding (UTF8/UTF8-BOM, and CRLF/LF). I'm struggling to think of a reliable way to translate the raw file content in my proxy service. |
I noticed two issues that lead me to believe that the GCM integration in VS is still broken (at least for GitLab).
I wouldn't be surprised if these two issues above also apply to the regular Token based auth. @christianerbsmehl |
Ok, I took another stab at this with Fiddler. It looks like VS is still trying to retrieve the file from GitLab using Basic Auth, which we already know is not supported GitLab allows supplying the token via header or query string, see here. |
Hi everyone. I've spent some time deciphering the issues and found a simple solution that only requires installing a NuGet package. Check it out: Genbox.GitLabSourceLink It works the same way as Microsoft.SourceLink.GitLab, except it also works for self-managed GitLab instances. I would have liked to contribute it to the official source link packages, but I saw no way to implement it due to limitations in how it produces sourcelink.json. Let me know if anyone from the sourcelink team wants to make it work in the official Microsoft.SourceLink.GitLab package. |
Hi! Very interesting! But the reference looks broken (404)... Or you point to the private repos. |
What reference are you referring to? The examples in the repo only works when the code is hosted on a GitLab instance. It uses the URL of the git remote. Edit: I'm a big doofus. The repository was private. I've fixed that now :) |
Just to be sure - you are talking about gitlab.com repos right? I ask because they have had that behavior on self-hosted GitLab instances forever. It begins to seem intentional, but it is buggy behavior. |
Yeah, you're absolutely right ... I was getting confused about how our proxy works. |
I'm having the same issue, local gitlab on prem and trying to have either the pdb or the sourcelink working and none of them are working. Is there any developments on this issue? |
I managed to create a solution. No proxies, no hacks. I have been using it at work (600+ projects) for some time now. |
@tmat thoughts on this one? |
In the readme you mentioned you've tested with PAT token. How? I mean, I have the nuget published with pdb symbols but now the client (as in, Visual studio) needs to authenticate the request in order to get the the files for debugging. That's the step that needs the PAT (I think). If it is, where and how to I set the PAT to be used by the client? Am I'm missing something? |
@dosper7 please create an issue in the GitLabSourceLink repo so we don't make too much noise here :) |
Need some help understand what is going on, I've done the "playbook" and visual studio is still saying that it has decompiled instead of using the sourcelink (maybe I'm missing something). Here is what I've tested: My lib csproj
I'm using dotnet cli ->
When I debug it and step into I have this: I also notice that in the nuget folder I have the downloaded lib, when I check for nuget info validation i have this: However, If I manually download the snupkg manually from the registry and put it in the same folder as the nupkg, the validation it's ok: But I'm still unable to use the sourcelink, or at least it seems it's not working because I see in the modules window the info that it "decompiled" the lib. So it seems it can be two issues:
Does this information helps? This has been a bit frustrating, so any help or info I can provide to move forward please ping me 🙏 |
AFAIK, the Visual Studio debugger does not support snupkg, but if you upload a snupkg file to NuGet.org, then there is a symbol server from which the debugger can request the PDB files. So if you are not using NuGet.org, then check whether your NuGet hosting service has a similar symbol-server feature, or perhaps embed the debug info into the DLL files so that it need not be downloaded separately. |
Hi There
After a lot of trawling the internet I am fairly sure that SourceLink does not support private GitLab repositories. Based on my reading I think this is because GitCrendentialManager will only use Basic Authentication, and GitLab will not accept Basic Authentication.
Firstly, can someone confirm that this is the case?
Secondly, is there a plan to fix this? SourceLink is near useless to us unless we can use it with private repositores. My initial thought is that its not acceptable to ask GitLab to support Basic Authentication, being as it is basically a bad idea.
Thanks
Cedd
The text was updated successfully, but these errors were encountered: