-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
401 Authentication errors on a solution that has mixed dotnet and MSBuild dependencies #1243
Comments
Should be fixed in #1241? |
It looks like for projects that use NuGet.exe to perform the update (i.e. .NET Framework projects with I think ideally we don't want this to happen; it would be preferable to rely on the Azure Artifact Credential Manager to handle auth rather than having Dependabot fiddle with the config files. Additionally, the way Dependabot currently modifies the nuget.config file only allows for feeds supporting PAT's, not basic auth (e.g. Telerik NuGet feed). I'll setup a test repo with a .NET Framework 4.8 project and see if I can reproduce this issue and see what options there are. My guess is if Dependabot didn't proxy Your comment about the extra environment variables is pretty valid. I wonder if we could modify the extension to accept a dictionary instead of a string, this way you can use - task: dependabot@1
inputs:
dockerImageTag: '1.30'
extraEnvironmentVariables:
WORKAROUND_CMD: "sh -c "$(curl -fsSL https://aka.ms/install-artifacts-credprovider.sh)"
NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED: "true"
VSS_NUGET_EXTERNAL_FEED_ENDPOINTS: '{"endpointCredentials":[{"endpoint":"https://pkgs.dev.azure.com/myorg/_packaging/myfeed/nuget/v3/index.json","username":"unused","password":"$(System.AccessToken)"}]}'
NuGetPackageSourceCredentials_nuget_source_1: "UserName=unused;Password=***" @mburumaxwell thoughts? |
I have checked my solutions, and it was using old version of .NET & .NET Core frameworks, but I have updated all projects to either .NET 4.8 or .NET Core 8.0 and still get the same behavior. Looking again at the looks, I think the problem area, trying to build a minimalist repo is as follows
This would tally with your comment about proxying configs
|
I have stripped my problematic solution down to the minimum that that exhibits the problem i.e. one class library (with most of it's logic removed), and an empty MVC website that references it. Thought it might help with the repo of this issues This solution still reports the same 401 error when it tries to use a private Azure DevOps artifact feed (that has an upstream of Nuget.org) to get public packages
|
Thanks. I've managed to reproduce the issue now and have a draft fix; It's not pretty, but it is a fix. |
I've put up #1248, which should fix this issue without needing to override |
@bm-fez can you please re-test this using the tag Your pipeline.yml can now be simplified to: - task: dependabot@1
inputs:
dockerImageTag: 'latest'
targetRepositoryName: $(Build.Repository.Name)
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) No changes required to dependabot.yml (i.e. |
@rhyskoedijk Thanks for providing the update, unfortunately I am still seeing the same problem (using the .NET 4.8 sample I uploaded previously in this issue). I have tried various changes using the docker tag to 1.30.3-ci0004 (used for all test)
In all cases I see the same error (full log of task)
The settings I currently have are
version: 2
registries:
nuget-azure-devops:
type: nuget-feed
key: internalfeed
url: https://pkgs.dev.azure.com/blackmarble-source/_packaging/BM-Libs/nuget/v3/index.json
token: PAT:${{SYSTEM_ACCESSTOKEN}}
updates:
- package-ecosystem: "nuget"
directory: "/Src"
open-pull-requests-limit: 6
registries:
- nuget-azure-devops
- task: dependabot@1
displayName: dependabot-$(Build.Repository.Name)
enabled: true
inputs:
# These two inputs are needed to workaround a bug in dependabot that breaks authentication to private nuget feeds in some cases, see: https://github.com/tinglesoftware/dependabot-azure-devops/issues/921#issuecomment-2162273558
# Once the following issue is resolved, bump the image tag to the version with the fix and the inputs can be removed: https://github.com/dependabot/dependabot-core/pull/8927
dockerImageTag: '1.30.3-ci0004'
extraEnvironmentVariables: 'WORKAROUND_CMD=sh -c "$(curl -fsSL https://aka.ms/install-artifacts-credprovider.sh)";NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true;VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials":[{"endpoint":"https://pkgs.dev.azure.com/blackmarble-source/_packaging/BM-Libs/nuget/v3/index.json","username":"unused","password":"$(System.AccessToken)"}]}'
targetRepositoryName: $(Build.Repository.Name)
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) and the <?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="internalfeed" value="https://pkgs.dev.azure.com/blackmarble-source/_packaging/BM-Libs/nuget/v3/index.json" />
</config>
</configuration> Have I missed something obvious, or misunderstood ? |
Sorry, one other thing I forgot to mention is that you'll need to use the "vNext" update script as the auth changes were not backported to the [default] update script that you are using. I will put up a PR to backport this change, but for now you should be able to test this using the vNext script with: - task: dependabot@1
inputs:
dockerImageTag: '1.30.3-ci0004'
useUpdateScriptvNext: true # <-- use the new script, which has the auth fixes
targetRepositoryName: $(Build.Repository.Name)
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken) I can see from your logs that the username being detected is still "user", which tell me the fix was not run.
If the fix is running, it should say "UserName: PAT". The |
@rhyskoedijk adding |
Describe the bug
The problem
I have been using this Azure DevOps task against a legacy solution that contains .NET 4.8 and .NET Core projects, hence it is doing a mixed
dotnet
andMSBuild
process against a private Azure DevOps NuGet package feed.Using the 1.30 Docker image, and the parameters for a private feed I can get most of it working.
My pipeline YAML
My config file
All the 403 errors I saw initially, prior to the extra parameters, are resolved. However, I am still seeing authentication issues for MSBUILD dependencies
It looks as if a dynamic NuGet source
nuget_source_1
is being used which is not picking up the configured authentication credentials.A workaround (sort of)
After much experimentation, running the container locally I have a workaround.
If I set an environment variable on the Docker command line via a
-e
parameterIt works, however there is a problem applying this workaround to the Azure DevOps task
The problem with the workaround
The issue is that this extra environment variable needs to include a
;
between the user and passwrod, but this character is being used to delimiter the parts ofextraEnvironmentVariables
that will become docker-e
parameters. This means the new environment variable is split into two on the;
by the time it reaches the docker run commandI see
as opposed to the required
I have tried all I can think of to escape the
;
in the environment variable e.g.\x3b
, so that the unescaped;
are used to split the parameter by Azure DevOps (in Typescript), and the escaped;
is handled by the Docker command line (BASH), but I can't get it to work, the escaping is not resolved.Questions/Options
This work around raises a number of questions as to if it is really needed and how to apply it
NuGetPackageSourceCredentials_nuget_source_1
environment variable is not required?NuGetPackageSourceCredentials_<source>
as I don't like that I have to set it up manually?;
in task parameter?;
Azure DevOps task be made configurable, so a swap could be made to one that does not clash with the;
. Using\n
might make the long parameter more readable (of course leaving the default as;
for backwards compatibility. Any thoughts on this?Categorization
To Reproduce
I am not sure of the exact solution structure to get a simple repo of this one
Expected behavior
Analysis of the solution should complete without authentication errors.
Server (please complete the following information):
The text was updated successfully, but these errors were encountered: