Skip to content
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

NuGet should automatically send credentials after the first request with a HTTP 401 response #12962

Open
zivkan opened this issue Oct 23, 2023 · 0 comments

Comments

@zivkan
Copy link
Member

zivkan commented Oct 23, 2023

NuGet Product Used

Other/NA

Product Version

all

Worked before?

No response

Impact

Other

Repro Steps & Context

see:

After NuGet experiences one HTTP 401 response from a server, sending more unauthenticated requests just increases latency and increases the server workload processing these requests.

Any action where NuGet makes more than 1 HTTP request to a server will reproduce the result. For a V3 feed, since the first request is the service index, it's effectively possible to restore a single package, or open the browse tab in PM UI

In HttpSourceAuthenticationHandler, when a response is a HTTP 401, NuGet needs to check if the WWW-Authenticate header exists, and if so, when it responds with the Basic scheme, NuGet needs to explicitly set the Authorization header on all future requests. If a future 401 response is received, credentials should be re-requested, in case the customer interactively provided a credential and made a typo, or if a cred provider returned a time-limited token that needs to be refreshed.

Since we're going to have to handle Basic authentication ourselves, it would be great to also handle Bearer, since that will enable OAuth2 (including OIDC) credential providers. It should be effectively zero cost to add once Basic is handled.

We previously tried HttpClientHandler.PreAuthenticate, but there's a bug in the .NET runtime:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants