简体   繁体   中英

Authentication to NuGet on Artifactory from within Visual Studio

We have a local Artifactory Pro server that serves nuget packages and uses LDAP to authenticate all users. Using the Artifactory-NuGet from cmdline works perfectly, but when trying to use the package manager from Visual Studio, authentication fails.

What I noticed is that Visual Studio tries to add a domain prefix after the first failed authentication attempt: Trying to login as 'user' fails, and then the login authentication windows contains 'DOMAIN\\user\u0026#39; as username.

I am not sure if the source of the problem is within Visual Studio or within Artifactory. I noticed that the web access to Artifactory does not accept usernames in the form "DOMAIN\\user\u0026quot;, even though I feel it should.

So my question is: How do I authenticate to an LDAP-backed, Artifactory-provided authenticated NuGet server from within Visual Studio?

确保输入了用户名(LDAP用户名)和加密密码(可以通过工件Web应用程序获得的密码)

I have the same issue, but i am able to dowload via a browser of the NuGet command line.

I looked at the different traffic with fiddler, and it appears the VS is not adding the security token following the authentication. When i download with a browser the traffic shows an additional cookie following the authentication, which is not present in the VS request.

Browser
Request = https://server/repo/artifact.pkg
Responce = 401 not authrised
{user prompted for username and password}
Request = http TUNNEL encryped basic login
Responce = 200 encrypted security token
Request = https://server/repo/artifact.pkg + security token
Responce = 200 the pkg file


Visual studio
Request = https://server/repo/$metadata
Responce = 401 not authrised
{user prompted for username and password}
Request = http TUNNEL encryped basic login
Responce = 200 encrypted security token
Request = https://server/repo/$metadata + security token
Responce = 200 <edmx> list of artifacts
Request = https://server/repo/artifact.pkg
Responce = 401 not authrised
{user prompted for username and password}
Request = http TUNNEL encryped basic login
Responce = 200 encrypted security token
Request = https://server/repo/artifact.pkg
Responce = 301 its moved to "https://server/repo/artifact.pkg"

looks like VS is broken and the cookie is not being stored and sent in the subsequent request. Its probabley using the very horrible Browser component in windows forms, and not retaining the cookie container between request. Might want to report to MS.

If you set up a global NuGet config file which contains your feed names and your authentication, then you can simply add the feed locations to Visual Studio and it will automatically (and silently) pull the authentication from the global config, as long as the feed names in Visual Studio match the feed names in the global config.

See this page https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior to see how to set up the manual config. You can use a machine config, user config or even a solution config and Visual Studio will still pull the auth details from it.

It's frustrating that adding the config file doesn't automatically populate the feed locations in Visual Studio, but at least it's sensible enough to read the authentication details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM