Skip to content

Commit 1a0fc36

Browse files
Add log for unsupported protocol with Negotiate auth (#31888)
1 parent c780f23 commit 1a0fc36

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Security/Authentication/Negotiate/src/Internal/NegotiateLoggingExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal static class NegotiateLoggingExtensions
1818
private static Action<ILogger, Exception?> _reauthenticating;
1919
private static Action<ILogger, Exception?> _deferring;
2020
private static Action<ILogger, string, Exception?> _negotiateError;
21+
private static Action<ILogger, string, Exception?> _protocolNotSupported;
2122

2223
static NegotiateLoggingExtensions()
2324
{
@@ -65,6 +66,10 @@ static NegotiateLoggingExtensions()
6566
eventId: new EventId(11, "NegotiateError"),
6667
logLevel: LogLevel.Debug,
6768
formatString: "Negotiate error code: {error}.");
69+
_protocolNotSupported = LoggerMessage.Define<string>(
70+
eventId: new EventId(12, "ProtocolNotSupported"),
71+
logLevel: LogLevel.Debug,
72+
formatString: "Negotiate is not supported with {protocol}.");
6873
}
6974

7075
public static void IncompleteNegotiateChallenge(this ILogger logger)
@@ -99,5 +104,8 @@ public static void ClientError(this ILogger logger, Exception ex)
99104

100105
public static void NegotiateError(this ILogger logger, string error)
101106
=> _negotiateError(logger, error, null);
107+
108+
public static void ProtocolNotSupported(this ILogger logger, string protocol)
109+
=> _protocolNotSupported(logger, protocol, null);
102110
}
103111
}

src/Security/Authentication/Negotiate/src/NegotiateHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
299299
// Not supported. We don't throw because Negotiate may be set as the default auth
300300
// handler on a server that's running HTTP/1 and HTTP/2. We'll challenge HTTP/2 requests
301301
// that require auth and they'll downgrade to HTTP/1.1.
302+
Logger.ProtocolNotSupported(Request.Protocol);
302303
return AuthenticateResult.NoResult();
303304
}
304305

0 commit comments

Comments
 (0)