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

Make handling of DefaultCredentials in NegotiateAuthentication/SocketsHttpHandler more consistent #91160

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

filipnavara
Copy link
Member

@filipnavara filipnavara commented Aug 26, 2023

See PR #91138 for alternative approach.

Report UnknownCredentials status on Unix/Managed NegotiateAuthenticationPal implementation for NTLM w/ default credentials

  • This was handled inconsistently between the managed NTLM implementation and the GSSAPI one. Let's standardize on throwing PlatformNotSupportedException with a useful message that explains which parameters are unsupported communicating back with NegotiateAuthenticationStatusCode.UnknownCredentials.
  • Add test for the behavior.

SocketsHttpHandler

  • Add test to ensure that using CredentialCache.DefaultCredentials with NTLM doesn't throw PNSE exception and returns the Unauthorized HTTP response instead.

Fixes #91131

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 26, 2023
@ghost
Copy link

ghost commented Aug 26, 2023

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

See PR #91138 for alternative approach.

Report UnknownCredentials status on Unix/Managed NegotiateAuthenticationPal implementation for NTLM w/ default credentials

  • This was handled inconsistently between the managed NTLM implementation and the GSSAPI one. Let's standardize on throwing PlatformNotSupportedException with a useful message that explains which parameters are unsupported communicating back with NegotiateAuthenticationStatusCode.UnknownCredentials.
  • Add test for the behavior.

SocketsHttpHandler

  • Add test to ensure that using CredentialCache.DefaultCredentials with NTLM doesn't throw PNSE exception and returns the Unauthorized HTTP response instead.

Fixes #91131

Author: filipnavara
Assignees: -
Labels:

area-System.Net.Security

Milestone: -

Debug.Assert(clientOptions.Package == NegotiationInfoClass.NTLM);

if (clientOptions.Credential == CredentialCache.DefaultNetworkCredentials ||
string.IsNullOrWhiteSpace(clientOptions.Credential.UserName) ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be an && between username and password.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was always || in all versions on .NET. It's not like empty user name with non-empty password, or vice versa, makes any sense.

Copy link

@dotMorten dotMorten Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not? I've seen services that only require password with empty username.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's valid in NTLM or Kerberos. It's valid in Basic authentication.

…ionPal implementation for NTLM w/ default credentials.

This was handled inconsistently between the managed NTLM implementation and the GSSAPI one.
Add test for the behavior.
Add test to ensure SocketsHttpHandler using CredentialCache.DefaultCredentials with NTLM doesn't throw PNSE exception and returns the Unauthorized HTTP response instead.
@filipnavara filipnavara changed the title Make handling of DefaultCredentials in NegotiateAuthentication/SocketsHttpHandler more consistent (alternative version) Make handling of DefaultCredentials in NegotiateAuthentication/SocketsHttpHandler more consistent Aug 29, 2023
Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wfurt wfurt merged commit b715349 into dotnet:main Aug 30, 2023
@filipnavara filipnavara deleted the nego-no-pnse-alt branch August 31, 2023 06:01
@karelz karelz added this to the 9.0.0 milestone Sep 6, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Security community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android NTLM: Empty Credentials now throws PlatformNotSupportedException
4 participants