http.sys: Allow configuring extended authentication flags (HTTP_AUTH_EX_FLAG) as options #51990
Description
Background and Motivation
The native HTTP.sys API offers two extended authentication flags:
that can be used by users to fine-tune their Windows authentication setups:
For instance, the HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING
flag can be used to avoid having to authenticate every request and make the authentication session-based, thus reducing the overall number of requests and improving the high-latency scenarios. Enabling it can be used to achieve the same behavior as with the authPersistNonNTLM
option in IIS.
This proposal exposes this part of the stable Win32 HTTP Server API as configuration options of the HttpSys
server.
See #51833 for additional details.
See #13634 for a usage example.
Proposed API
namespace Microsoft.AspNetCore.Server.HttpSys;
public sealed class AuthenticationManager
{
+ /// <summary>
+ /// If true, the Kerberos authentication credentials are persisted per connection
+ /// and re-used for subsequent anonymous requests on the same connection.
+ /// Kerberos or Negotiate authentication must be enabled. The default is false.
+ /// </summary>
+ public bool EnableKerberosCredentialCaching { get; set; }
+ /// <summary>
+ /// If true, the server captures the caller's credentials and uses them for Kerberos
+ /// or Negotiate authentication. Kerberos or Negotiate authentication must be enabled.
+ /// The default is false.
+ /// </summary>
+ public bool CaptureCredentials { get; set; }
}
Usage Examples
webBuilder.UseHttpSys(options =>
{
options.Authentication.Schemes = AuthenticationSchemes.Negotiate;
options.Authentication.EnableKerberosCredentialCaching = true;
});
Alternative Designs
-
Potentially, these options could've been expressed as a single enum
[Flags]
property.However, the existing properties in
AuthenticationManager
tend to usebool
properties for similar configuration settings (bool AllowAnonymous
,bool AutomaticAuthentication
).Also, the
ExFlags
field in the nativeHTTP_SERVER_AUTHENTICATION_INFO
structure seems to exist for a historical reason — presumably, to pack multiple new values into a single available byte, because older similar fields are bool-typed. -
There are possible naming variations for the new boolean options.
The currently selected naming scheme fully mirrors the names of the corresponding flags from the native API (such as
HTTP_AUTH_EX_FLAG_ENABLE_KERBEROS_CREDENTIAL_CACHING
), to avoid any unintended semantic changes.
Risks
None that I'm aware of: new options mirror an existing stable Win32 HTTP Server API.