WIP: Integrate AzArtifacts Credential Provider #1765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This PR integrates the Azure Artifacts Credential Provider into PSResourceGet.
Information on the cred provider and how to install, discover, and use the cred provider is located here: https://github.com/NuGet/Home/wiki/NuGet-cross-plat-authentication-plugin#plugin-installation-and-discovery.
Please use this link for setting up and configuring the cred provider for PSResourceGet as well.
This PR adds a new dynamic parameter to
Register-PSResourceRepository
andSet-PSResourceRepository
called-CredentialProvider
, which is an enum with valuesNone
andAzArtifacts
. The parameter only works with repositories that are notContainerRegistry
repositories. This is because the credential provider only works with Azure Artifact feeds, however Azure Artifact feeds can have any uri. Instead of only allowing the parameter to be used with Azure Artifact feeds, we are not allowing use for feeds in which we know we cannot use the credential provider for.PSResourceGet will automatically set the value
CredentialProvider
toAzArtifacts
if it recognizes that the repository is definitely an Azure Artifacts feed. This is done by checking to see if the uri containspkgs.dev.azure.com
orpkgs.visualstudio.com
. This check is done when registering a new repository or when PSResourceGet reads repositories from thePSResourceRepository.xml
file.PSResourceGet looks for the credential provider any time network credentials are set. The new priority ordering for credentials is:
1. Credentials passed in via parameter
-Credential
.2. Credentials retrieved via the AzArtifacts Credential Provider.
3. Credentials retrieved from SecretManagement.
The Credential Provider can be bypassed by setting the
-CredentialProvider
parameter toNone
.If the
CredentialProvider
property is set toAzArtifacts
for a repository, PSResourceGet will attempt to find the Credential Provider file on the machine in the following order:1. Checking the environment variable
NUGET_PLUGIN_PATHS
2. Checking the default locations:
$env:UserProfile\.nuget\plugins
3. Checking the fixed location where Visual Studio is installed:
common7\IDE\CommonExtensions\Microsoft\NuGet
More information on this discovery process can be found in the link above.
Once the Credential Provider is found, PSResourceGet calls the provider with the following arguments:
CredentialProvider.Microsoft.exe -Uri <uri> -NonInteractive -IsRetry -F Json
Or
dotnet CredentialProvider.Microsoft.dll -Uri <uri> -NonInteractive -IsRetry -F Json
Right now, this means that for Unix machines, there is a dependency on the dotnet cli to call the Credential Provider.
Once credentials are retrieved, they are used to make the network call, as is done when using the
-Credential
parameter or SecretManagement.PR Context
Resolves #1658
Resolves #1601
Resolves #1511
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.