如何使用身份验证代理指定Visual Studio代码的用户标识和密码?

问题描述 投票:17回答:8

如何使用身份验证代理指定Visual Studio代码的用户标识和密码?

我在主要的VS Code网站上看过Proxy Server Support,但这只提到了两个设置......

"http.proxy": "http://10.203.0.1:5187/"
"http.proxyStrictSSL": false

我设定了这些,但仍然没有运气,例如我无法安装扩展程序...甚至无法获取它们的列表

我怀疑它是我们的代理,因为它需要用户ID和密码:-(

那你怎么设置这些值呢?

proxy visual-studio-code
8个回答
26
投票

在代理URL中设置凭据:

http://username:[email protected]:5187/

警告:在文件中以明文形式设置密码很容易导致您的帐户遭到入侵。此外,它可能违反了您的公司数据安全准则。 https://cwe.mitre.org/data/definitions/256.html


22
投票

如果您不想将凭据存储在设置文件中,可以使用fiddler代理对代理的调用。此外,我相信上述仅适用于使用基本身份验证的代理服务器,以下内容适用于NTLM。

VSCode打开设置文件:

%APPDATA%\代码\用户\ settings.json

添加以下内容:

{
    "http.proxy": "http://127.0.0.1:8888",
    "http.proxyStrictSSL": false
}

提琴手确认提琴手设置:

enter image description here enter image description here

Fiddler确保Fiddler设置为自动验证:

enter image description here

VSCode Extensions现在应该在线:

enter image description here


更新

现在,在版本1.15 PR #22369中实现的Proxy server authentication实现后不再需要这样做了。

在我的情况下,我仍然需要添加:

"http.proxyStrictSSL": false

5
投票

我最喜欢的回应是David Martin建议使用Fiddler。但是,如果您不想进行此操作,则下面是如何设置代理的凭据。

要指定DOMAIN +用户名+密码:(它可能无法使用斜杠,因此请使用%5C代替斜杠,如下所示)

// The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"http.proxy": "http://DOMAIN%5Cusername:password@proxy_name_or_ip:port",
"https.proxy": "http://DOMAIN%5Cusername:password@proxy_name_or_ip:port",

// Whether the proxy server certificate should be verified against the list of supplied CAs.
"http.proxyStrictSSL": false,

仅指定用户名+密码:

// The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"http.proxy": "http://username:password@proxy_name_or_ip:port",
"https.proxy": "http://username:password@proxy_name_or_ip:port",

// Whether the proxy server certificate should be verified against the list of supplied CAs.
"http.proxyStrictSSL": false,

4
投票

请参考本文。 https://taeguk.co.uk/blog/working-in-visual-studio-behind-the-firewall/

我们假设我的NTLM登录是DOMAIN \用户名,我的密码是P @ ssword!凭据的格式必须是DOMAIN \用户名:P @ ssword!,但您需要URL编码用户名和密码。一个简单的在线URL编码可以将您的用户名和密码翻译为:DOMAIN%5CUser%20Name和P%40ssword!。将所有这些信息分成一个单独的字符串,如下所示:http://DOMAIN%5CUser%20Name:P%[email protected]:8881然后将其添加到文件中的用户设置,首选项中对“http.proxy”值://将您的设置放在此文件中以覆盖默认设置{“http.proxy “:”http://DOMAIN%5CUser%20Name:P%[email protected]:8881“}


2
投票

“http.proxy”:“http://DOMAIN//USER:[email protected]:8080”。别忘了添加端口。


2
投票

值得尊敬的CNTLM可以帮到你。你给它你的凭据,告诉它有关上游代理,在本地机器上运行它,然后将VS指向http://localhost:3128的代理。

http://cntlm.sourceforge.net/

对于不支持经过身份验证的代理的任何应用程序,它都是一个方便的解决方案。


0
投票

在Visual Studio Code(我的版本是1.32.3)中你写了一个请求,即

### my request
GET https://defdomain.prefix.com/app/resource
Authorization: bXl1c2VyOnVzZXIyMkBwYXNzd29yZA==

因此,Authorization标头的类型为“Basic base64encoded”,由myuser:user22 @ password(用户名:usercredentials)base64编码组成。就这样。


0
投票

使用以下命令并替换您的proxy:port的用户名,密码和IP地址

PS C:\ Users \ rathakrishnan> npm config set proxy http://username:[email protected]:3128

PS C:\ Users \ rathakrishnan> npm install -g @ angular / cli

© www.soinside.com 2019 - 2024. All rights reserved.