Support basic authentication #1

Closed
xavierdecoster opened this Issue Apr 4, 2014 · 13 comments

Projects

None yet

8 participants

@xavierdecoster

Steps performed:

  • Created a private myget feed which hosts private chocolatey packages
  • Add-PackageSource -Name initech -Location https://www.myget.org/F/initech-chocolatey -Trust -Provider Chocolatey
  • Install-Package -Source initech

Exception:
No Package Found
2014-04-04_1156

Expected:
prompt for credentials (basic auth: username/pwd)

Alternatively:
since chocolatey provider is using nuget under the hood, storing nuget credentials in nuget.config could be taken into account (tried, doesn't work)

@fearthecowboy fearthecowboy added the bug label Apr 18, 2014
@fearthecowboy
Contributor

There are two issues

  • lack of credential support.
  • lack of additional metadata fields for sources.
@nlowe
nlowe commented Jul 15, 2015

Are there still plans to implement this? I cannot add authenticated package sources, they fail saying that the Web URI is invalid. This is incorrect (the endpoint is actually returning a 401).

@jianyunt jianyunt added the New Feature label Jan 7, 2016
@jianyunt jianyunt added this to the 1606 milestone Jan 7, 2016
@jianyunt jianyunt removed the bug label Jan 7, 2016
@Stijnc
Stijnc commented Mar 16, 2016

Any word on when milestone 1606 will be reached?
With Visual Studio Team services (former VSO) now offering a private nuget feed we could benefit from credential support in oneget.

@jianyunt
Contributor

We will publish a new version of the Nugetprovider with -credential support in a week or so. Stay turned.

@quoctruong

@Stijnc The latest version of NuGetProvider is now available. You can install it with Install-PackageProvider NuGet -Force.

After installing the latest NuGetProvider, you can try Find-Package with -Credential parameter.

@Stijnc
Stijnc commented Mar 24, 2016

@quoctruong works like a charm.

PS C:\WINDOWS\system32> Find-Package -Source testvs -Credential (get-credential)

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential

Name                           Version          Source                         Summary
----                           -------          ------                         -------
fiddler                        2.4.9.9          testvs

I only had an issue registering the my package source.

PS C:\WINDOWS\system32> Register-PackageSource -Location $Uri -Name 'AuthPackageSource' -ProviderName Nuget -Force -Tru
sted
Register-PackageSource : MSG:SourceLocationNotValid
«https:/*****.pkgs.visualstudio.com/DefaultCollection/_packaging/**********/nuget/v3/index.json»
At line:1 char:1

using nuget to register the source on the other hand worked as expected and I could use the find-package cmdlet as expected using a credential

@jianyunt
Contributor

@Stijnc, thanks for validating it. Regarding register-packagesource, we discussed within our team whether we should support it. True, the nuget supports it. It saves your encrypted cred in the config. We think it may or maynot be a good idea to save user's cred. So we decided to not support it by now. If this is a common user scenario, please let us know. We can consider it. thanks!

@Stijnc
Stijnc commented Mar 25, 2016

@jianyunt @quoctruong well, to test the credential support in Find-package I registered the source using nuget without specifying any credentials.
the register-packagesource throws an error registering the source, which is a bit odd.
I now need to register the source using nuget and only afterwards I can use find-package with credential support.
Below the extract:

  1. successful registration using nuget (without saving credentials)
  2. removing the source registration using nuget
  3. failed registration using Register-PackageSource
PS C:\> nuget sources add -name "powershelldev" -source https://*****.pkgs.visualstudio.com/DefaultCollection/_packa
ging/******/nuget/v2
Package Source with Name: powershelldev added successfully.
PS C:\> nuget sources remove -Name powershelldev
Package source with Name: powershelldev removed successfully.
PS C:\> Register-PackageSource -Name 'powershelldev' -Location 'https://******.pkgs.visualstudio.com/DefaultCollectio
n/_packaging/*******/nuget/v2' -ProviderName NuGet
Register-PackageSource : MSG:SourceLocationNotValid
«https://*****.pkgs.visualstudio.com/DefaultCollection/_packaging/********/nuget/v2»
At line:1 char:1
+ Register-PackageSource -Name 'powershelldev' -Location 'https://****** ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (powershelldev:String) [Register-PackageSource], Exception
    + FullyQualifiedErrorId : SourceLocationNotValid,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSo
   urce
@slimracing

I am having a similar issue with PSGet and an authenticated feed. Find|Install-Module does not seem to pick up the NuGet config which works for chocolatey and the 401 returned from the feed results in a warning: 'Unable to resolve package source'.

Is this a new issue or will it be addressed when this is resolved?

@jianyunt
Contributor

Correct. I think NuGet provider does not read the cred from nuget.config.
Instead we added -credential support in the cmlets find-module/package, install-module/package recently. So you can do

Find-Module -Name xjea -Credential (get-credential)

The change will be in the next release of Windows or WMF.

@MichaelStankiewicz

Whenever I use register-packagesource or register-psrepository in a DSC resource, I get an exception stating that the url isn't valid. However if I run the same code in my user context, it works fine. Is there any support coming for a system wide package source registration?

@jianyunt jianyunt added the Fixed label Aug 15, 2016
@quoctruong quoctruong was assigned by jianyunt Aug 15, 2016
@jianyunt
Contributor

@MichaelStankiewicz, the Auth and Proxy are supported in WMF 5.1

In WMF 5.1, OneGet supports finding and installing packages from a repository that requires basic authentication. You can supply your credentials to the Find-Package and Install-Package cmdlets. For example:

Find-Package -Source <SourceWithCredential> -Credential (Get-Credential)

Support for using OneGet behind a proxy

In WMF 5.1, OneGet now takes new proxy parameters: -ProxyCredential and -Proxy. Using these parameters, you can specify the proxy URL and credentials to OneGet cmdlets. By default, system proxy settings are used. For example:

Find-Package -Source http://www.nuget.org/api/v2/ -Proxy http://www.myproxyserver.com -ProxyCredential (Get-Credential)
@jianyunt
Contributor
jianyunt commented Nov 3, 2016

Supported in WMF 5.1 or Windows Server 2016 or Win10 Anniversary.

@jianyunt jianyunt closed this Nov 3, 2016
@quoctruong quoctruong was unassigned by jianyunt Nov 3, 2016
@jianyunt jianyunt removed the New Feature label Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment