microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.38k stars 28.61k forks source link

Vscode cannot access extensions marketplace when http.proxy contains user credentials #196630

Open digeomel opened 10 months ago

digeomel commented 10 months ago

Does this issue occur when all extensions are disabled?: Not applicable, the bug is precisely about extensions

I have checked most previously reported issues related to the proxy and extensions (and there are quite a few and mostly a few years old), and although those have been closed/solved, mine is not.

I'm on Ubuntu 22.04.3 LTS.

First of all, there are two separate issues here: 1) How vscode accesses the extensions marketplace for updates/installs 2) How extensions access the Internet

My proxy-related settings are as follows:

{
    "http.proxy": "http://user:password@10.20.30.40:5678/",
    "http.proxySupport": "on",
    "http.proxyAuthorization": null,
    "http.proxyStrictSSL": false,
}

With the settings above, vscode cannot access the extensions marketplace. If I remove the user:password@ part, everything works fine.

However, and this is related to the 2nd issue, using this extension: https://marketplace.visualstudio.com/items?itemName=chrmarti.network-proxy-test which I assume tests if extensions can access the Internet, it is the other way around. Without the user credentials, it fails, with them it works.

The environment variables http_proxy and https_proxy are both set to http://user:password@10.20.30.40:5678/.

Please note that I also tried setting http.proxyAuthorization to a base64-encoded string of user:password, but that didn't work for both scenarios. In this case, I'm also not sure if special characters like @ which normally have to be url-encoded, as %40, need to be encoded here before passed to base64, or there's no need for encoding at all. I think I tried both.

I realize that for the 2nd issue different extensions might use different ways to access the Internet, and some may not work with the proxy settings, but why can't vscode access the extensions marketplace when user credentials are present?

PS. Redirected here from https://github.com/microsoft/vsmarketplace/issues/783 as I thought that this was an issue with the marketplace.

VSCodeTriageBot commented 10 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.83.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

digeomel commented 10 months ago

This also happens in 1.83.1.

chrmarti commented 10 months ago

We feed "http.proxy" back to Electron which is used for accessing the marketplace. That should work with credentials, but not in this case. Not sure what might make the difference.

digeomel commented 10 months ago

@chrmarti could it be the existence of special URL-encoded characters like @ -> %40 in the password? Should I open this issue with the Electron team? And what is the role of http.proxyAuthorization then?

digeomel commented 10 months ago

Is this the code that issues the request?

https://github.com/microsoft/vscode/blob/7eec26f0f530e3daa3f5bb0b3d12df9725b030f6/src/vs/platform/request/browser/requestService.ts#L28

I found an issue with Electron that's supposed to be closed almost 4 years ago:

https://github.com/electron/electron/issues/21269

chrmarti commented 10 months ago

It turns out that we don't set the proxy for Electron when there is an @ in the URL: https://github.com/microsoft/vscode/blob/56088b01d985ad1b868e3c01b7c4e1ad9247f9e9/src/vs/platform/windows/electron-main/windowImpl.ts#L801. This might have been to work around https://github.com/electron/electron/issues/21269.