acordner
acordner

Reputation: 235

Private NuGet package server hosted on AWS returns 403 Forbidden error for just one NuGet package

Many years ago I set up a NuGet server on an AWS instance to host NuGet packages for my team's software projects. It has been working great, until today.

I had a project that belonged to a larger solution that was puyblishing a NuGet package to my server when its Jenkins job ran. I needed to move that project to its own Git repo with its own solution and its own build script with its own Jenkins job. Everything was fine. The new Jenkins job builds from the new repo and publishes the NuGet package to my server.

However, when I then tried to add that NuGet package to another project using Visual Studio 2019, I got a credential prompt for my NuGet server which never happens (the project already uses other NuGet packages from that server). At a loss, I tried entering the Windows administrator account password for the AWS server. The prompt went away and has not come back.

The Manage NuGet Packages in Visual Studio shows the package with the version from the latest build, but when I try to add that package to my project I get a 403 Forbidden error. This is the only NuGet package on that server that has this problem. All others work successfully.

I have checked folder permissions on the NuGet server website's \Packages folder as well as the specific folder for this NuGet package. Nothing seems out of place. I have removed and replaced the NuGet package's folder from the \Packages directory for the website. There is nothing in the web.config file for the server that I can see that would cause this. I don't know what else to check. Google searches for 403 Forbidden errors on NuGet servers have not revealed anything that seemed relevant. I am not using TFS. All other packages work correctly. Why does one package have this issue?

UPDATE: When I tried using command line to install this package, this is the output:

PM> install-Package MyPackage -Version 3.0.0-devbuild0229

Attempting to gather dependency information for package 'MyPackage.3.0.0-devbuild0229' with respect to project 'MyProject', targeting '.NETFramework,Version=v4.8'

Gathering dependency information took 320 ms

Attempting to resolve dependencies for package 'MyPackage.3.0.0-devbuild0229' with DependencyBehavior 'Lowest'

Resolving dependency information took 0 ms

Resolving actions to install package 'MyPackage.3.0.0-devbuild0229'

Resolved actions to install package 'MyPackage.3.0.0-devbuild0229'

Retrieving package 'MyPackage 3.0.0-devbuild0229' from 'MySource'.

GET http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229

Forbidden http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229 1647ms

Error downloading 'MyPackage.3.0.0-devbuild0229' from 'http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229'.

Response status code does not indicate success: 403 (Forbidden).

GET http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229

Forbidden http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229 667ms

Error downloading 'MyPackage.3.0.0-devbuild0229' from 'http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229'.

Response status code does not indicate success: 403 (Forbidden).

GET http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229

Forbidden http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229 645ms

Install failed. Rolling back...

Package 'MyPackage.3.0.0-devbuild0229' does not exist in project 'MyProject'

Package 'MyPackage.3.0.0-devbuild0229' does not exist in folder 'C:\MyProject\packages'

Executing nuget actions took 3.78 sec

install-Package : Error downloading 'MyPackage.3.0.0-devbuild0229' from 'http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/mypackage/3.0.0-devbuild0229'.

Response status code does not indicate success: 403 (Forbidden).

At line:1 char:1

Time Elapsed: 00:00:04.4888243

Upvotes: 1

Views: 1230

Answers (1)

acordner
acordner

Reputation: 235

As it turns out, our IT department recently put in place some additional restrictions on accessing AWS servers using an application called Zscalar. By clicking on the link in the Forbidden message in the Output window in VS my browser opens to a Zscalar web page that indicates:

You tried to visit: http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/api/v2/package/myPackage... Proceeding to visit the site may violate your company policy. Press the "Continue" button to access the site anyway or press the "Back" button on your browser to go back

Clicking the Continue button on this page allows Visual Studio to successfully download the NuGet package, but only temporarily, so this process has to be repeated regularly.

I am working with our IT department to resolve the issue.

Upvotes: 1

Related Questions