-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
area-System.Net.Httpneeds-author-actionAn issue or pull request that requires more info or actions from the author.An issue or pull request that requires more info or actions from the author.questionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.
Description
Description
Hello! I faced the same issue as #28531 but on Windows and net9.0.
Thank you.
Reproduction Steps
I.m using YARP to proxy requests to IIS powered WebApi service that is using Windows authentication. SocketsHttpHandler is used in the following way:
.ConfigureHttpClient((ForwarderHttpClientContext context, SocketsHttpHandler handler) =>
{
// https://github.com/dotnet/yarp/issues/166#issuecomment-1286334749
handler.Credentials = CredentialCache.DefaultNetworkCredentials;
})It works well for instances that have valid Kerberos configuration but it returns 401 if it's not instead of switching to NTLMv2.
Expected behavior
SocketsHttpHandler is autenticated
Actual behavior
I got 401 HTTP response
Regression?
Framework-based HTTP clients seems to be working
Known Workarounds
I can workaround it with custom ICredentials implementation that is forcing to use NTML like this:
public class FallbackToNtmlCredentialManager : ICredentials
{
public NetworkCredential? GetCredential(Uri uri, string authType)
{
if (!string.Equals(authType, "NTLM", StringComparison.InvariantCultureIgnoreCase))
return null;
return CredentialCache.DefaultNetworkCredentials;
}
}Configuration
net9.0
Windows Server 2016
x64
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.Net.Httpneeds-author-actionAn issue or pull request that requires more info or actions from the author.An issue or pull request that requires more info or actions from the author.questionAnswer questions and provide assistance, not an issue with source code or documentation.Answer questions and provide assistance, not an issue with source code or documentation.