-
Notifications
You must be signed in to change notification settings - Fork 5k
Ignore DefaultCredentials when doing Basic & Digest auth in SocketsHttpHandler #113728
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
Ignore DefaultCredentials when doing Basic & Digest auth in SocketsHttpHandler #113728
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR prevents Basic authentication from mistakenly using DefaultCredentials in SocketsHttpHandler.
- Adds a conditional check in the Basic authentication case to skip processing when DefaultCredentials is used.
- Enhances the authentication handling by ensuring only supported credential types are processed in Basic auth.
Comments suppressed due to low confidence (1)
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs:269
- [nitpick] Consider verifying that the variable name 'credentials' is consistent with other parts of the code where a similar credential is referred to as 'credential'. If applicable, renaming it for consistency may help reduce confusion.
if (CredentialCache.DefaultCredentials == credentials)
cc @MihaZupan |
Can you please add a test that validates the new behavior? |
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs
Outdated
Show resolved
Hide resolved
Updated the SocketsHttpHandler_UseDefaultCredentials test to utilize [Theory] and [InlineData] attributes, allowing for testing with both Basic and Digest authentication types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thans @makazeu
Fixes #113145.
As described in #113145 (comment)