NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 253 forks source link

Add support for windows auth in xplat #2393

Closed emgarten closed 4 years ago

emgarten commented 8 years ago

NuGet xplat does not support windows auth. In some scenarios a null reference exception is hit when restore tries to authenticate against a source with windows auth.

https://github.com/dotnet/cli/issues/1679

tebeco commented 8 years ago

So this issue is still opened ?

raffaeler commented 8 years ago

Any workaround? Looks like nuget never liked proxies, but this issue is blocking

emgarten commented 8 years ago

The best workaround is to use NuGet.exe 3.5.0-beta from http://dist.nuget.org/index.html

dotnet restore is a subset of the restore command in NuGet.exe

tebeco commented 8 years ago

I could make 3.5.0beta works behind a proxy with ntlm auth

dotnet restore still fail

Vs2015 use cache inside program files

I have to manually run nuget.exe

So VsCode won't work because it use a separate nuget client

raffaeler commented 8 years ago

I need making dotnet work to avoid a continuous mess in VS2015. From this perspective, the best workaround I found is installing cntlm proxy which works also with nuget 3.4 (the default for the current tools).

I am quite surprised the proxy problem is back since I raised this problem more than 2 years ago with the old nuget.exe.

tebeco commented 8 years ago

The pb is for nuget xplat is it the exact same codebase ?

emgarten commented 8 years ago

@tebeco the codebase for nuget.exe restore and dotnet restore are the same, nuget.exe is built against the desktop framework and contains msbuild and windows auth support. dotnet restore is built using the netstandard libraries and does not have support for all of these yet.

alpaix commented 8 years ago

Original dotnet/cli#1679 issue was caused by a bug in CoreFx (null pointer exception in System.Net.Http) of earlier versions. NuGet supports windows auth out of the box.

As we recently refactored our authentication stack I went ahead and validated reported scenario via NuGet.Server v2.11.2.0 configured with NTLM auth module on IIS Express. No issues spotted in:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x86
.NET Command Line Tools (1.0.0-rc2-002543)

Product Information:
 Version:     1.0.0-rc2-002543
 Commit Sha:  38d0c28a1e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
alpaix commented 8 years ago

@raffaeler @tebeco Could you please confirm the issue has been resolved in your scenarios?

raffaeler commented 8 years ago

Unfortunately / luckily I can't because they finally put nuget in the proxy exception list

tebeco commented 8 years ago

@alpaix what have been resolved ? and using what version of what ;)

I still have issue but it's really weird

On corporate network on .NetCore app

dotnet.exe --version 1.0.0-preview2-003121

Nuget Path is in PATH var and it's CLI 3.5 beta2

nuget NuGet Version: 3.5.0.1520

nuget VSIX is 3.5 Beta2

I have to run manually

nuget restore

Every time I create a new project using for example NUnitit fails to restore pacakges Unless I use nuget CLI :

nuget restore

And it will restore packages from internet and not localCaches, i think the bug may comes from elsewhere

So i guess the NTLM issue is fixed in 3.5-beta2 if that was your question

Else i'm not sure to understand the question ;)

alpaix commented 8 years ago

@tebeco Few questions to you to clarify your complains:

tebeco commented 8 years ago

It's like nugey vsix (v3.5beta2 also) is either bugged or not used when I add manually a line in project.json and just save (not using/tried nuget gui or the powershell prompt inside studio)

And c# extension for vscode have the same issue when I try to open a folder of a netcore app, the extension is triggered but I got the same 407 in the console. And for vscode I have no clues at all to know how to update the nugget client. It seems to be package within dotnet.exe that is within the c# extension (yep ... Inception)

All our corporate stcack in full of pain webapi so in q later future moving to .netcore is not that stupid and probably easy but not unless its tuned to work nicely with ntlm prosy ^^

smezger commented 8 years ago

@alpaix Thanks for solving this issue! It's working now on my side behind the proxy with auth! As you said, I've used:

tebeco commented 8 years ago

Out of curiosity, where does NuGet 3.5.0-rtm-1724 comes from ? I only find beta2

smezger commented 8 years ago

You can download it here: https://dist.nuget.org/win-x86-commandline/v3.5.0-rc1/NuGet.exe However I’ve figured out that it is actually a newer build 1737 and not 1724.

alpaix commented 8 years ago

@tebeco @smezger We've just released 3.5 RC (see the release notes).

alpaix commented 8 years ago

@tebeco Can you share the output from:

dotnet restore ... --verbosity Debug
Madlord commented 8 years ago

Still got error 407 with actual 3.5rc installed.

tebeco commented 8 years ago

@alpaix I'll give it a try today I could not test earlier

mtttcgcg commented 8 years ago

Where should I place this new Nuget.exe in order to make VsCode's dotnet restore command use it?

tebeco commented 8 years ago

You cant It's part of the c# extension if i'm not wrong

alpaix commented 8 years ago

@Madlord Would you be able to capture verbose output and/or Fiddler trace and share it? Please send it to support@nuget.org and mention issue id in the subject.

alpaix commented 8 years ago

@mtttcgcg VSCode invokes dotnet restore to perform NuGet package restore operations. In its turn it doesn't call NuGet.exe but rather uses embedded NuGet API. You can install the latest .NET Core on your desktop from here.

Barryrowe commented 7 years ago

Has anyone confirmed a version of the nuget extension working through an NTLM proxy with a .net core project?

A fresh install of the .net core tools for VS2015 (Preview 2.0.1) shows the same issues. The nuget extenstion installed on my machine is: 3.5.0.1484, and was installed today.

The new dotnet core toolchain fails to properly authenticate to an NTML proxy

In the same solution if we add an old-style project (ASP.NET 4 for example), nuget packages install fine because, as is stated above, it's using the bundled nuget.exe and not the xplat version (or whatever the right name for that is) as @brthor points out here https://github.com/dotnet/cli/issues/3065#issuecomment-224002424

example error messages

C:\Program Files\dotnet\dotnet.exe restore "D:\git-repos\TestNugetInstall\ASPTEST.vs\restore.dg" log : Restoring packages for D:\git-repos\TestNugetInstall\CoreNugetTest\project.json... log : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Web.Xdt''. log : Response status code does not indicate success: 407 (Proxy Authentication Required). log : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Web.Xdt''. log : Response status code does not indicate success: 407 (Proxy Authentication Required). error: Failed to retrieve information from remote source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Web.Xdt''. error: Response status code does not indicate success: 407 (Proxy Authentication Required). error: Failed to retrieve information from remote source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Web.Xdt''. error: Response status code does not indicate success: 407 (Proxy Authentication Required).

tebeco commented 7 years ago

If you can provide me an url of the nuget.exe cli i'll try monday at work A full url of the exe ^^

tebeco commented 7 years ago

So far nuget restore works but not dotnet restore So maybe the version of dotnet could help too

Barryrowe commented 7 years ago

We are just using the bundled version with visual studio 2015 update 3, with the above .net core tools package and nuget extension installed.

The nuget extenstion installed on my machine is: 3.5.0.1484

We are not directly calling the cli, that is happening through the install process with a .net core based project in Visual Studio 2015. The error lines above show that this underneath calls dotnet restore.

The version of the dotnet CLI tools installed are: .NET Command Line Tools (1.0.0-preview2-003121)

Just playing around trying to get you more information, it looks like if I set the http_proxy environment variable, the restore succeeds from the command line.

AFTER running this from the command line, visual studio was able to properly restore as well, as long as the http_proxy environment variable is set. Setting the http_proxy environment variable did not have any effect on running the restore through Visual Studio until after I ran a command line restore. (This is the most surprising find to me).

It appears that maybe whatever interface to the nuget api dotnet restore is using (.xplat?? I'm not familiar enough with the available interfaces to know), is only looking at the environment variable for a proxy url, where I'm guessing using the Nuget.exe restore, it checks the system and ensures the proxy variable is setup in the executing context before running the actual restore. This is just a guess, but hopefully this information helps.

This is being run on Windows 7 Professional

C:\>set http_proxy=[myCorporateProxyWithoutCredentials]

C:\>dotnet -v restore "D:\git-repos\TestNugetInstall\ASPTEST\.vs\restore.dg"
Telemetry is: Enabled
log  : Restoring packages for D:\git-repos\TestNugetInstall\CoreNugetTest\project.json...
log  : Installing Newtonsoft.Json 8.0.1.
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\git-repos\TestNugetInstall\CoreNugetTest\project.json...
log  : Writing lock file to disk. Path: D:\git-repos\TestNugetInstall\CoreNugetTest\project.lock.json
log  : D:\git-repos\TestNugetInstall\CoreNugetTest\CoreNugetTest.xproj
log  : Restore completed in 3340ms.

C:\>set http_proxy=
C:\>echo %http_proxy%
%http_proxy%

C:\>dotnet -v restore "D:\git-repos\TestNugetInstall\ASPTEST\.vs\restore.dg"
Telemetry is: Enabled
log  : Restoring packages for D:\git-repos\TestNugetInstall\CoreNugetTest\project.json...
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json''.
log  : Response status code does not indicate success: 407 (Proxy Authentication Required).
log  : Retrying 'FindPackagesByIdAsyncCore' for source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json''.
log  : Response status code does not indicate success: 407 (Proxy Authentication Required).
error: Failed to retrieve information from remote source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json''.
error: Response status code does not indicate success: 407 (Proxy Authentication Required).
error: Failed to retrieve information from remote source 'https://www.nuget.org/api/v2/FindPackagesById()?id='Newtonsoft.Json''.
error:   Response status code does not indicate success: 407 (Proxy Authentication Required).
tebeco commented 7 years ago

Versions

nuget

NuGet Version: 3.5.0.1737

nuget update -self

Checking for updates from https://www.nuget.org/api/v2/. Currently running NuGet.exe 3.5.0-rtm-1737. NuGet.exe is up to date.

dotnet --version

1.0.0-preview2-003131

Project

Working with .Net Core App Add a nuget that you don't have in Visual Studio Cache (I've used NUnit 3.5) in project.json

Restore

Dotnet CLI

dotnet restore

log : Restoring packages for D:\Sources\Other\NetCoreConsoleapp\src\NetCoreConsoleapp\project.json... error: Unable to load the service index for source https://api.nuget.org/v3/index.json. error: Response status code does not indicate success: 407 (Proxy Authentication Required).

Nuget CLI

TL;DR ==> Working

nuget restore

MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. Restoring packages for D:\Sources\Other\NetCoreConsoleapp\src\NetCoreConsoleapp\project.json... ...

Barryrowe commented 7 years ago

@tebeco Based on the comments on from @brthor here dotnet/cli#3065 (comment) the nuget CLI and the dotnet cli use a different entry point to the nuget api.

Based on my testing, this does seem like an issue with the Visual Studio Nuget Extension (or visual studio itself). I'm just trying to provide the information.

tebeco commented 7 years ago

My answner only use CLI I've used visual studio on tu create a project template and closed it Nuget.exe and dotnet.exe ran into a console prompt

nkolev92 commented 4 years ago

Hey all, Apologies for the long turnaround on this, at this point I think most of the underlying framework issues have been fixed, I believe that it's safe to close this issue.

Please file new issues for any new problems you might hit.